Java Code Examples for javax.jms.Session#createTopic()

The following examples show how to use javax.jms.Session#createTopic() . 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: TopicPublisher.java    From blog with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public static void main(String[] args) throws JMSException {
	ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
	Connection connection = factory.createConnection();
	connection.start();

	Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
	Topic topic = session.createTopic(TOPIC);

	MessageProducer producer = session.createProducer(topic);
	producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);

	int i=1;
	while (true) {
		TextMessage message = session.createTextMessage();
		message.setStringProperty(IDENTIFIER, "/a2/"+i);
		message.setText("message_" + System.currentTimeMillis());
		producer.send(message);
		System.out.println("Sent message: " + message.getText());
		try {
			Thread.sleep(2000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		i++;
	}
}
 
Example 2
Source File: AdvisoryTests.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
public void xtestMessageDiscardedAdvisory() throws Exception {
   Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   Topic topic = s.createTopic(getClass().getName());
   MessageConsumer consumer = s.createConsumer(topic);
   assertNotNull(consumer);

   Topic advisoryTopic = AdvisorySupport.getMessageDiscardedAdvisoryTopic((ActiveMQDestination) topic);
   MessageConsumer advisoryConsumer = s.createConsumer(advisoryTopic);
   //start throwing messages at the consumer
   MessageProducer producer = s.createProducer(topic);
   int count = (new ActiveMQPrefetchPolicy().getTopicPrefetch() * 2);
   for (int i = 0; i < count; i++) {
      BytesMessage m = s.createBytesMessage();
      producer.send(m);
   }

   Message msg = advisoryConsumer.receive(1000);
   assertNotNull(msg);
}
 
Example 3
Source File: JmsRedeliveredTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
public void testNoReceiveDurableConsumerDoesNotIncrementRedelivery() throws Exception {
   connection.setClientID(getName());
   connection.start();

   Session session = connection.createSession(true, Session.CLIENT_ACKNOWLEDGE);
   Topic topic = session.createTopic("topic-" + getName());
   MessageConsumer consumer = session.createDurableSubscriber(topic, "sub");

   MessageProducer producer = createProducer(session, topic);
   producer.send(createTextMessage(session));
   session.commit();

   TimeUnit.SECONDS.sleep(1);
   consumer.close();

   consumer = session.createDurableSubscriber(topic, "sub");
   Message msg = consumer.receive(1000);
   assertNotNull(msg);

   assertFalse("Message should not be redelivered.", msg.getJMSRedelivered());

   session.commit();
   session.close();
}
 
Example 4
Source File: JobSchedulerManagementTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testRemoveNotScheduled() throws Exception {
   Connection connection = createConnection();

   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

   // Create the Browse Destination and the Reply To location
   Destination management = session.createTopic(ScheduledMessage.AMQ_SCHEDULER_MANAGEMENT_DESTINATION);

   MessageProducer producer = session.createProducer(management);

   try {

      // Send the remove request
      Message remove = session.createMessage();
      remove.setStringProperty(ScheduledMessage.AMQ_SCHEDULER_ACTION, ScheduledMessage.AMQ_SCHEDULER_ACTION_REMOVEALL);
      remove.setStringProperty(ScheduledMessage.AMQ_SCHEDULED_ID, new IdGenerator().generateId());
      producer.send(remove);
   } catch (Exception e) {
      fail("Caught unexpected exception during remove of unscheduled message.");
   }
}
 
Example 5
Source File: SubscriptionsIntegrationTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
private void doSharedSubscriptionLinkCapabilitySupportedTestImpl(boolean durable) throws Exception {
    try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
        // DONT include server connection capability to indicate support for shared-subs.
        // This will cause the link capability to be desired, and we verify success if offered.
        Symbol[] serverCapabilities = new Symbol[]{};

        Connection connection = testFixture.establishConnecton(testPeer, serverCapabilities);
        connection.start();

        testPeer.expectBegin();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

        String topicName = "myTopic";
        Topic dest = session.createTopic(topicName);
        String subscriptionName = "mySubscription";

        // Expect a shared receiver to attach, and succeed due to the server offering
        // the shared subs capability, i.e sharing is supported.
        if (durable) {
            Matcher<?> durableLinkNameMatcher = equalTo(subscriptionName);
            testPeer.expectSharedSubscriberAttach(topicName, subscriptionName, durableLinkNameMatcher, true, false, true, true, true);
            testPeer.expectLinkFlow();

            session.createSharedDurableConsumer(dest, subscriptionName);
        } else {
            Matcher<?> volatileLinkNameMatcher = equalTo(subscriptionName + SUB_NAME_DELIMITER + "volatile1");
            testPeer.expectSharedSubscriberAttach(topicName, subscriptionName, volatileLinkNameMatcher, false, false, true, true, true);
            testPeer.expectLinkFlow();

            session.createSharedConsumer(dest, subscriptionName);
        }

        testPeer.expectClose();
        connection.close();

        testPeer.waitForAllHandlersToComplete(1000);
    }
}
 
