[ https://issues.apache.org/jira/browse/ARTEMIS-2520?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16952660#comment-16952660 ]
Domenico Bruscino commented on ARTEMIS-2520: -------------------------------------------- [~robbie] Thanks for your comments. I'm going to close the issue because I agree with you _*the spec basically doesn't explicitly define exactly what should occur*_ and changing the receive behavior could be a danger. > 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: Improvement > Reporter: Domenico Bruscino > Priority: Minor > > 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)