question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MQ Message not acknowledged on thrown exception

See original GitHub issue

Describe the bug I am using artemis mq as a message broker and have an incoming stream to listen for messages on a queue. In the method for the incoming stream, I have it possible to throw an exception. It seems that if an exception is thrown the mq broker is not notified that the message has been acknowledged by my service even though I have received and processed it. My service will no longer receive any messages sent to the queue and every time I restart my service, it receives that same bad message. If I change the method to just log the error, the queue works normally and is able to receive the bad message, log it, and continue receiving messages.

Expected behavior Throws exception but continues listening for future messages on that queue.

Actual behavior Throws exception and no longer receives messages on that queue.

To Reproduce Steps to reproduce the behavior:

  1. Start up mq broker
  2. Create method with incoming tag to receive messages on a queue
  3. Throw exception in method
  4. Send data that causes exception to be thrown
  5. Send data again

Configuration

# Add your application.properties here, if applicable.
mp.messaging.incoming.queue-name.connector=smallrye-amqp
mp.messaging.incoming.queue-name.durable=true

Environment (please complete the following information):

  • Output of uname -a or ver:
  • Output of java -version: 11.0.2
  • GraalVM version (if different from Java):
  • Quarkus version or git rev: 0.28.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
mislcommented, Dec 10, 2019

Hmm, apparently I was wrong. Modified mqtt-quickstart to look more like my code with a onErrorResumeWith and a PublisherBuilder. Replacing the process-method in PriceConverter with the following:

  public PublisherBuilder<MqttMessage<Double>> process( final MqttMessage<byte[]> priceMessage ) {
    return ReactiveStreams.of( priceMessage )
        .filter( Objects::nonNull )
        .map( message -> Integer.valueOf(new String(priceMessage.getPayload())) )
        .peek( price -> System.out.println("Receiving price: " + price) )
        .map( value -> value * CONVERSION_RATE)
        .map( value -> MqttMessage.of( value ))
        .onErrorResumeWith( e -> {
          System.out.println("Failed message: " + e.getMessage());
          return ReactiveStreams.empty();
        } )
        ;
  }

Running showed no issues. Sending incorrect messages did not disturb further processing of correct messages.

My failing server was actually using a ProcessorBuilder instead of a PublisherBuilder. So after changing it to PublisherBuilder it worked again as expected. I don’t know what exactly I did wrong in the original situation. So next I used a ProcessorBuilder for the quickstart as well. Replacing the process-method in PriceConverter with the following give the same faulty behaviour:

  public ProcessorBuilder<MqttMessage<byte[]>, MqttMessage<Double>> processor() {
    return ReactiveStreams.<MqttMessage<byte[]>>builder()
        .filter( Objects::nonNull )
        .map( message -> Integer.valueOf(new String(message.getPayload())) )
        .peek( price -> System.out.println("Receiving price: " + price) )
        .map( value -> value * CONVERSION_RATE)
        .map( value -> MqttMessage.of( value ))
        .onErrorResumeWith( e -> {
          System.out.println("Failed message: " + e.getMessage());
          return ReactiveStreams.empty();
        } )
        ;
  }
0reactions
cescoffiercommented, Jul 7, 2020

Fixed in 1.6 thanks to the reactive messaging update.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WMQ JMS Exception Messages - IBM
Error Code Message Explanation AMS1047 Alias not found in the keystore An alias is not found in the keystore. AMS1051 Failed to initialize the keystore...
Read more >
How Not Delete message from MQ by throwing Exception ...
When something wrong happens, I want to throw an exception and stop deleting the message from MQ. I want to use only AUTO_ACKNOWLEDGE...
Read more >
message.acknowledge method not working in case of exception
I am using JMS listener with spring boot and want to control message dequeing from queue only when the message been processed successfully....
Read more >
WMQ JMS Exception Messages - IBM
Error Code Message Explanation AMS1047 Alias not found in the keystore An alias is not found in the keystore. AMS1051 Failed to initialize the keystore...
Read more >
Sending Message in MQJMS transacted session, no exception
send() is not throwing any exception and exception is raised only when we did txn.commit. Raised exception is generic XA exception which is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found