Example 6
Source File: JobSchedulerManagementTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testBrowseWithSelector() throws Exception {
   Connection connection = createConnection();

   // Setup the scheduled Message
   scheduleMessage(connection, TimeUnit.SECONDS.toMillis(9));
   scheduleMessage(connection, TimeUnit.SECONDS.toMillis(10));
   scheduleMessage(connection, TimeUnit.SECONDS.toMillis(5));
   scheduleMessage(connection, TimeUnit.SECONDS.toMillis(45));

   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

   // Create the Browse Destination and the Reply To location
   Destination requestBrowse = session.createTopic(ScheduledMessage.AMQ_SCHEDULER_MANAGEMENT_DESTINATION);
   Destination browseDest = session.createTemporaryTopic();

   // Create the "Browser"
   MessageConsumer browser = session.createConsumer(browseDest, ScheduledMessage.AMQ_SCHEDULED_DELAY + " = 45000");

   connection.start();

   // Send the browse request
   MessageProducer producer = session.createProducer(requestBrowse);
   Message request = session.createMessage();
   request.setStringProperty(ScheduledMessage.AMQ_SCHEDULER_ACTION, ScheduledMessage.AMQ_SCHEDULER_ACTION_BROWSE);
   request.setJMSReplyTo(browseDest);
   producer.send(request);

   // Now try and receive the one we selected
   Message message = browser.receive(5000);
   assertNotNull(message);
   assertEquals(45000, message.getLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY));

   // Now check if there are anymore, there shouldn't be
   message = browser.receive(5000);
   assertNull(message);
}
 
Example 7
Source File: SubscriptionsIntegrationTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
/**
 * Verifies that a shared volatile subscriber and shared durable subscriber with the same subscription name
 * can be active on the same connection at the same time and names their links appropriately to distinguish
 * themselves from each other.
 *
 * @throws Exception if an unexpected exception occurs
 */
@Test(timeout = 20000)
public void testSharedDurableAndVolatileSubsCoexistUsingDistinctLinkNames() throws Exception {
    try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
        // Add server connection capability to indicate support for shared-subs
        Symbol[] serverCapabilities = new Symbol[]{SHARED_SUBS};

        // Establish connection
        Connection connection = testFixture.establishConnecton(testPeer, serverCapabilities);
        connection.start();

        testPeer.expectBegin();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

        String topicName = "myTopic";
        Topic dest = session.createTopic(topicName);
        String subscriptionName = "mySubscription";

        // Attach the durable shared receiver
        Matcher<?> durableLinkNameMatcher = equalTo(subscriptionName);
        testPeer.expectSharedDurableSubscriberAttach(topicName, subscriptionName, durableLinkNameMatcher, true);
        testPeer.expectLinkFlow();

        session.createSharedDurableConsumer(dest, subscriptionName);

        // Attach the volatile shared receiver
        Matcher<?> volatileLinkNameMatcher = equalTo(subscriptionName + SUB_NAME_DELIMITER + "volatile1");
        testPeer.expectSharedVolatileSubscriberAttach(topicName, subscriptionName, volatileLinkNameMatcher, true);
        testPeer.expectLinkFlow();

        session.createSharedConsumer(dest, subscriptionName);

        testPeer.expectClose();
        connection.close();

        testPeer.waitForAllHandlersToComplete(1000);
    }
}
 
