Uploaded image for project: 'AMQ Broker'
  1. AMQ Broker
  2. ENTMQBR-2994

Consumer.receive return null if server is stopped

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major Major
    • None
    • None
    • None
    • None
    • Hide
      ConnectionFactory factorySend = new ActiveMQConnectionFactory();
      Connection connection = factorySend.createConnection();
      
      try (Session session = connection.createSession()) {
         javax.jms.Queue queue = session.createQueue("queueStop");
         MessageProducer producer = session.createProducer(queue);
         producer.send(session.createTextMessage("text"));
         connection.start();
         MessageConsumer consumer = session.createConsumer(queue);
         assertNotNull(consumer.receive(1000));
      
         final CountDownLatch stoppingLatch = new CountDownLatch(1);
         (new Thread(new Runnable() {
            @Override
            public void run() {
               try {
                  stoppingLatch.countDown();
                  Thread.sleep(1000);
                  server.stop();
               } catch (Exception e) {
                  e.printStackTrace();
               }
            }
         })).start();
      
         try {
            stoppingLatch.await();
            consumer.receive(5000);
            Assert.fail("didn't get expected exception!");
         } catch (Exception e) {
            e.printStackTrace();
         }
      }
      
      Show
      ConnectionFactory factorySend = new ActiveMQConnectionFactory(); Connection connection = factorySend.createConnection(); try (Session session = connection.createSession()) { javax.jms.Queue queue = session.createQueue( "queueStop" ); MessageProducer producer = session.createProducer(queue); producer.send(session.createTextMessage( "text" )); connection.start(); MessageConsumer consumer = session.createConsumer(queue); assertNotNull(consumer.receive(1000)); final CountDownLatch stoppingLatch = new CountDownLatch(1); ( new Thread ( new Runnable () { @Override public void run() { try { stoppingLatch.countDown(); Thread .sleep(1000); server.stop(); } catch (Exception e) { e.printStackTrace(); } } })).start(); try { stoppingLatch.await(); consumer.receive(5000); Assert.fail( "didn't get expected exception!" ); } catch (Exception e) { e.printStackTrace(); } }

      ActiveMQMessageConsumer.receive(timeout) returns null, if the server is stopped during the call.

              rh-ee-ataylor Andy Taylor
              dbruscin Domenico Francesco Bruscino
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: