javax.jms.MessageListener Java Examples

The following examples show how to use javax.jms.MessageListener. 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: NoDuplicateOnTopicNetworkTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
private void createConsumer() throws JMSException {
   if (durableSub) {
      consumer = session.createDurableSubscriber(topic, durableID);
   } else {
      consumer = session.createConsumer(topic);
   }
   consumer.setMessageListener(new MessageListener() {

      @Override
      public void onMessage(Message arg0) {
         TextMessage msg = (TextMessage) arg0;
         try {
            LOG.debug("Received message [" + msg.getText() + "]");
            receivedStrings.add(msg.getText());
            receivedLatch.countDown();
         } catch (JMSException e) {
            fail("Unexpected :" + e);
         }
      }

   });
}
 
Example #2
Source File: TopicDurableTests.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected List<CompletableFuture<List<Message>>> receiveMessagesAsync(int count, MessageConsumer... consumer) throws JMSException {
   AtomicInteger totalCount = new AtomicInteger(count);
   List<CompletableFuture<List<Message>>> resultsList = new ArrayList<>();
   List<List<Message>> receivedResList = new ArrayList<>();

   for (int i = 0; i < consumer.length; i++) {
      final int index = i;
      resultsList.add(new CompletableFuture<>());
      receivedResList.add(new ArrayList<>());
      MessageListener myListener = message -> {
         instanceLog.debug("Mesages received" + message + " count: " + totalCount.get());
         receivedResList.get(index).add(message);
         if (totalCount.decrementAndGet() == 0) {
            for (int j = 0; j < consumer.length; j++) {
               resultsList.get(j).complete(receivedResList.get(j));
            }
         }
      };
      consumer[i].setMessageListener(myListener);
   }
   return resultsList;
}
 
Example #3
Source File: IncomingTopic.java    From reladomo with Apache License 2.0 6 votes vote down vote up
@Override
protected void start() throws JMSException, NamingException
{
    super.start();
    this.xaConsumer = this.getXaSession().createDurableSubscriber(this.getXaTopic(), this.getConfig().getDurableConsumerName());
    if (this.getInterruptableBackoff() != null && this.getNonXaSession() != null)
    {
        this.nonXaConsumer = this.getNonXaSession().createConsumer(this.getNonXaTopic());
        this.nonXaConsumer.setMessageListener(new MessageListener()
        {
            @Override
            public void onMessage(Message message)
            {
                IncomingTopic.this.getInterruptableBackoff().asyncInterrupt();
            }
        });
    }
}
 
Example #4
Source File: MessageListenerContainer.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
public void start() {
    try {
        session = connection.createSession(transacted, acknowledgeMode);
        if (durableSubscriptionName != null && destination instanceof Topic) {
            consumer = session.createDurableSubscriber((Topic)destination, durableSubscriptionName,
                                                       messageSelector, pubSubNoLocal);
        } else {
            consumer = session.createConsumer(destination, messageSelector);
        }

        MessageListener intListener = new LocalTransactionalMessageListener(session, listenerHandler);
        // new DispachingListener(getExecutor(), listenerHandler);
        consumer.setMessageListener(intListener);

        running = true;
    } catch (JMSException e) {
        throw JMSUtil.convertJmsException(e);
    }
}
 
Example #5
Source File: JmsListenerContainerFactoryTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void createSimpleContainer() {
	SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory();
	setDefaultJmsConfig(factory);
	SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();

	MessageListener messageListener = new MessageListenerAdapter();
	endpoint.setMessageListener(messageListener);
	endpoint.setDestination("myQueue");

	SimpleMessageListenerContainer container = factory.createListenerContainer(endpoint);

	assertDefaultJmsConfig(container);
	assertEquals(messageListener, container.getMessageListener());
	assertEquals("myQueue", container.getDestinationName());
}
 
Example #6
Source File: JmsListenerContainerFactoryTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void createJmsContainerFullConfig() {
	DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
	setDefaultJmsConfig(factory);
	factory.setCacheLevel(DefaultMessageListenerContainer.CACHE_CONSUMER);
	factory.setConcurrency("3-10");
	factory.setMaxMessagesPerTask(5);

	SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
	MessageListener messageListener = new MessageListenerAdapter();
	endpoint.setMessageListener(messageListener);
	endpoint.setDestination("myQueue");
	DefaultMessageListenerContainer container = factory.createListenerContainer(endpoint);

	assertDefaultJmsConfig(container);
	assertEquals(DefaultMessageListenerContainer.CACHE_CONSUMER, container.getCacheLevel());
	assertEquals(3, container.getConcurrentConsumers());
	assertEquals(10, container.getMaxConcurrentConsumers());
	assertEquals(5, container.getMaxMessagesPerTask());

	assertEquals(messageListener, container.getMessageListener());
	assertEquals("myQueue", container.getDestinationName());
}
 
Example #7
Source File: JmsConsumerTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testCantReceiveWhenListenerIsSet() throws Exception {
   conn = cf.createConnection();
   Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
   jBossQueue = ActiveMQJMSClient.createQueue(JmsConsumerTest.Q_NAME);
   MessageConsumer consumer = session.createConsumer(jBossQueue);
   consumer.setMessageListener(new MessageListener() {
      @Override
      public void onMessage(final Message msg) {
      }
   });

   try {
      consumer.receiveNoWait();
      Assert.fail("Should throw exception");
   } catch (JMSException e) {
      // Ok
   }
}
 
Example #8
Source File: MessageListenerTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testConnectionProblem() throws JMSException {
    Connection connection = createConnection("broker");
    Queue dest = JMSUtil.createQueue(connection, "test");

    MessageListener listenerHandler = new TestMessageListener();
    TestExceptionListener exListener = new TestExceptionListener();

    PollingMessageListenerContainer container = //
        new PollingMessageListenerContainer(connection, dest, listenerHandler, exListener);
    connection.close(); // Simulate connection problem
    container.start();
    Awaitility.await().until(() -> exListener.exception != null);
    JMSException ex = exListener.exception;
    assertNotNull(ex);
    assertEquals("The connection is already closed", ex.getMessage());
}
 
Example #9
Source File: AppInfoBuilderTest.java    From tomee with Apache License 2.0 6 votes vote down vote up
public void testShouldCreateContainer() throws Exception {
    final EjbJar ejbJar = new EjbJar();
    final OpenejbJar openejbJar = new OpenejbJar();

    final EjbModule ejbModule = new EjbModule(ejbJar, openejbJar);

    final AppModule appModule = new AppModule(ejbModule);
    appModule.getContainers().add(new Container("my-container", "MESSAGE", null));

    final AppInfo appInfo = new AppInfoBuilder(new ConfigurationFactory()).build(appModule);
    assertEquals(1, appInfo.containers.size());
    final ContainerInfo containerInfo = appInfo.containers.get(0);
    assertEquals(appInfo.appId + "/my-container", containerInfo.id);
    assertEquals(1, containerInfo.types.size());
    assertEquals("MESSAGE", containerInfo.types.get(0));
    assertEquals(MdbContainerFactory.class.getName(), containerInfo.className);
    assertEquals("Default JMS Resource Adapter", containerInfo.properties.get("ResourceAdapter"));
    assertEquals(MessageListener.class.getName(), containerInfo.properties.get("MessageListenerInterface"));
    assertEquals(TomEEMessageActivationSpec.class.getName(), containerInfo.properties.get("ActivationSpecClass"));
    assertEquals("10", containerInfo.properties.get("InstanceLimit"));
    assertEquals("true", containerInfo.properties.get("FailOnUnknownActivationSpec"));
}
 
Example #10
Source File: AbstractMessageListenerContainer.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Invoke the specified listener: either as standard JMS MessageListener
 * or (preferably) as Spring SessionAwareMessageListener.
 * @param session the JMS Session to operate on
 * @param message the received JMS Message
 * @throws JMSException if thrown by JMS API methods
 * @see #setMessageListener
 */