Example 8
Source File: ContextLookupCmpBean.java    From tomee with Apache License 2.0 5 votes vote down vote up
private void testJmsConnection(final Connection connection) throws JMSException {
    final Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
    final Topic topic = session.createTopic("test");
    final MessageProducer producer = session.createProducer(topic);
    producer.send(session.createMessage());
    producer.close();
    session.close();
    connection.close();
}
 
Example 9
Source File: ContextLookupStatelessBean.java    From tomee with Apache License 2.0 5 votes vote down vote up
private void testJmsConnection(final Connection connection) throws JMSException {
    final Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
    final Topic topic = session.createTopic("test");
    final MessageProducer producer = session.createProducer(topic);
    producer.send(session.createMessage());
    producer.close();
    session.close();
    connection.close();
}
 
Example 10
Source File: MessageRoutingTest.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
@Test
public void testRoutingWithRoutingKeySetAsJMSProperty() throws Exception
{
    assumeThat("AMQP 1.0 test", getProtocol(), is(equalTo(Protocol.AMQP_1_0)));

    prepare();

    Connection connection = getConnection();
    try
    {
        connection.start();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

        Destination sendingDestination = session.createTopic(EXCHANGE_NAME);
        Destination receivingDestination = session.createQueue(QUEUE_NAME);

        Message message = session.createTextMessage("test");
        message.setStringProperty("routing_key", ROUTING_KEY);

        MessageProducer messageProducer = session.createProducer(sendingDestination);
        messageProducer.send(message);

        MessageConsumer messageConsumer = session.createConsumer(receivingDestination);
        Message receivedMessage = messageConsumer.receive(getReceiveTimeout());

        assertNotNull("Message not received", receivedMessage);
        assertEquals("test", ((TextMessage) message).getText());
    }
    finally
    {
        connection.close();
    }
}
 
Example 11
Source File: ContextLookupMdbPojoBean.java    From tomee with Apache License 2.0 5 votes vote down vote up
private void testJmsConnection(final Connection connection) throws JMSException {
    final Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
    final Topic topic = session.createTopic("test");
    final MessageProducer producer = session.createProducer(topic);
    producer.send(session.createMessage());
    producer.close();
    session.close();
    connection.close();
}
 
Example 12
Source File: FederatedAddressTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testFederatedAddressDeployAfterQueuesExist() throws Exception {
   String address = getName();

   ConnectionFactory cf1 = getCF(1);
   ConnectionFactory cf0 = getCF(0);
   try (Connection connection1 = cf1.createConnection(); Connection connection0 = cf0.createConnection()) {
      connection1.start();
      connection0.start();

      Session session1 = connection1.createSession();
      Topic topic1 = session1.createTopic(address);
      MessageProducer producer = session1.createProducer(topic1);
      producer.send(session1.createTextMessage("hello"));


      Session session0 = connection0.createSession();
      Topic topic0 = session0.createTopic(address);
      MessageConsumer consumer0 = session0.createConsumer(topic0);


      producer.send(session1.createTextMessage("hello"));
      assertNull(consumer0.receive(100));

      FederationConfiguration federationConfiguration = FederatedTestUtil.createAddressUpstreamFederationConfiguration("server1", address);
      getServer(0).getConfiguration().getFederationConfigurations().add(federationConfiguration);
      getServer(0).getFederationManager().deploy();

      Wait.waitFor(() -> getServer(1).getPostOffice().getBindingsForAddress(
         SimpleString.toSimpleString(address)).getBindings().size() == 1, 2000, 100);

      producer.send(session1.createTextMessage("hello"));
      assertNotNull(consumer0.receive(1000));
   }
}
 
