org.apache.qpid.proton.amqp.messaging.TerminusExpiryPolicy Java Examples
The following examples show how to use
org.apache.qpid.proton.amqp.messaging.TerminusExpiryPolicy.
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 |
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 |
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: TargetType.java From qpid-proton-j with Apache License 2.0 | 6 votes |
public int size() { return _impl.getCapabilities() != null ? 7 : _impl.getDynamicNodeProperties() != null ? 6 : _impl.getDynamic() ? 5 : (_impl.getTimeout() != null && !_impl.getTimeout().equals(UnsignedInteger.ZERO)) ? 4 : !_impl.getExpiryPolicy().equals(TerminusExpiryPolicy.SESSION_END) ? 3 : !_impl.getDurable().equals(TerminusDurability.NONE) ? 2 : _impl.getAddress() != null ? 1 : 0; }
Example #4
Source File: AmqpTempDestinationTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@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 #5
Source File: AmqpTempDestinationTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@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 #6
Source File: AmqpTemporaryDestinationBuilder.java From qpid-jms with Apache License 2.0 | 5 votes |
@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 #7
Source File: SourceType.java From qpid-proton-j with Apache License 2.0 | 5 votes |
public int size() { return _impl.getCapabilities() != null ? 11 : _impl.getOutcomes() != null ? 10 : _impl.getDefaultOutcome() != null ? 9 : _impl.getFilter() != null ? 8 : _impl.getDistributionMode() != null ? 7 : _impl.getDynamicNodeProperties() != null ? 6 : _impl.getDynamic() ? 5 : (_impl.getTimeout() != null && !_impl.getTimeout().equals(UnsignedInteger.ZERO)) ? 4 : _impl.getExpiryPolicy() != TerminusExpiryPolicy.SESSION_END ? 3 : _impl.getDurable() != TerminusDurability.NONE ? 2 : _impl.getAddress() != null ? 1 : 0; }
Example #8
Source File: AmqpDurableReceiverTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void testLookupExistingSubscription() throws Exception { AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.createConnection()); connection.setContainerId(getContainerID()); connection.connect(); AmqpSession session = connection.createSession(); AmqpReceiver receiver = session.createDurableReceiver(getTopicName(), getSubscriptionName()); receiver.detach(); receiver = session.lookupSubscription(getSubscriptionName()); assertNotNull(receiver); Receiver protonReceiver = receiver.getReceiver(); assertNotNull(protonReceiver.getRemoteSource()); Source remoteSource = (Source) protonReceiver.getRemoteSource(); if (remoteSource.getFilter() != null) { assertFalse(remoteSource.getFilter().containsKey(NO_LOCAL_NAME)); assertFalse(remoteSource.getFilter().containsKey(JMS_SELECTOR_NAME)); } assertEquals(TerminusExpiryPolicy.NEVER, remoteSource.getExpiryPolicy()); assertEquals(TerminusDurability.UNSETTLED_STATE, remoteSource.getDurable()); assertEquals(COPY, remoteSource.getDistributionMode()); receiver.close(); try { receiver = session.lookupSubscription(getSubscriptionName()); fail("Should not be able to lookup the subscription"); } catch (Exception e) { } connection.close(); }
Example #9
Source File: AmqpDurableReceiverTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void testLookupExistingSubscriptionWithNoLocal() throws Exception { AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.createConnection()); connection.setContainerId(getContainerID()); connection.connect(); AmqpSession session = connection.createSession(); AmqpReceiver receiver = session.createDurableReceiver(getTopicName(), getSubscriptionName(), null, true); receiver.detach(); receiver = session.lookupSubscription(getSubscriptionName()); assertNotNull(receiver); Receiver protonReceiver = receiver.getReceiver(); assertNotNull(protonReceiver.getRemoteSource()); Source remoteSource = (Source) protonReceiver.getRemoteSource(); assertNotNull(remoteSource.getFilter()); assertTrue(remoteSource.getFilter().containsKey(NO_LOCAL_NAME)); assertFalse(remoteSource.getFilter().containsKey(JMS_SELECTOR_NAME)); assertEquals(TerminusExpiryPolicy.NEVER, remoteSource.getExpiryPolicy()); assertEquals(TerminusDurability.UNSETTLED_STATE, remoteSource.getDurable()); assertEquals(COPY, remoteSource.getDistributionMode()); receiver.close(); try { receiver = session.lookupSubscription(getSubscriptionName()); fail("Should not be able to lookup the subscription"); } catch (Exception e) { } connection.close(); }
Example #10
Source File: AmqpReceiver.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected void configureSource(Source source) { Map<Symbol, DescribedType> filters = new HashMap<>(); Symbol[] outcomes = new Symbol[] {Accepted.DESCRIPTOR_SYMBOL, Rejected.DESCRIPTOR_SYMBOL, Released.DESCRIPTOR_SYMBOL, Modified.DESCRIPTOR_SYMBOL}; if (getSubscriptionName() != null && !getSubscriptionName().isEmpty()) { source.setExpiryPolicy(TerminusExpiryPolicy.NEVER); source.setDurable(TerminusDurability.UNSETTLED_STATE); source.setDistributionMode(COPY); } else { source.setDurable(TerminusDurability.NONE); source.setExpiryPolicy(TerminusExpiryPolicy.LINK_DETACH); } source.setOutcomes(outcomes); Modified modified = new Modified(); modified.setDeliveryFailed(true); modified.setUndeliverableHere(false); source.setDefaultOutcome(modified); if (isNoLocal()) { filters.put(NO_LOCAL_NAME, AmqpNoLocalFilter.NO_LOCAL); } if (getSelector() != null && !getSelector().trim().equals("")) { filters.put(JMS_SELECTOR_NAME, new AmqpJmsSelectorFilter(getSelector())); } if (!filters.isEmpty()) { source.setFilter(filters); } }
Example #11
Source File: AMQPConnectionContext.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public void onRemoteDetach(Link link) throws Exception { handler.requireHandler(); boolean handleAsClose = link.getSource() != null && ((Source) link.getSource()).getExpiryPolicy() == TerminusExpiryPolicy.LINK_DETACH; if (handleAsClose) { onRemoteClose(link); } else { link.detach(); link.free(); } }
Example #12
Source File: ProtonServerReceiverContext.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public void close(boolean remoteLinkClose) throws ActiveMQAMQPException { protonSession.removeReceiver(receiver); org.apache.qpid.proton.amqp.messaging.Target target = (org.apache.qpid.proton.amqp.messaging.Target) receiver.getRemoteTarget(); if (target != null && target.getDynamic() && (target.getExpiryPolicy() == TerminusExpiryPolicy.LINK_DETACH || target.getExpiryPolicy() == TerminusExpiryPolicy.SESSION_END)) { try { sessionSPI.removeTemporaryQueue(SimpleString.toSimpleString(target.getAddress())); } catch (Exception e) { //ignore on close, its temp anyway and will be removed later } } }
Example #13
Source File: AmqpDurableReceiverTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test(timeout = 60000) public void testLookupExistingSubscriptionWithSelectorAndNoLocal() throws Exception { AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.createConnection()); connection.setContainerId(getContainerID()); connection.connect(); AmqpSession session = connection.createSession(); AmqpReceiver receiver = session.createDurableReceiver(getTopicName(), getSubscriptionName(), SELECTOR_STRING, true); receiver.detach(); receiver = session.lookupSubscription(getSubscriptionName()); assertNotNull(receiver); Receiver protonReceiver = receiver.getReceiver(); assertNotNull(protonReceiver.getRemoteSource()); Source remoteSource = (Source) protonReceiver.getRemoteSource(); assertNotNull(remoteSource.getFilter()); assertTrue(remoteSource.getFilter().containsKey(NO_LOCAL_NAME)); assertTrue(remoteSource.getFilter().containsKey(JMS_SELECTOR_NAME)); String selector = (String) ((DescribedType) remoteSource.getFilter().get(JMS_SELECTOR_NAME)).getDescribed(); assertEquals(SELECTOR_STRING, selector); assertEquals(TerminusExpiryPolicy.NEVER, remoteSource.getExpiryPolicy()); assertEquals(TerminusDurability.UNSETTLED_STATE, remoteSource.getDurable()); assertEquals(COPY, remoteSource.getDistributionMode()); receiver.close(); try { receiver = session.lookupSubscription(getSubscriptionName()); fail("Should not be able to lookup the subscription"); } catch (Exception e) { } connection.close(); }
Example #14
Source File: AmqpConsumerBuilder.java From qpid-jms with Apache License 2.0 | 4 votes |
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); } }
Example #15
Source File: ProtonPublisherImpl.java From vertx-proton with Apache License 2.0 | 4 votes |
public ProtonPublisherImpl(String address, ProtonConnectionImpl conn, ProtonPublisherOptions options) { this.connCtx = conn.getContext(); this.conn = conn; ProtonLinkOptions linkOptions = new ProtonLinkOptions(); if(options.getLinkName() != null) { linkOptions.setLinkName(options.getLinkName()); } receiver = conn.createReceiver(address, linkOptions); receiver.setAutoAccept(false); receiver.setPrefetch(0); if(options.getMaxOutstandingCredit() > 0) { maxOutstandingCredit = options.getMaxOutstandingCredit(); } org.apache.qpid.proton.amqp.messaging.Source source = (org.apache.qpid.proton.amqp.messaging.Source) receiver.getSource(); durable = options.isDurable(); if(durable) { source.setExpiryPolicy(TerminusExpiryPolicy.NEVER); source.setDurable(TerminusDurability.UNSETTLED_STATE); } if(options.isDynamic()) { source.setAddress(null); source.setDynamic(true); } ArrayList<Symbol> capabilities = new ArrayList<>(); if(options.isShared()) { capabilities.add(SHARED); } if(options.isGlobal()) { capabilities.add(GLOBAL); } if(!capabilities.isEmpty()) { Symbol[] caps = capabilities.toArray(new Symbol[capabilities.size()]); source.setCapabilities(caps); } }
Example #16
Source File: AmqpDurableReceiverTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
@Test(timeout = 60000) public void testLookupExistingSubscriptionWithSelector() throws Exception { AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.createConnection()); connection.setContainerId(getContainerID()); connection.connect(); AmqpSession session = connection.createSession(); AmqpReceiver receiver = session.createDurableReceiver(getTopicName(), getSubscriptionName(), SELECTOR_STRING, false); receiver.detach(); receiver = session.lookupSubscription(getSubscriptionName()); assertNotNull(receiver); Receiver protonReceiver = receiver.getReceiver(); assertNotNull(protonReceiver.getRemoteSource()); Source remoteSource = (Source) protonReceiver.getRemoteSource(); assertNotNull(remoteSource.getFilter()); assertFalse(remoteSource.getFilter().containsKey(NO_LOCAL_NAME)); assertTrue(remoteSource.getFilter().containsKey(JMS_SELECTOR_NAME)); String selector = (String) ((DescribedType) remoteSource.getFilter().get(JMS_SELECTOR_NAME)).getDescribed(); assertEquals(SELECTOR_STRING, selector); assertEquals(TerminusExpiryPolicy.NEVER, remoteSource.getExpiryPolicy()); assertEquals(TerminusDurability.UNSETTLED_STATE, remoteSource.getDurable()); assertEquals(COPY, remoteSource.getDistributionMode()); receiver.close(); try { receiver = session.lookupSubscription(getSubscriptionName()); fail("Should not be able to lookup the subscription"); } catch (Exception e) { } connection.close(); }
Example #17
Source File: SourceType.java From qpid-proton-j with Apache License 2.0 | 4 votes |
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 #18
Source File: TargetType.java From qpid-proton-j with Apache License 2.0 | 4 votes |
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; }