@SuppressWarnings("rawtypes")
protected void invokeListener(Session session, Message message) throws JMSException {
	Object listener = getMessageListener();

	if (listener instanceof SessionAwareMessageListener) {
		doInvokeListener((SessionAwareMessageListener) listener, session, message);
	}
	else if (listener instanceof MessageListener) {
		doInvokeListener((MessageListener) listener, message);
	}
	else if (listener != null) {
		throw new IllegalArgumentException(
				"Only MessageListener and SessionAwareMessageListener supported: " + listener);
	}
	else {
		throw new IllegalStateException("No message listener specified - see property 'messageListener'");
	}
}
 
Example #11
Source File: SQSSessionCallbackSchedulerTest.java    From amazon-sqs-java-messaging-lib with Apache License 2.0 6 votes vote down vote up
/**
 * Test schedule callback
 */
@Test
public void testScheduleCallBack() throws JMSException, InterruptedException {

    /*
     * Set up mocks
     */
    sqsSessionRunnable.callbackQueue = new ArrayDeque<SQSSession.CallbackEntry>();

    MessageListener msgListener = mock(MessageListener.class);
    SQSMessageConsumerPrefetch.MessageManager msgManager = mock(SQSMessageConsumerPrefetch.MessageManager.class);
    /*
     * Nack the messages, exception expected
     */
    sqsSessionRunnable.scheduleCallBacks(msgListener, Collections.singletonList(msgManager));

    assertEquals(1, sqsSessionRunnable.callbackQueue.size());

    SQSSession.CallbackEntry entry = sqsSessionRunnable.callbackQueue.pollFirst();

    assertEquals(msgListener, entry.getMessageListener());
    assertEquals(msgManager, entry.getMessageManager());
}
 
Example #12
Source File: ActiveMqFacade.java    From apm-agent-java with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<Message> registerConcreteListenerImplementation(Destination destination) {
    final CompletableFuture<Message> incomingMessageFuture = new CompletableFuture<>();
    try {
        MessageConsumer consumer = session.createConsumer(destination);
        //noinspection Convert2Lambda,Anonymous2MethodRef
        consumer.setMessageListener(new MessageListener() {
            @Override
            public void onMessage(Message message) {
                incomingMessageFuture.complete(message);
            }
        });
    } catch (JMSException e) {
        throw new RuntimeException(e);
    }
    return incomingMessageFuture;
}
 
Example #13
Source File: ReceiveShipping.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
   ConnectionFactory factory = new ActiveMQJMSConnectionFactory("tcp://localhost:61616");
   Destination destination = ActiveMQDestination.fromPrefixedName("queue://shipping");

   try (Connection conn = factory.createConnection()) {
      Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
      MessageConsumer consumer = session.createConsumer(destination);
      consumer.setMessageListener(new MessageListener() {
         @Override
         public void onMessage(Message message) {
            System.out.println("Received Message: ");
            Order order = Jms.getEntity(message, Order.class);
            System.out.println(order);
         }
      });
      conn.start();
      Thread.sleep(1000000);
   }
}
 
Example #14
Source File: CompositePublishTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
protected MessageListener createMessageListener(int i, final List<Message> messageList) {
   return new MessageListener() {
      @Override
      public void onMessage(Message message) {
         consumeMessage(message, messageList);
      }
   };
}
 
Example #15
Source File: JmsMessageEndpointManager.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void setupMessageListener(Object messageListener) {
	if (messageListener instanceof MessageListener) {
		setMessageListener((MessageListener) messageListener);
	}
	else {
		throw new IllegalArgumentException("Unsupported message listener '" +
				messageListener.getClass().getName() + "': only '" + MessageListener.class.getName() +
				"' type is supported");
	}
}
 
Example #16
Source File: SQSMessageConsumerPrefetchTest.java    From amazon-sqs-java-messaging-lib with Apache License 2.0 5 votes vote down vote up
/**
 * Test SetMessageListener when message were prefetched
 */
