diff --git a/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java b/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java index 19eed540bc..bef351cee5 100755 --- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java +++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageConsumer.java @@ -666,7 +666,7 @@ public class ActiveMQMessageConsumer implements MessageAvailableConsumer, StatsC @Override public void close() throws JMSException { if (!unconsumedMessages.isClosed()) { - if (session.getTransactionContext().isInTransaction()) { + if (!deliveredMessages.isEmpty() && session.getTransactionContext().isInTransaction()) { session.getTransactionContext().addSynchronization(new Synchronization() { @Override public void afterCommit() throws Exception { diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4472Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4472Test.java index 59acc54b20..42c391c85d 100644 --- a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4472Test.java +++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ4472Test.java @@ -40,7 +40,7 @@ public class AMQ4472Test { public void testLostMessage() { Connection connection = null; try { - ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.useJmx=false&jms.prefetchPolicy.all=0"); + ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.useJmx=false"); connection = connectionFactory.createConnection(); connection.start();