Example 13
Source File: ContextLookupMdbBean.java    From tomee with Apache License 2.0 5 votes vote down vote up
private void testJmsConnection(final Connection connection) throws JMSException {
    final Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
    final Topic topic = session.createTopic("test");
    final MessageProducer producer = session.createProducer(topic);
    producer.send(session.createMessage());
    producer.close();
    session.close();
    connection.close();
}
 
Example 14
Source File: MessageProducerTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendToQueueOnlyWhenTopicWithSameAddress() throws Exception {
   SimpleString addr = SimpleString.toSimpleString("testAddr");

   EnumSet<RoutingType> supportedRoutingTypes = EnumSet.of(RoutingType.ANYCAST, RoutingType.MULTICAST);

   servers.get(0).getActiveMQServer().addAddressInfo(new AddressInfo(addr, supportedRoutingTypes));
   servers.get(0).getActiveMQServer().createQueue(new QueueConfiguration(addr).setRoutingType(RoutingType.ANYCAST).setDurable(false));

   Connection pconn = createConnection();
   pconn.start();

   Session ps = pconn.createSession(false, Session.AUTO_ACKNOWLEDGE);

   Queue queue = ps.createQueue(addr.toString());
   Topic topic = ps.createTopic(addr.toString());

   MessageConsumer queueConsumer = ps.createConsumer(queue);
   MessageConsumer topicConsumer = ps.createConsumer(topic);

   MessageProducer queueProducer = ps.createProducer(queue);
   queueProducer.send(ps.createMessage());

   assertNotNull(queueConsumer.receive(1000));
   assertNull(topicConsumer.receiveNoWait());

   MessageProducer topicProducer = ps.createProducer(topic);
   topicProducer.send(ps.createMessage());

   assertNull(queueConsumer.receiveNoWait());
   assertNotNull(topicConsumer.receive(1000));
}
 
Example 15
Source File: EncCmp2Bean.java    From tomee with Apache License 2.0 5 votes vote down vote up
private void testJmsConnection(final Connection connection) throws JMSException {
    final Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
    final Topic topic = session.createTopic("test");
    final MessageProducer producer = session.createProducer(topic);
    producer.send(session.createMessage());
    producer.close();
    session.close();
    connection.close();
}
 
Example 16
Source File: ConfigTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testConnectorConfig() throws Exception {

   File journalFile = new File(JOURNAL_ROOT + "testMemoryConfig");
   recursiveDelete(journalFile);

   File derbyFile = new File(DERBY_ROOT + "testMemoryConfig");
   recursiveDelete(derbyFile);

   final int MAX_PRODUCERS = 5;
   final int MAX_CONSUMERS = 10;

   BrokerService broker = createBroker(new FileSystemResource(CONF_ROOT + "connector-properties.xml"));
   broker.start();
   try {

      assertEquals(broker.getTransportConnectorByScheme("tcp").getMaximumProducersAllowedPerConnection(), MAX_PRODUCERS);
      assertEquals(broker.getTransportConnectorByScheme("tcp").getMaximumConsumersAllowedPerConnection(), MAX_CONSUMERS);

      ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61631");
      javax.jms.Connection connection = activeMQConnectionFactory.createConnection();
      connection.start();
      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      Topic topic = session.createTopic("test.foo");

      for (int i = 0; i < MAX_PRODUCERS; i++) {
         session.createProducer(topic);
      }

      try {
         session.createProducer(topic);
         fail("Should have got an exception on exceeding MAX_PRODUCERS");
      } catch (JMSException expected) {
      }

      try {
         for (int i = 0; i < (MAX_CONSUMERS + 1); i++) {
            MessageConsumer consumer = session.createConsumer(topic);
            assertNotNull(consumer);
         }
         fail("Should have caught an exception");
      } catch (JMSException e) {
      }

      LOG.info("Success");
   } finally {
      broker.stop();
   }
}
 