@Test
public void testSetMessageListener() {

    SQSMessageConsumerPrefetch.MessageManager msgManager1 = mock(SQSMessageConsumerPrefetch.MessageManager.class);
    Message message1 = mock(Message.class);
    when(msgManager1.getMessage())
            .thenReturn(message1);

    SQSMessageConsumerPrefetch.MessageManager msgManager2 = mock(SQSMessageConsumerPrefetch.MessageManager.class);
    Message message2 = mock(Message.class);
    when(msgManager2.getMessage())
            .thenReturn(message2);

    consumerPrefetch.messageQueue.add(msgManager1);
    consumerPrefetch.messageQueue.add(msgManager2);

    MessageListener msgListener = mock(MessageListener.class);
    consumerPrefetch.running = true;
    consumerPrefetch.setMessageListener(msgListener);
          
    assertTrue(consumerPrefetch.messageQueue.isEmpty());

    List<MessageManager> expectedList = new ArrayList<MessageManager>();
    expectedList.add(msgManager1);
    expectedList.add(msgManager2);
    verify(sqsSessionRunnable).scheduleCallBacks(msgListener, expectedList);

    verifyNoMoreInteractions(sqsSessionRunnable);
}
 
Example #17
Source File: SQSMessageConsumerPrefetchTest.java    From amazon-sqs-java-messaging-lib with Apache License 2.0 5 votes vote down vote up
/**
 * Test getting message listener
 */
@Test
public void testGetMessageListener() {

    MessageListener msgListener = mock(MessageListener.class);
    consumerPrefetch.setMessageListener(msgListener);

    assertEquals(msgListener, consumerPrefetch.getMessageListener());
}
 
Example #18
Source File: AmqpClientActorTest.java    From ditto with Eclipse Public License 2.0 5 votes vote down vote up
private void testConsumeMessageAndExpectForwardToConciergeForwarderAndReceiveResponse(final Connection connection,
        final BiFunction<ThingId, DittoHeaders, CommandResponse> responseSupplier,
        final String expectedAddressPrefix,
        final Predicate<String> messageTextPredicate) throws JMSException {

    new TestKit(actorSystem) {{
        final Props props =
                AmqpClientActor.propsForTests(connection, getRef(), getRef(),
                        (ac, el) -> mockConnection);
        final ActorRef amqpClientActor = actorSystem.actorOf(props);

        amqpClientActor.tell(OpenConnection.of(CONNECTION_ID, DittoHeaders.empty()), getRef());
        expectMsg(CONNECTED_SUCCESS);

        final ArgumentCaptor<MessageListener> captor = ArgumentCaptor.forClass(MessageListener.class);
        verify(mockConsumer, timeout(1000).atLeastOnce()).setMessageListener(captor.capture());
        final MessageListener messageListener = captor.getValue();
        messageListener.onMessage(mockMessage());

        final ThingCommand command = expectMsgClass(ThingCommand.class);
        assertThat((CharSequence) command.getEntityId()).isEqualTo(TestConstants.Things.THING_ID);
        assertThat(command.getDittoHeaders().getCorrelationId()).contains(TestConstants.CORRELATION_ID);
        assertThat(command).isInstanceOf(ModifyThing.class);

        getLastSender().tell(responseSupplier.apply(command.getEntityId(), command.getDittoHeaders()), getRef());

        final ArgumentCaptor<JmsMessage> messageCaptor = ArgumentCaptor.forClass(JmsMessage.class);
        // verify that the message is published via the producer with the correct destination
        final MessageProducer messageProducer =
                getProducerForAddress(expectedAddressPrefix + command.getEntityId());
        verify(messageProducer, timeout(2000)).send(messageCaptor.capture(), any(CompletionListener.class));

        final Message message = messageCaptor.getValue();
        assertThat(message).isNotNull();
        assertThat(messageTextPredicate).accepts(message.getBody(String.class));
    }};
}
 
Example #19
Source File: ActiveMQRASession.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
/**
 * Get the message listener -- throws IllegalStateException
 *
 * @return The message listener
 * @throws JMSException Thrown if an error occurs
 */
