org.apache.qpid.proton.amqp.messaging.Source Java Examples
The following examples show how to use
org.apache.qpid.proton.amqp.messaging.Source.
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: AmqpSinkBridgeEndpointMockTest.java From strimzi-kafka-bridge with Apache License 2.0 | 6 votes |
@Test public <K, V> void filters_nonLongOffsetFilter() throws Exception { String topic = "my_topic"; Vertx vertx = Vertx.vertx(); AmqpSinkBridgeEndpoint<K, V> endpoint = (AmqpSinkBridgeEndpoint) new AmqpSinkBridgeEndpoint<>(vertx, BridgeConfig.fromMap(config), EmbeddedFormat.JSON, new StringDeserializer(), new ByteArrayDeserializer()); endpoint.open(); ProtonSender mockSender = mockSender(ProtonQoS.AT_MOST_ONCE, topic + "/group.id/blah"); // Call handle() Map<Symbol, Object> filter = new HashMap<>(); filter.put(Symbol.getSymbol(AmqpBridge.AMQP_PARTITION_FILTER), 0); filter.put(Symbol.getSymbol(AmqpBridge.AMQP_OFFSET_FILTER), "not a long"); ((Source) mockSender.getRemoteSource()).setFilter(filter); endpoint.handle(new AmqpEndpoint(mockSender)); assertDetach(mockSender, // TODO really? AmqpBridge.AMQP_ERROR_WRONG_OFFSET_FILTER, "Wrong offset filter"); }
Example #2
Source File: AmqpSinkBridgeEndpointMockTest.java From strimzi-kafka-bridge with Apache License 2.0 | 6 votes |
@Test public <K, V> void filters_nonIntegerPartitionFilter() throws Exception { String topic = "my_topic"; Vertx vertx = Vertx.vertx(); AmqpSinkBridgeEndpoint<K, V> endpoint = (AmqpSinkBridgeEndpoint) new AmqpSinkBridgeEndpoint<>(vertx, BridgeConfig.fromMap(config), EmbeddedFormat.JSON, new StringDeserializer(), new ByteArrayDeserializer()); endpoint.open(); ProtonSender mockSender = mockSender(ProtonQoS.AT_MOST_ONCE, topic + "/group.id/blah"); // Call handle() Map<Symbol, Object> filter = new HashMap<>(); filter.put(Symbol.getSymbol(AmqpBridge.AMQP_PARTITION_FILTER), "not an integer"); filter.put(Symbol.getSymbol(AmqpBridge.AMQP_OFFSET_FILTER), 10L); ((Source) mockSender.getRemoteSource()).setFilter(filter); endpoint.handle(new AmqpEndpoint(mockSender)); assertDetach(mockSender, AmqpBridge.AMQP_ERROR_WRONG_PARTITION_FILTER, "Wrong partition filter"); }
Example #3
Source File: ProtonServerReceiverContext.java From activemq-artemis with Apache License 2.0 | 6 votes |
private DeliveryState determineDeliveryState(final Source source, final boolean useModified, final Exception e) { Outcome defaultOutcome = getEffectiveDefaultOutcome(source); if (isAddressFull(e) && useModified && (outcomeSupported(source, Modified.DESCRIPTOR_SYMBOL) || defaultOutcome instanceof Modified)) { Modified modified = new Modified(); modified.setDeliveryFailed(true); return modified; } else { if (outcomeSupported(source, Rejected.DESCRIPTOR_SYMBOL) || defaultOutcome instanceof Rejected) { return createRejected(e); } else if (source.getDefaultOutcome() instanceof DeliveryState) { return ((DeliveryState) source.getDefaultOutcome()); } else { // The AMQP specification requires that Accepted is returned for this case. However there exist // implementations that set neither outcomes/default-outcome but use/expect for full range of outcomes. // To maintain compatibility with these implementations, we maintain previous behaviour. return createRejected(e); } } }
Example #4
Source File: AmqpSinkBridgeEndpointMockTest.java From strimzi-kafka-bridge with Apache License 2.0 | 6 votes |
@Test public <K, V> void filters_offsetFilterButNoPartitionFilter() throws Exception { String topic = "my_topic"; Vertx vertx = Vertx.vertx(); AmqpSinkBridgeEndpoint<K, V> endpoint = (AmqpSinkBridgeEndpoint) new AmqpSinkBridgeEndpoint<>(vertx, BridgeConfig.fromMap(config), EmbeddedFormat.JSON, new StringDeserializer(), new ByteArrayDeserializer()); endpoint.open(); ProtonSender mockSender = mockSender(ProtonQoS.AT_MOST_ONCE, topic + "/group.id/blah"); // Call handle() Map<Symbol, Object> filter = new HashMap<>(); //filter.put(Symbol.getSymbol(Bridge.AMQP_PARTITION_FILTER), 0); filter.put(Symbol.getSymbol(AmqpBridge.AMQP_OFFSET_FILTER), 10L); ((Source) mockSender.getRemoteSource()).setFilter(filter); endpoint.handle(new AmqpEndpoint(mockSender)); assertDetach(mockSender, AmqpBridge.AMQP_ERROR_NO_PARTITION_FILTER, "No partition filter specified"); }
Example #5
Source File: AmqpSinkBridgeEndpointMockTest.java From strimzi-kafka-bridge with Apache License 2.0 | 6 votes |
@Test public <K, V> void filters_negativeLongOffsetFilter() throws Exception { String topic = "my_topic"; Vertx vertx = Vertx.vertx(); AmqpSinkBridgeEndpoint<K, V> endpoint = (AmqpSinkBridgeEndpoint) new AmqpSinkBridgeEndpoint<>(vertx, BridgeConfig.fromMap(config), EmbeddedFormat.JSON, new StringDeserializer(), new ByteArrayDeserializer()); endpoint.open(); ProtonSender mockSender = mockSender(ProtonQoS.AT_MOST_ONCE, topic + "/group.id/blah"); // Call handle() Map<Symbol, Object> filter = new HashMap<>(); filter.put(Symbol.getSymbol(AmqpBridge.AMQP_PARTITION_FILTER), 0); filter.put(Symbol.getSymbol(AmqpBridge.AMQP_OFFSET_FILTER), -10L); ((Source) mockSender.getRemoteSource()).setFilter(filter); endpoint.handle(new AmqpEndpoint(mockSender)); assertDetach(mockSender, AmqpBridge.AMQP_ERROR_WRONG_FILTER, "Wrong filter"); }
Example #6
Source File: AmqpTransactionCoordinatorBuilder.java From qpid-jms with Apache License 2.0 | 6 votes |
@Override protected Sender createEndpoint(JmsSessionInfo resourceInfo) { Coordinator coordinator = new Coordinator(); coordinator.setCapabilities(TxnCapability.LOCAL_TXN); Symbol[] outcomes = new Symbol[]{ Accepted.DESCRIPTOR_SYMBOL, Rejected.DESCRIPTOR_SYMBOL, Released.DESCRIPTOR_SYMBOL, Modified.DESCRIPTOR_SYMBOL }; Source source = new Source(); source.setOutcomes(outcomes); String coordinatorName = "qpid-jms:coordinator:" + resourceInfo.getId().toString(); Sender sender = getParent().getSession().getEndpoint().sender(coordinatorName); sender.setSource(source); sender.setTarget(coordinator); sender.setSenderSettleMode(SenderSettleMode.UNSETTLED); sender.setReceiverSettleMode(ReceiverSettleMode.FIRST); return sender; }
Example #7
Source File: AmqpSinkBridgeEndpointMockTest.java From strimzi-kafka-bridge with Apache License 2.0 | 6 votes |
@Test public <K, V> void filters_negativeIntegerPartitionFilter() throws Exception { String topic = "my_topic"; Vertx vertx = Vertx.vertx(); AmqpSinkBridgeEndpoint<K, V> endpoint = (AmqpSinkBridgeEndpoint) new AmqpSinkBridgeEndpoint<>(vertx, BridgeConfig.fromMap(config), EmbeddedFormat.JSON, new StringDeserializer(), new ByteArrayDeserializer()); endpoint.open(); ProtonSender mockSender = mockSender(ProtonQoS.AT_MOST_ONCE, topic + "/group.id/blah"); // Call handle() Map<Symbol, Object> filter = new HashMap<>(); filter.put(Symbol.getSymbol(AmqpBridge.AMQP_PARTITION_FILTER), -1); filter.put(Symbol.getSymbol(AmqpBridge.AMQP_OFFSET_FILTER), 10L); ((Source) mockSender.getRemoteSource()).setFilter(filter); endpoint.handle(new AmqpEndpoint(mockSender)); ArgumentCaptor<ErrorCondition> errorCap = ArgumentCaptor.forClass(ErrorCondition.class); verify(mockSender).setCondition(errorCap.capture()); verify(mockSender).close(); assertDetach(mockSender, AmqpBridge.AMQP_ERROR_WRONG_FILTER, "Wrong filter"); }
Example #8
Source File: AmqpSession.java From activemq-artemis with Apache License 2.0 | 6 votes |
/** * Create a receiver instance using the given Source * * @param source the caller created and configured Source used to create the receiver link. * @return a newly created receiver that is ready for use. * @throws Exception if an error occurs while creating the receiver. */ public AmqpReceiver createMulticastReceiver(Source source, String receiverId, String receiveName) throws Exception { checkClosed(); final ClientFuture request = new ClientFuture(); final AmqpReceiver receiver = new AmqpReceiver(AmqpSession.this, source, receiverId); receiver.setSubscriptionName(receiveName); connection.getScheduler().execute(new Runnable() { @Override public void run() { checkClosed(); receiver.setStateInspector(getStateInspector()); receiver.open(request); pumpToProtonTransport(request); } }); request.sync(); return receiver; }
Example #9
Source File: AmqpTempDestinationTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
protected void doTestDynamicReceiverLifetimeBoundToLinkQueue(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(); Queue queueView = getProxyToQueue(remoteSource.getAddress()); assertNotNull(queueView); receiver.close(); queueView = getProxyToQueue(remoteSource.getAddress()); assertNull(queueView); connection.close(); }
Example #10
Source File: AmqpSession.java From activemq-artemis with Apache License 2.0 | 6 votes |
/** * Create a receiver instance using the given Source * * @param source the caller created and configured Source used to create the receiver link. * @param receiverId the receiver id to use. * @return a newly created receiver that is ready for use. * @throws Exception if an error occurs while creating the receiver. */ public AmqpReceiver createReceiver(Source source, String receiverId) throws Exception { checkClosed(); final ClientFuture request = new ClientFuture(); final AmqpReceiver receiver = new AmqpReceiver(AmqpSession.this, source, receiverId); connection.getScheduler().execute(new Runnable() { @Override public void run() { checkClosed(); receiver.setStateInspector(getStateInspector()); receiver.open(request); pumpToProtonTransport(request); } }); request.sync(); return receiver; }
Example #11
Source File: AmqpTransactionCoordinator.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Override protected void doOpen() { Coordinator coordinator = new Coordinator(); coordinator.setCapabilities(TxnCapability.LOCAL_TXN); Source source = new Source(); String coordinatorName = "qpid-jms:coordinator:" + session.getConnection().getConnectionId(); Sender sender = session.getEndpoint().sender(coordinatorName); sender.setSource(source); sender.setTarget(coordinator); sender.setSenderSettleMode(SenderSettleMode.UNSETTLED); sender.setReceiverSettleMode(ReceiverSettleMode.FIRST); setEndpoint(sender); super.doOpen(); }
Example #12
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 #13
Source File: BrokerDefinedMulticastConsumerTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test(timeout = 60000) public void testConsumeWhenOnlyAnycast() throws Exception { server.addAddressInfo(new AddressInfo(address, RoutingType.ANYCAST)); sendMessages(address.toString(), 1); AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect()); AmqpSession session = connection.createSession(); Source jmsSource = createJmsSource(true); jmsSource.setAddress(address.toString()); try { session.createReceiver(jmsSource); fail("should throw exception"); } catch (Exception e) { //ignore } connection.close(); }
Example #14
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 #15
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 #16
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 #17
Source File: BrokerDefinedAnycastConsumerTest.java From activemq-artemis with Apache License 2.0 | 6 votes |
@Test(timeout = 60000) public void testConsumeWhenOnlyMulticast() throws Exception { server.addAddressInfo(new AddressInfo(address, RoutingType.MULTICAST)); sendMessages(address.toString(), 1); AmqpClient client = createAmqpClient(); AmqpConnection connection = addConnection(client.connect()); AmqpSession session = connection.createSession(); Source jmsSource = createJmsSource(false); jmsSource.setAddress(address.toString()); try { session.createReceiver(jmsSource); fail("should throw exception"); } catch (Exception e) { //ignore } connection.close(); }
Example #18
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 #19
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 #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: 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 #22
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 #23
Source File: AmqpTempDestinationTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
protected void doTestCreateDynamicReceiverAndSend(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(); Queue queueView = getProxyToQueue(remoteSource.getAddress()); assertNotNull(queueView); // Get the new address String address = receiver.getReceiver().getRemoteSource().getAddress(); LOG.debug("New dynamic receiver address -> {}", address); // Create a message and send to a receive that is listening on the newly // created dynamic link address. AmqpMessage message = new AmqpMessage(); message.setMessageId("msg-1"); message.setText("Test-Message"); AmqpSender sender = session.createSender(address); sender.send(message); receiver.flow(1); AmqpMessage received = receiver.receive(5, TimeUnit.SECONDS); assertNotNull("Should have read a message", received); received.accept(); sender.close(); receiver.close(); connection.close(); }
Example #24
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 #25
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 #26
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 #27
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 #28
Source File: AmqpReceiverTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void testCreateQueueReceiverWithJMSSelector() throws Exception { AmqpClient client = createAmqpClient(); client.setValidator(new AmqpValidator() { @SuppressWarnings("unchecked") @Override public void inspectOpenedResource(Receiver receiver) { if (receiver.getRemoteSource() == null) { markAsInvalid("Link opened with null source."); } Source source = (Source) receiver.getRemoteSource(); Map<Symbol, Object> filters = source.getFilter(); if (findFilter(filters, JMS_SELECTOR_FILTER_IDS) == null) { markAsInvalid("Broker did not return the JMS Filter on Attach"); } } }); AmqpConnection connection = addConnection(client.connect()); AmqpSession session = connection.createSession(); session.createReceiver(getQueueName(), "JMSPriority > 8"); connection.getStateInspector().assertValid(); connection.close(); }
Example #29
Source File: AmqpReceiverTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Test(timeout = 60000) public void testCreateQueueReceiverWithNoLocalSet() throws Exception { AmqpClient client = createAmqpClient(); client.setValidator(new AmqpValidator() { @SuppressWarnings("unchecked") @Override public void inspectOpenedResource(Receiver receiver) { if (receiver.getRemoteSource() == null) { markAsInvalid("Link opened with null source."); } Source source = (Source) receiver.getRemoteSource(); Map<Symbol, Object> filters = source.getFilter(); // Currently don't support noLocal on a Queue if (findFilter(filters, NO_LOCAL_FILTER_IDS) != null) { markAsInvalid("Broker did not return the NoLocal Filter on Attach"); } } }); AmqpConnection connection = addConnection(client.connect()); AmqpSession session = connection.createSession(); session.createReceiver(getQueueName(), null, true); connection.getStateInspector().assertValid(); connection.close(); }
Example #30
Source File: BrokerDefinedMulticastConsumerTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
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; }