Example 17
Source File: VirtualTopicToFQQNOpenWireTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testTwoTopicSubsSameNameAutoVirtualTopicFQQN() throws Exception {
   Connection connection = null;

   SimpleString topic1 = new SimpleString("VirtualTopic.Orders1");
   SimpleString topic2 = new SimpleString("VirtualTopic.Orders2");

   this.server.getAddressSettingsRepository().getMatch("VirtualTopic.#").setAutoCreateQueues(true);
   this.server.getAddressSettingsRepository().getMatch("VirtualTopic.#").setAutoCreateAddresses(true);

   try {
      ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory(urlString);
      activeMQConnectionFactory.setWatchTopicAdvisories(false);
      connection = activeMQConnectionFactory.createConnection();
      connection.start();

      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      Destination destination1 = session.createTopic(topic1.toString());
      Destination destination2 = session.createTopic(topic2.toString());

      MessageConsumer messageConsumer1 = session.createConsumer(session.createQueue("Consumer.A." + topic1.toString()));
      MessageConsumer messageConsumer2 = session.createConsumer(session.createQueue("Consumer.A." + topic2.toString()));

      MessageProducer producer = session.createProducer(null);
      TextMessage message = session.createTextMessage("This is a text message to 1");
      producer.send(destination1, message);
      message = session.createTextMessage("This is a text message to 2");
      producer.send(destination2, message);


      TextMessage messageReceived1 = (TextMessage) messageConsumer1.receive(2000);
      TextMessage messageReceived2 = (TextMessage) messageConsumer2.receive(2000);

      assertNotNull(messageReceived1);
      assertNotNull(messageReceived2);

      String text = messageReceived1.getText();
      assertEquals("This is a text message to 1", text);

      text = messageReceived2.getText();
      assertEquals("This is a text message to 2", text);

      messageConsumer1.close();
      messageConsumer2.close();

   } finally {
      if (connection != null) {
         connection.close();
      }
   }
}
 
Example 18
Source File: FQQNOpenWireTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testVirtualTopicFQQNAutoCreateQWithExistingAddressWithAnyCastDefault() throws Exception {
   Connection exConn = null;

   SimpleString topic = new SimpleString("VirtualTopic.Orders");
   SimpleString subscriptionQ = new SimpleString("Consumer.A");

   // defaults are false via test setUp
   this.server.addAddressInfo(new AddressInfo(topic, RoutingType.MULTICAST));
   this.server.getAddressSettingsRepository().getMatch("VirtualTopic.#").setAutoCreateQueues(true);
   this.server.getAddressSettingsRepository().getMatch("VirtualTopic.#").setAutoCreateAddresses(false);

   // set default to anycast which would fail if used in queue auto creation
   this.server.getAddressSettingsRepository().getMatch("VirtualTopic.#").setDefaultAddressRoutingType(RoutingType.ANYCAST);

   try {
      ActiveMQConnectionFactory exFact = new ActiveMQConnectionFactory();
      exFact.setWatchTopicAdvisories(false);
      exConn = exFact.createConnection();
      exConn.start();

      Session session = exConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      Destination destination = session.createTopic(topic.toString());
      MessageProducer producer = session.createProducer(destination);

      Destination destinationFQN = session.createQueue(CompositeAddress.toFullyQualified(topic, subscriptionQ).toString());

      MessageConsumer messageConsumerA = session.createConsumer(destinationFQN);
      MessageConsumer messageConsumerB = session.createConsumer(destinationFQN);

      TextMessage message = session.createTextMessage("This is a text message");
      producer.send(message);

      // only one consumer should get the message
      TextMessage messageReceivedA = (TextMessage) messageConsumerA.receive(2000);
      TextMessage messageReceivedB = (TextMessage) messageConsumerB.receive(2000);

      assertTrue((messageReceivedA == null || messageReceivedB == null));
      String text = messageReceivedA != null ? messageReceivedA.getText() : messageReceivedB.getText();
      assertEquals("This is a text message", text);

      messageConsumerA.close();
      messageConsumerB.close();

   } finally {
      if (exConn != null) {
         exConn.close();
      }
   }
}
 