@Override
public MessageListener getMessageListener() throws JMSException {
   if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
      ActiveMQRALogger.LOGGER.trace("getMessageListener()");
   }

   throw new IllegalStateException("Method not allowed");
}
 
Example #20
Source File: JmsListenerEndpointTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void setupConcurrencySimpleContainer() {
	SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
	MessageListener messageListener = new MessageListenerAdapter();
	SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
	endpoint.setConcurrency("5-10"); // simple implementation only support max value
	endpoint.setMessageListener(messageListener);

	endpoint.setupListenerContainer(container);
	assertEquals(10, new DirectFieldAccessor(container).getPropertyValue("concurrentConsumers"));
}
 
Example #21
Source File: PreservesMessagePropertiesMessageConsumerAdapterTest.java    From spring-cloud-ribbon-extensions with Apache License 2.0 5 votes vote down vote up
@Test
public void receive() throws Exception {
    when(delegate.getMessageListener()).thenReturn(mock(PreservesMessagePropertiesMessageListener.class));
    propagator.receive();
    verify(delegate).receive();
    reset(delegate);
    when(delegate.getMessageListener()).thenReturn(mock(MessageListener.class));
    propagator.receive();
    verify(delegate).receive();
}
 
Example #22
Source File: DurableSubscriptionUnsubscribeTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private void createAdvisorySubscription() throws Exception {
   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   MessageConsumer advisoryConsumer = session.createConsumer(AdvisorySupport.getConsumerAdvisoryTopic(topic));
   advisoryConsumer.setMessageListener(new MessageListener() {
      @Override
      public void onMessage(Message message) {
         if (((ActiveMQMessage) message).getDataStructure() instanceof RemoveSubscriptionInfo) {
            advisories.incrementAndGet();
         }
      }
   });
}
 
Example #23
Source File: ClientJmsDelegate.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
public void registerListener(String consumerName, MessageListener messageListener)
{
    MessageConsumer consumer = _testConsumers.get(consumerName);
    try
    {
        consumer.setMessageListener(messageListener);
    }
    catch (JMSException e)
    {
        throw new DistributedTestException("Unable to register message listener with consumer: " + consumerName, e);
    }
}
 
Example #24
Source File: JmsMessageProducerInstrumentation.java    From apm-agent-java with Apache License 2.0 5 votes vote down vote up
@Advice.OnMethodEnter(suppress = Throwable.class)
@Nullable
public static Span startSpan(@Advice.Argument(0) final Destination destination,
                             @Advice.Argument(1) final Message message) {
    //noinspection ConstantConditions - the Advice must be invoked only if the BaseJmsInstrumentation constructor was invoked
    JmsInstrumentationHelper<Destination, Message, MessageListener> helper =
        jmsInstrHelperManager.getForClassLoaderOfClass(MessageProducer.class);
    if (helper != null) {
        return helper.startJmsSendSpan(destination, message);
    }
    return null;
}
 
Example #25
Source File: JmsClientAckTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 60000)
public void testAckedMessageAreConsumedByAsync() throws Exception {
    connection = createAmqpConnection();
    connection.start();
    Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
    Queue queue = session.createQueue(name.getMethodName());
    MessageProducer producer = session.createProducer(queue);
    producer.send(session.createTextMessage("Hello"));

    final QueueViewMBean proxy = getProxyToQueue(name.getMethodName());
    assertEquals(1, proxy.getQueueSize());

    // Consume the message...
    MessageConsumer consumer = session.createConsumer(queue);
    consumer.setMessageListener(new MessageListener() {

        @Override
        public void onMessage(Message message) {
            try {
                message.acknowledge();
            } catch (JMSException e) {
                LOG.warn("Unexpected exception on acknowledge: {}", e.getMessage());
            }
        }
    });

    assertTrue("Queued message not consumed.", Wait.waitFor(new Wait.Condition() {

        @Override
        public boolean isSatisfied() throws Exception {
            return proxy.getQueueSize() == 0;
        }
    }));
}
 
