Java Code Examples for org.apache.qpid.proton.amqp.messaging.Target#setDynamic()

The following examples show how to use org.apache.qpid.proton.amqp.messaging.Target#setDynamic() . 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 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 2
Source File: ProtonSessionImpl.java    From vertx-proton with Apache License 2.0 5 votes vote down vote up
@Override
public ProtonSender createSender(String address, ProtonLinkOptions senderOptions) {
  Sender sender = session.sender(getOrCreateLinkName(senderOptions));

  Symbol[] outcomes = new Symbol[] { Accepted.DESCRIPTOR_SYMBOL, Rejected.DESCRIPTOR_SYMBOL,
      Released.DESCRIPTOR_SYMBOL, Modified.DESCRIPTOR_SYMBOL };
  Source source = new Source();
  source.setOutcomes(outcomes);

  Target target = new Target();
  target.setAddress(address);
  if(senderOptions.isDynamic()) {
    target.setDynamic(true);
  }

  sender.setSource(source);
  sender.setTarget(target);

  ProtonSenderImpl s = new ProtonSenderImpl(sender);
  if (address == null) {
    s.setAnonymousSender(true);
  }

  s.openHandler((result) -> {
    LOG.trace("Sender open completed");
  });
  s.closeHandler((result) -> {
    if (result.succeeded()) {
      LOG.trace("Sender closed");
    } else {
      LOG.warn("Sender closed with error", result.cause());
    }
  });

  // Default to at-least-once
  s.setQoS(ProtonQoS.AT_LEAST_ONCE);

  return s;
}
 
Example 3
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 4
Source File: TargetType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
public Target newInstance(Object described)
{
    List l = (List) described;

    Target o = new Target();


    switch(7 - l.size())
    {

        case 0:
            Object val0 = l.get( 6 );
            if( val0 == null || val0.getClass().isArray() )
            {
                o.setCapabilities( (Symbol[]) val0 );
            }
            else
            {
                o.setCapabilities( (Symbol) val0 );
            }
        case 1:
            o.setDynamicNodeProperties( (Map) l.get( 5 ) );
        case 2:
            Boolean dynamic = (Boolean) l.get(4);
            o.setDynamic(dynamic == null ? false : dynamic);
        case 3:
            UnsignedInteger timeout = (UnsignedInteger) l.get(3);
            o.setTimeout(timeout == null ? UnsignedInteger.ZERO : timeout);
        case 4:
            Symbol expiryPolicy = (Symbol) l.get(2);
            o.setExpiryPolicy(expiryPolicy == null ? TerminusExpiryPolicy.SESSION_END : TerminusExpiryPolicy.valueOf(expiryPolicy));
        case 5:
            UnsignedInteger durable = (UnsignedInteger) l.get(1);
            o.setDurable(durable == null ? TerminusDurability.NONE : TerminusDurability.get(durable));
        case 6:
            o.setAddress( (String) l.get( 0 ) );
    }


    return o;
}