[ https://issues.apache.org/jira/browse/ARTEMIS-2520?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16951037#comment-16951037 ]
Domenico Bruscino commented on ARTEMIS-2520: -------------------------------------------- [~robbie] I see your point but {code:java}consumer.receive(5000);{code} throws an exception when {code:java}ConnectionFactory factorySend = new JmsConnectionFactory("amqp://localhost:61616");{code} or {code:java}ConnectionFactory factorySend = new org.apache.activemq.ActiveMQConnectionFactory("tcp://localhost:61616");{code} What is the expected behavior? > Consumer.receive return null if server is stopped > ------------------------------------------------- > > Key: ARTEMIS-2520 > URL: https://issues.apache.org/jira/browse/ARTEMIS-2520 > Project: ActiveMQ Artemis > Issue Type: Bug > Reporter: Domenico Bruscino > Priority: Major > > ActiveMQMessageConsumer.receive(timeout) returns null, if the server is > stopped during the call. > Test to reproduce: > {code:java} > 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(); > } > } > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)