Example #26
Source File: JmsInstrumentationHelperImpl.java    From apm-agent-java with Apache License 2.0 5 votes vote down vote up
@VisibleForAdvice
@Override
@Nullable
public MessageListener wrapLambda(@Nullable MessageListener listener) {
    // the name check also prevents from wrapping twice
    if (listener != null && listener.getClass().getName().contains("/")) {
        return new MessageListenerWrapper(listener);
    }
    return listener;
}
 
Example #27
Source File: JMSConsumerTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
public void testMessageListenerWithConsumer() throws Exception {

      final AtomicInteger counter = new AtomicInteger(0);
      final CountDownLatch done = new CountDownLatch(1);

      // Receive a message with the JMS API
      connection.start();
      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      destination = createDestination(session, destinationType);
      MessageConsumer consumer = session.createConsumer(destination);
      consumer.setMessageListener(new MessageListener() {
         @Override
         public void onMessage(Message m) {
            counter.incrementAndGet();
            if (counter.get() == 4) {
               done.countDown();
            }
         }
      });

      // Send the messages
      sendMessages(session, destination, 4);

      assertTrue(done.await(1000, TimeUnit.MILLISECONDS));
      Thread.sleep(200);

      // Make sure only 4 messages were delivered.
      assertEquals(4, counter.get());
   }
 
Example #28
Source File: JmsSendWithAsyncCallbackTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
public void testAsyncCallbackIsFaster() throws JMSException, InterruptedException {
   connection.start();

   Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   Queue queue = session.createQueue(getName());

   // setup a consumer to drain messages..
   MessageConsumer consumer = session.createConsumer(queue);
   consumer.setMessageListener(new MessageListener() {
      @Override
      public void onMessage(Message message) {
      }
   });

   // warmup...
   for (int i = 0; i < 10; i++) {
      benchmarkNonCallbackRate();
      benchmarkCallbackRate();
   }

   double callbackRate = benchmarkCallbackRate();
   double nonCallbackRate = benchmarkNonCallbackRate();

   LOG.info(String.format("AsyncCallback Send rate: %,.2f m/s", callbackRate));
   LOG.info(String.format("NonAsyncCallback Send rate: %,.2f m/s", nonCallbackRate));

   // The async style HAS to be faster than the non-async style..
   assertTrue("async rate[" + callbackRate + "] should beat non-async rate[" + nonCallbackRate + "]", callbackRate / nonCallbackRate > 1.5);
}
 
Example #29
Source File: JmsPoolJMSConsumer.java    From pooled-jms with Apache License 2.0 5 votes vote down vote up
@Override
public MessageListener getMessageListener() {
    try {
        return consumer.getMessageListener();
    } catch (JMSException e) {
        throw JMSExceptionSupport.createRuntimeException(e);
    }
}
 
Example #30
Source File: ConsumerIntegrationTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
/**
 * Test that an Ack is not dropped when RTE is thrown from onMessage
 *
 * @throws Exception if an error occurs during the test.
 */
@Test(timeout = 20000)
public void testRuntimeExceptionInOnMessageReleasesInAutoAckMode() throws Exception {
    try (TestAmqpPeer testPeer = new TestAmqpPeer();) {
        Connection connection = testFixture.establishConnecton(testPeer);
        connection.start();

        testPeer.expectBegin();

        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Queue queue = session.createQueue("myQueue");

        DescribedType amqpValueNullContent = new AmqpValueDescribedType(null);

        testPeer.expectReceiverAttach();
        testPeer.expectLinkFlowRespondWithTransfer(null, null, null, null, amqpValueNullContent);
        testPeer.expectDispositionThatIsReleasedAndSettled();

        MessageConsumer messageConsumer = session.createConsumer(queue);
        messageConsumer.setMessageListener(new MessageListener() {

            @Override
            public void onMessage(Message message) {
                throw new RuntimeException();
            }
        });

        testPeer.waitForAllHandlersToComplete(2000);

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

        testPeer.waitForAllHandlersToComplete(2000);
    }
}