Example 19
Source File: FQQNOpenWireTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testVirtualTopicFQQN() throws Exception {
   Connection exConn = null;

   SimpleString topic = new SimpleString("VirtualTopic.Orders");
   SimpleString subscriptionQ = new SimpleString("Consumer.A");

   this.server.addAddressInfo(new AddressInfo(topic, RoutingType.MULTICAST));
   this.server.createQueue(new QueueConfiguration(subscriptionQ).setAddress(topic));

   try {
      ActiveMQConnectionFactory exFact = new ActiveMQConnectionFactory();
      exFact.setWatchTopicAdvisories(false);
      exConn = exFact.createConnection();
      exConn.start();

      Session session = exConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      Destination destination = session.createTopic(topic.toString());
      MessageProducer producer = session.createProducer(destination);

      Destination destinationFQN = session.createQueue(CompositeAddress.toFullyQualified(topic, subscriptionQ).toString());
      MessageConsumer messageConsumerA = session.createConsumer(destinationFQN);
      MessageConsumer messageConsumerB = session.createConsumer(destinationFQN);

      TextMessage message = session.createTextMessage("This is a text message");
      producer.send(message);

      // only one consumer should get the message
      TextMessage messageReceivedA = (TextMessage) messageConsumerA.receive(2000);
      TextMessage messageReceivedB = (TextMessage) messageConsumerB.receive(2000);

      assertTrue((messageReceivedA == null || messageReceivedB == null));
      String text = messageReceivedA != null ? messageReceivedA.getText() : messageReceivedB.getText();
      assertEquals("This is a text message", text);

      messageConsumerA.close();
      messageConsumerB.close();

   } finally {
      if (exConn != null) {
         exConn.close();
      }
   }
}
 
Example 20
Source File: FederatedAddressTest.java    From activemq-artemis with Apache License 2.0 2 votes vote down vote up
private void testFederatedAddressReplication(String address) throws Exception {

      ConnectionFactory cf1 = getCF(1);
      ConnectionFactory cf0 = getCF(0);
      try (Connection connection1 = cf1.createConnection(); Connection connection0 = cf0.createConnection()) {
         connection1.start();
         connection0.start();

         Session session1 = connection1.createSession();
         Topic topic1 = session1.createTopic(address);
         MessageProducer producer = session1.createProducer(topic1);
         producer.send(session1.createTextMessage("hello"));


         Session session0 = connection0.createSession();
         Topic topic0 = session0.createTopic(address);
         MessageConsumer consumer0 = session0.createConsumer(topic0);

         assertTrue(Wait.waitFor(() -> getServer(1).getPostOffice().getBindingsForAddress(
            SimpleString.toSimpleString(address)).getBindings().size() == 1, 2000, 100));

         producer.send(session1.createTextMessage("hello"));

         assertNotNull(consumer0.receive(1000));


         producer.send(session1.createTextMessage("hello"));

         assertNotNull(consumer0.receive(1000));

         MessageConsumer consumer1 = session1.createConsumer(topic1);

         producer.send(session1.createTextMessage("hello"));

         assertNotNull(consumer1.receive(1000));
         assertNotNull(consumer0.receive(1000));
         consumer1.close();

         //Groups
         producer.send(session1.createTextMessage("hello"));
         assertNotNull(consumer0.receive(1000));

         producer.send(createTextMessage(session1, "groupA"));

         assertNotNull(consumer0.receive(1000));
         consumer1 = session1.createConsumer(topic1);

         producer.send(createTextMessage(session1, "groupA"));
         assertNotNull(consumer1.receive(1000));
         assertNotNull(consumer0.receive(1000));

      }

   }