Java Code Examples for org.apache.qpid.proton.amqp.messaging.Source#setCapabilities()

The following examples show how to use org.apache.qpid.proton.amqp.messaging.Source#setCapabilities() . 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: AmqpReceiverTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 60000)
public void testClientIdIsSetInSubscriptionList() throws Exception {
   server.addAddressInfo(new AddressInfo(SimpleString.toSimpleString("mytopic"), RoutingType.ANYCAST));

   AmqpClient client = createAmqpClient();
   AmqpConnection connection = addConnection(client.connect());
   connection.setContainerId("testClient");
   connection.connect();

   try {
      AmqpSession session = connection.createSession();

      Source source = new Source();
      source.setDurable(TerminusDurability.UNSETTLED_STATE);
      source.setCapabilities(Symbol.getSymbol("topic"));
      source.setAddress("mytopic");
      session.createReceiver(source, "testSub");

      SimpleString fo = new SimpleString("testClient.testSub:mytopic");
      assertNotNull(server.locateQueue(fo));

   } catch (Exception e) {
      e.printStackTrace();
   } finally {
      connection.close();
   }
}
 
Example 3
Source File: BrokerDefinedMulticastConsumerTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
protected Source createJmsSource(boolean topic) {

      Source source = new Source();
      // Set the capability to indicate the node type being created
      if (!topic) {
         source.setCapabilities(QUEUE_CAPABILITY);
      } else {
         source.setCapabilities(TOPIC_CAPABILITY);
      }

      return source;
   }
 
Example 4
Source File: ClientDefinedMultiConsumerTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private Source createNonSharedSource(TerminusDurability terminusDurability) {
   Source source = new Source();
   source.setAddress(address.toString());
   source.setCapabilities(TOPIC_CAPABILITY);
   source.setDurable(terminusDurability);
   return source;
}
 
Example 5
Source File: ClientDefinedMultiConsumerTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private Source createSharedSource(TerminusDurability terminusDurability) {
   Source source = new Source();
   source.setAddress(address.toString());
   source.setCapabilities(TOPIC_CAPABILITY, SHARED);
   source.setDurable(terminusDurability);
   return source;
}
 
Example 6
Source File: ClientDefinedMultiConsumerTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private Source createSharedGlobalSource(TerminusDurability terminusDurability) {
   Source source = new Source();
   source.setAddress(address.toString());
   source.setCapabilities(TOPIC_CAPABILITY, SHARED, GLOBAL);
   source.setDurable(terminusDurability);
   return source;
}
 
Example 7
Source File: BrokerDefinedAnycastConsumerTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
protected Source createJmsSource(boolean topic) {

      Source source = new Source();
      // Set the capability to indicate the node type being created
      if (!topic) {
         source.setCapabilities(QUEUE_CAPABILITY);
      } else {
         source.setCapabilities(TOPIC_CAPABILITY);
      }

      return source;
   }
 
Example 8
Source File: TopicTerminusFactory.java    From enmasse with Apache License 2.0 4 votes vote down vote up
@Override
public Source getSource(String address) {
    Source source = super.getSource(address);
    source.setCapabilities(Symbol.getSymbol("topic"));
    return source;
}
 
Example 9
Source File: SourceType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
public Source newInstance(Object described)
{
    List l = (List) described;

    Source o = new Source();


    switch(11 - l.size())
    {

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


    return o;
}
 
Example 10
Source File: AmqpConsumerBuilder.java    From qpid-jms with Apache License 2.0 4 votes vote down vote up
private void configureSource(Source source) {
    Map<Symbol, DescribedType> filters = new HashMap<Symbol, DescribedType>();
    Symbol[] outcomes = new Symbol[]{ Accepted.DESCRIPTOR_SYMBOL, Rejected.DESCRIPTOR_SYMBOL,
                                      Released.DESCRIPTOR_SYMBOL, Modified.DESCRIPTOR_SYMBOL };

    if (resourceInfo.isDurable()) {
        source.setExpiryPolicy(TerminusExpiryPolicy.NEVER);
        source.setDurable(TerminusDurability.UNSETTLED_STATE);
        source.setDistributionMode(COPY);
    } else {
        source.setDurable(TerminusDurability.NONE);
        source.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH);
    }

    if (resourceInfo.isBrowser()) {
        source.setDistributionMode(COPY);
    }

    // Capabilities
    LinkedList<Symbol> capabilities = new LinkedList<>();

    Symbol typeCapability =  AmqpDestinationHelper.toTypeCapability(resourceInfo.getDestination());
    if (typeCapability != null){
        capabilities.add(typeCapability);
    }

    if (resourceInfo.isShared()) {
        capabilities.add(AmqpSupport.SHARED);

        if(!resourceInfo.isExplicitClientID()) {
            capabilities.add(AmqpSupport.GLOBAL);
        }
    }

    if (!capabilities.isEmpty()) {
        Symbol[] capArray = capabilities.toArray(new Symbol[capabilities.size()]);
        source.setCapabilities(capArray);
    }

    //Outcomes
    source.setOutcomes(outcomes);
    source.setDefaultOutcome(MODIFIED_FAILED);

    // Filters
    if (resourceInfo.isNoLocal()) {
        filters.put(JMS_NO_LOCAL_SYMBOL, AmqpJmsNoLocalType.NO_LOCAL);
    }

    if (resourceInfo.getSelector() != null && !resourceInfo.getSelector().trim().equals("")) {
        filters.put(JMS_SELECTOR_SYMBOL, new AmqpJmsSelectorType(resourceInfo.getSelector()));
    }

    if (!filters.isEmpty()) {
        source.setFilter(filters);
    }
}