org.apache.qpid.proton.amqp.messaging.DeleteOnClose Java Examples

The following examples show how to use org.apache.qpid.proton.amqp.messaging.DeleteOnClose. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AmqpClientTestSupport.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected Source createDynamicSource(boolean topic) {

      Source source = new Source();
      source.setDynamic(true);
      source.setDurable(TerminusDurability.NONE);
      source.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);

      // Set the dynamic node lifetime-policy
      Map<Symbol, Object> dynamicNodeProperties = new HashMap<>();
      dynamicNodeProperties.put(LIFETIME_POLICY, DeleteOnClose.getInstance());
      source.setDynamicNodeProperties(dynamicNodeProperties);

      // Set the capability to indicate the node type being created
      if (!topic) {
         source.setCapabilities(TEMP_QUEUE_CAPABILITY);
      } else {
         source.setCapabilities(TEMP_TOPIC_CAPABILITY);
      }

      return source;
   }
 
Example #2
Source File: AmqpClientTestSupport.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected Target createDynamicTarget(boolean topic) {

      Target target = new Target();
      target.setDynamic(true);
      target.setDurable(TerminusDurability.NONE);
      target.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);

      // Set the dynamic node lifetime-policy
      Map<Symbol, Object> dynamicNodeProperties = new HashMap<>();
      dynamicNodeProperties.put(LIFETIME_POLICY, DeleteOnClose.getInstance());
      target.setDynamicNodeProperties(dynamicNodeProperties);

      // Set the capability to indicate the node type being created
      if (!topic) {
         target.setCapabilities(TEMP_QUEUE_CAPABILITY);
      } else {
         target.setCapabilities(TEMP_TOPIC_CAPABILITY);
      }

      return target;
   }
 
Example #3
Source File: AmqpTempDestinationTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
protected void doTestCreateDynamicSender(boolean topic) throws Exception {
   Target target = createDynamicTarget(topic);

   AmqpClient client = createAmqpClient();
   AmqpConnection connection = addConnection(client.connect());
   AmqpSession session = connection.createSession();

   AmqpSender sender = session.createSender(target);
   assertNotNull(sender);

   Target remoteTarget = (Target) sender.getEndpoint().getRemoteTarget();
   assertTrue(remoteTarget.getDynamic());
   assertTrue(remoteTarget.getDurable().equals(TerminusDurability.NONE));
   assertTrue(remoteTarget.getExpiryPolicy().equals(TerminusExpiryPolicy.LINK_DETACH));

   // Check the dynamic node lifetime-policy
   Map<Symbol, Object> dynamicNodeProperties = remoteTarget.getDynamicNodeProperties();
   assertTrue(dynamicNodeProperties.containsKey(LIFETIME_POLICY));
   assertEquals(DeleteOnClose.getInstance(), dynamicNodeProperties.get(LIFETIME_POLICY));

   Queue queueView = getProxyToQueue(remoteTarget.getAddress());
   assertNotNull(queueView);

   connection.close();
}
 
Example #4
Source File: AmqpTempDestinationTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
protected void doTestCreateDynamicReceiver(boolean topic) throws Exception {
   Source source = createDynamicSource(topic);

   AmqpClient client = createAmqpClient();
   AmqpConnection connection = addConnection(client.connect());
   AmqpSession session = connection.createSession();

   AmqpReceiver receiver = session.createReceiver(source);
   assertNotNull(receiver);

   Source remoteSource = (Source) receiver.getEndpoint().getRemoteSource();
   assertTrue(remoteSource.getDynamic());
   assertTrue(remoteSource.getDurable().equals(TerminusDurability.NONE));
   assertTrue(remoteSource.getExpiryPolicy().equals(TerminusExpiryPolicy.LINK_DETACH));

   // Check the dynamic node lifetime-policy
   Map<Symbol, Object> dynamicNodeProperties = remoteSource.getDynamicNodeProperties();
   assertTrue(dynamicNodeProperties.containsKey(LIFETIME_POLICY));
   assertEquals(DeleteOnClose.getInstance(), dynamicNodeProperties.get(LIFETIME_POLICY));

   Queue queueView = getProxyToQueue(remoteSource.getAddress());
   assertNotNull(queueView);

   connection.close();
}
 
Example #5
Source File: AmqpTemporaryDestinationBuilder.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Override
protected Sender createEndpoint(JmsTemporaryDestination resourceInfo) {
    // Form a link name, use the local generated name with a prefix to aid debugging
    String localDestinationName = resourceInfo.getAddress();
    String senderLinkName = null;
    if (resourceInfo.isQueue()) {
        senderLinkName = "qpid-jms:" + TEMP_QUEUE_CREATOR + localDestinationName;
    } else {
        senderLinkName = "qpid-jms:" + TEMP_TOPIC_CREATOR + localDestinationName;
    }

    // Just use a bare Source, this is a producer which
    // wont send anything and the link name is unique.
    Source source = new Source();

    Target target = new Target();
    target.setDynamic(true);
    target.setDurable(TerminusDurability.NONE);
    target.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);

    // Set the dynamic node lifetime-policy
    Map<Symbol, Object> dynamicNodeProperties = new HashMap<Symbol, Object>();
    dynamicNodeProperties.put(DYNAMIC_NODE_LIFETIME_POLICY, DeleteOnClose.getInstance());
    target.setDynamicNodeProperties(dynamicNodeProperties);

    // Set the capability to indicate the node type being created
    if (resourceInfo.isQueue()) {
        target.setCapabilities(AmqpDestinationHelper.TEMP_QUEUE_CAPABILITY);
    } else {
        target.setCapabilities(AmqpDestinationHelper.TEMP_TOPIC_CAPABILITY);
    }

    Sender sender = getParent().getEndpoint().sender(senderLinkName);
    sender.setSource(source);
    sender.setTarget(target);
    sender.setSenderSettleMode(SenderSettleMode.UNSETTLED);
    sender.setReceiverSettleMode(ReceiverSettleMode.FIRST);

    return sender;
}
 
Example #6
Source File: DeleteOnCloseType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
@Override
protected List wrap(DeleteOnClose val)
{
    return Collections.EMPTY_LIST;
}
 
Example #7
Source File: DeleteOnCloseType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
public DeleteOnClose newInstance(Object described)
{
    return DeleteOnClose.getInstance();
}
 
Example #8
Source File: DeleteOnCloseType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
public Class<DeleteOnClose> getTypeClass()
{
    return DeleteOnClose.class;
}