org.apache.qpid.proton.amqp.messaging.TerminusDurability Java Examples
The following examples show how to use
org.apache.qpid.proton.amqp.messaging.TerminusDurability.
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: 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 #2
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 #3
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 #4
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 #5
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 #6
Source File: ClientDefinedMultiConsumerTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test(timeout = 60000) public void testAddressDoesntExist() throws Exception { AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect("myClientId")); AmqpSession session = connection.createSession(); Source source = createNonSharedSource(TerminusDurability.CONFIGURATION); Source source1 = createSharedSource(TerminusDurability.CONFIGURATION); AmqpReceiver receiver = session.createMulticastReceiver(source, "myReceiverID", "mySub"); try { session.createMulticastReceiver(source1, "myReceiverID", "mySub|2"); fail("Exception expected"); } catch (Exception e) { //expected } finally { receiver.close(); } connection.close(); }
Example #7
Source File: ClientDefinedMultiConsumerTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test(timeout = 60000) public void test2ConsumersOnNonSharedDurableAddress() throws Exception { AddressInfo addressInfo = new AddressInfo(address); addressInfo.getRoutingTypes().add(RoutingType.MULTICAST); server.addAddressInfo(addressInfo); AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect("myClientId")); AmqpSession session = connection.createSession(); Source source = createNonSharedSource(TerminusDurability.CONFIGURATION); Source source1 = createSharedSource(TerminusDurability.CONFIGURATION); AmqpReceiver receiver = session.createMulticastReceiver(source, "myReceiverID", "mySub"); try { session.createMulticastReceiver(source1, "myReceiverID", "mySub|2"); fail("Exception expected"); } catch (Exception e) { //expected } finally { receiver.close(); } connection.close(); }
Example #8
Source File: ClientDefinedMultiConsumerTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void test2ConsumersOnSharedVolatileAddressGlobal() throws Exception { AddressInfo addressInfo = new AddressInfo(address); addressInfo.getRoutingTypes().add(RoutingType.MULTICAST); server.addAddressInfo(addressInfo); AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect(false)); AmqpSession session = connection.createSession(); Source source = createSharedGlobalSource(TerminusDurability.NONE); AmqpReceiver receiver = session.createMulticastReceiver(source, "myReceiverID", "mySub"); AmqpReceiver receiver2 = session.createMulticastReceiver(source, "myReceiverID", "mySub|2"); receiver.flow(1); receiver2.flow(1); sendMessages(address.toString(), 2); AmqpMessage amqpMessage = receiver.receive(5, TimeUnit.SECONDS); assertNotNull(amqpMessage); amqpMessage = receiver2.receive(5, TimeUnit.SECONDS); assertNotNull(amqpMessage); assertEquals(2, ((QueueImpl)server.getPostOffice().getBinding(SimpleString.toSimpleString("mySub:shared-volatile:global")).getBindable()).getConsumerCount()); receiver.close(); assertNotNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("mySub:shared-volatile:global"))); receiver2.close(); //check its been deleted Wait.waitFor(new Wait.Condition() { @Override public boolean isSatisfied() throws Exception { return server.getPostOffice().getBinding(SimpleString.toSimpleString("mySub:shared-volatile:global")) == null; } }, 1000); connection.close(); }
Example #9
Source File: ClientDefinedMultiConsumerTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void test2ConsumersOnSharedVolatileAddressBrokerDefined() throws Exception { AddressInfo addressInfo = new AddressInfo(address); addressInfo.getRoutingTypes().add(RoutingType.MULTICAST); server.addAddressInfo(addressInfo); server.createQueue(new QueueConfiguration("myClientId.mySub:shared-volatile").setAddress(address).setAutoCreateAddress(false)); AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect("myClientId")); AmqpSession session = connection.createSession(); Source source = createSharedSource(TerminusDurability.NONE); AmqpReceiver receiver = session.createMulticastReceiver(source, "myReceiverID", "mySub"); AmqpReceiver receiver2 = session.createMulticastReceiver(source, "myReceiverID", "mySub|1"); receiver.flow(1); receiver2.flow(1); sendMessages(address.toString(), 2); AmqpMessage amqpMessage = receiver.receive(5, TimeUnit.SECONDS); assertNotNull(amqpMessage); amqpMessage = receiver2.receive(5, TimeUnit.SECONDS); assertNotNull(amqpMessage); assertEquals(2, ((QueueImpl)server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub:shared-volatile")).getBindable()).getConsumerCount()); receiver.close(); assertNotNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub:shared-volatile"))); receiver2.close(); //check its **Hasn't** been deleted assertNotNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub:shared-volatile"))); connection.close(); }
Example #10
Source File: ClientDefinedMultiConsumerTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void test2ConsumersOnSharedDurableAddress() throws Exception { AddressInfo addressInfo = new AddressInfo(address); addressInfo.getRoutingTypes().add(RoutingType.MULTICAST); server.addAddressInfo(addressInfo); AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect("myClientId")); AmqpSession session = connection.createSession(); Source source = createSharedSource(TerminusDurability.CONFIGURATION); AmqpReceiver receiver = session.createMulticastReceiver(source, "myReceiverID", "mySub"); AmqpReceiver receiver2 = session.createMulticastReceiver(source, "myReceiverID", "mySub|2"); receiver.flow(1); receiver2.flow(1); sendMessages(address.toString(), 2); AmqpMessage amqpMessage = receiver.receive(5, TimeUnit.SECONDS); assertNotNull(amqpMessage); amqpMessage = receiver2.receive(5, TimeUnit.SECONDS); assertNotNull(amqpMessage); assertEquals(2, ((QueueImpl)server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub")).getBindable()).getConsumerCount()); receiver.close(); assertNotNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub"))); receiver2.close(); //check its been deleted assertNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub"))); connection.close(); }
Example #11
Source File: ClientDefinedMultiConsumerTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void test2ConsumersOnSharedDurableAddressReconnect() throws Exception { AddressInfo addressInfo = new AddressInfo(address); addressInfo.getRoutingTypes().add(RoutingType.MULTICAST); server.addAddressInfo(addressInfo); AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect("myClientId")); AmqpSession session = connection.createSession(); Source source = createSharedSource(TerminusDurability.CONFIGURATION); AmqpReceiver receiver = session.createMulticastReceiver(source, "myReceiverID", "mySub"); AmqpReceiver receiver2 = session.createMulticastReceiver(source, "myReceiverID", "mySub|2"); receiver.flow(1); receiver2.flow(1); sendMessages(address.toString(), 2); AmqpMessage amqpMessage = receiver.receive(5, TimeUnit.SECONDS); assertNotNull(amqpMessage); amqpMessage = receiver2.receive(5, TimeUnit.SECONDS); assertNotNull(amqpMessage); assertEquals(2, ((QueueImpl)server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub")).getBindable()).getConsumerCount()); connection.close(); connection = addConnection(client.connect("myClientId")); session = connection.createSession(); assertNotNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub"))); receiver = session.createMulticastReceiver(source, "myReceiverID", "mySub"); receiver2 = session.createMulticastReceiver(source, "myReceiverID", "mySub|2"); receiver.close(); assertNotNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub"))); receiver2.close(); //check its been deleted assertNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub"))); connection.close(); }
Example #12
Source File: ClientDefinedMultiConsumerTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void test2ConsumersOnSharedDurableAddressReconnectwithNull() throws Exception { AddressInfo addressInfo = new AddressInfo(address); addressInfo.getRoutingTypes().add(RoutingType.MULTICAST); server.addAddressInfo(addressInfo); AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect("myClientId")); AmqpSession session = connection.createSession(); Source source = createSharedSource(TerminusDurability.CONFIGURATION); AmqpReceiver receiver = session.createMulticastReceiver(source, "myReceiverID", "mySub"); AmqpReceiver receiver2 = session.createMulticastReceiver(source, "myReceiverID", "mySub|2"); receiver.flow(1); receiver2.flow(1); sendMessages(address.toString(), 2); AmqpMessage amqpMessage = receiver.receive(5, TimeUnit.SECONDS); assertNotNull(amqpMessage); amqpMessage = receiver2.receive(5, TimeUnit.SECONDS); assertNotNull(amqpMessage); assertEquals(2, ((QueueImpl)server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub")).getBindable()).getConsumerCount()); connection.close(); connection = addConnection(client.connect("myClientId")); session = connection.createSession(); assertNotNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub"))); receiver = session.createDurableReceiver(null, "mySub"); receiver2 = session.createDurableReceiver(null, "mySub|2"); receiver.close(); assertNotNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub"))); receiver2.close(); //check its been deleted assertNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub"))); connection.close(); }
Example #13
Source File: ClientDefinedMultiConsumerTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void test2ConsumersOnSharedDurableAddressGlobal() throws Exception { AddressInfo addressInfo = new AddressInfo(address); addressInfo.getRoutingTypes().add(RoutingType.MULTICAST); server.addAddressInfo(addressInfo); AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect(false)); AmqpSession session = connection.createSession(); Source source = createSharedGlobalSource(TerminusDurability.CONFIGURATION); AmqpReceiver receiver = session.createMulticastReceiver(source, "myReceiverID", "mySub"); AmqpReceiver receiver2 = session.createMulticastReceiver(source, "myReceiverID", "mySub|2"); receiver.flow(1); receiver2.flow(1); sendMessages(address.toString(), 2); AmqpMessage amqpMessage = receiver.receive(5, TimeUnit.SECONDS); assertNotNull(amqpMessage); amqpMessage = receiver2.receive(5, TimeUnit.SECONDS); assertNotNull(amqpMessage); assertEquals(2, ((QueueImpl)server.getPostOffice().getBinding(SimpleString.toSimpleString("mySub:global")).getBindable()).getConsumerCount()); receiver.close(); assertNotNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("mySub:global"))); receiver2.close(); //check its been deleted assertNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("mySub:global"))); connection.close(); }
Example #14
Source File: ClientDefinedMultiConsumerTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private Source createNonSharedSource(TerminusDurability terminusDurability) { Source source = new Source(); source.setAddress(address.toString()); source.setCapabilities(TOPIC_CAPABILITY); source.setDurable(terminusDurability); return source; }
Example #15
Source File: ClientDefinedMultiConsumerTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private Source createSharedSource(TerminusDurability terminusDurability) { Source source = new Source(); source.setAddress(address.toString()); source.setCapabilities(TOPIC_CAPABILITY, SHARED); source.setDurable(terminusDurability); return source; }
Example #16
Source File: ClientDefinedMultiConsumerTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
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 #17
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 #18
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 #19
Source File: ClientDefinedMultiConsumerTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void test2ConsumersOnSharedVolatileAddressNoReceiverClose() throws Exception { AddressInfo addressInfo = new AddressInfo(address); addressInfo.getRoutingTypes().add(RoutingType.MULTICAST); server.addAddressInfo(addressInfo); AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect("myClientId")); AmqpSession session = connection.createSession(); Source source = createSharedSource(TerminusDurability.NONE); AmqpReceiver receiver = session.createMulticastReceiver(source, "myReceiverID", "mySub"); AmqpReceiver receiver2 = session.createMulticastReceiver(source, "myReceiverID", "mySub|2"); receiver.flow(1); receiver2.flow(1); sendMessages(address.toString(), 2); AmqpMessage amqpMessage = receiver.receive(5, TimeUnit.SECONDS); assertNotNull(amqpMessage); amqpMessage = receiver2.receive(5, TimeUnit.SECONDS); assertNotNull(amqpMessage); assertEquals(2, ((QueueImpl)server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub:shared-volatile")).getBindable()).getConsumerCount()); assertNotNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub:shared-volatile"))); //check its been deleted connection.close(); Wait.waitFor(new Wait.Condition() { @Override public boolean isSatisfied() throws Exception { return server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub:shared-volatile")) == null; } }, 1000); }
Example #20
Source File: ClientDefinedMultiConsumerTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void test2ConsumersOnSharedVolatileAddress() throws Exception { AddressInfo addressInfo = new AddressInfo(address); addressInfo.getRoutingTypes().add(RoutingType.MULTICAST); server.addAddressInfo(addressInfo); AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect("myClientId")); AmqpSession session = connection.createSession(); Source source = createSharedSource(TerminusDurability.NONE); AmqpReceiver receiver = session.createMulticastReceiver(source, "myReceiverID", "mySub"); AmqpReceiver receiver2 = session.createMulticastReceiver(source, "myReceiverID", "mySub|2"); receiver.flow(1); receiver2.flow(1); sendMessages(address.toString(), 2); AmqpMessage amqpMessage = receiver.receive(5, TimeUnit.SECONDS); assertNotNull(amqpMessage); amqpMessage = receiver2.receive(5, TimeUnit.SECONDS); assertNotNull(amqpMessage); assertEquals(2, ((QueueImpl)server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub:shared-volatile")).getBindable()).getConsumerCount()); receiver.close(); assertNotNull(server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub:shared-volatile"))); receiver2.close(); //check its been deleted Wait.waitFor(new Wait.Condition() { @Override public boolean isSatisfied() throws Exception { return server.getPostOffice().getBinding(SimpleString.toSimpleString("myClientId.mySub:shared-volatile")) == null; } }, 1000); connection.close(); }
Example #21
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 #22
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 #23
Source File: AmqpReceiverTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@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 #24
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 #25
Source File: DurableTopicTerminusFactory.java From enmasse with Apache License 2.0 | 4 votes |
@Override public Source getSource(String address) { Source source = super.getSource(address); source.setDurable(TerminusDurability.UNSETTLED_STATE); return source; }
Example #26
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 #27
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 #28
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 #29
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; }
Example #30
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); } }