Bumped into message rejection. How to diagnose a reason ?

313 views
Skip to first unread message

Vladimir Nayfeld

unread,
May 4, 2020, 7:24:07 PM5/4/20
to rabbitmq-users
Hello, I am a new for a RabbitMq and bumped into a problem.

I want to publish a message to MQ constructed form an Object defined from a class:
  • public class DataEvent {
    private String eventType;
    private String values;
}

String eventType - I use it to carry a "Routing key".
String values - is presented by a JSON and is used for the Body of the message.

  • A Queue is Bound as:

FromRouting keyArguments
(Default exchange binding)
documentEventExchangefinancial.billing

Hence DataEvent.getEventType="financial.billing".


  • A payload (Body) should be Deserialized for Subscriber in the Class:
class DocumentReadyEvent {
    private String transactionId;
    private List<String> uris;
}
  • Hence, I am trying to produce a "String values" in the JSON format as
{
  "transactionId": "string",
  "uris": [
    "string"
  ]
}

  • Subscriber configured as : 
 @RabbitListener(
        autoStartup = "true",
        bindings = {
            @QueueBinding(
                value = @Queue(
                    value = "${billing.queueName}",
                    autoDelete = "false",
                    durable = "true",
                    arguments = {
                        @Argument(name = "x-dead-letter-exchange"),
                        @Argument(name = "x-dead-letter-routing-key", value = "${billing.dlq.queueName}")
                    }
                ),
                exchange = @Exchange(
                    value = "${exchange.name}",
                    type = ExchangeTypes.TOPIC
                ),
                key = "${billing.exchangeKey}"
            )
        }) 
  •  This is an Example of the "message" I send:
Body - a Json String.. I expect that RabbitMQ will Serialize it 
Body:'"{\"transactionId\":\"e4a6415d-a4d9-4b0d-94cc-7e609ac9fe80\", \"uris\":[\"/POLICY/1.xml\",\"/POLICY/2.xml\"]}"'

          I expect that RabbitMQ desereialize it for Subscriber and Subscriber will have an Object:
                
class DocumentReadyEvent {
    private String transactionId = "e4a6415d-a4d9-4b0d-94cc-7e609ac9fe80";
    private List<String> uris = ArrayList <String> ("/POLICY/1.xml", "/POLICY/2.xml")
}
       
  • However, all my Publish attempts  result in  message being "rejected" .  
       All messages rerouted to a "billingDocumentDlqQueue " , which is clear to me b/c it is configured as  @Argument(name = "x-dead-letter-routing-key", value = "${billing.dlq.queueName}") 

  • Biggest question for me is How to find a reason for Message to be "rejected"? 
My guess is, that somewhere an "MQ" log produces a detailed Message for rejection or
perhaps an Exception stacktrace.   Can I find such log file somewhere?  I am running a RabbitMQ on my local machine.

  • This is an example of.message I am sending to RabbitMQ.

(
Body:'"{\"transactionId\":\"e4a6415d-a4d9-4b0d-94cc-7e609ac9fe80\", \"uris\":[\"/POLICY/OW-PAS/1010057/274558.xml\",\"/POLICY/OW-PAS/1010057/274558.xml\"]}"'

MessageProperties 
[
headers={__TypeId__=java.lang.String}, 
contentType=application/json,
  contentEncoding=UTF-8,
   contentLength=150,
    deliveryMode=PERSISTENT,
     priority=0,
      deliveryTag=0
  ]
  )

Exchange (AMQP default)
Routing Key billingDocumentDlqQueue
Redelivered
Properties
priority: 0
delivery_mode: 2
headers:
__TypeId__: java.lang.String
x-death:
count: 1
exchange: documentEventExchange
queue: billingDocumentEventQueue
reason: rejected
routing-keys: financial.billing
time: 1588630174
x-first-death-exchange: documentEventExchange
x-first-death-queue: billingDocumentEventQueue
x-first-death-reason: rejected
content_encoding: UTF-8
content_type: application/json
Payload
150 bytes
Encoding: string
"{\"transactionId\":\"e4a6415d-a4d9-4b0d-94cc-7e609ac9fe80\", \"uris\":[\"/POLICY/OW-PAS/1010057/274558.xml\",\"/POLICY/OW-PAS/1010057/274558.xml\"]}"


I'll very appreciate any suggestions.

              Vladimir Nayfeld

              unread,
              May 6, 2020, 12:23:28 PM5/6/20
              to rabbitmq-users
              I found solution.
              This is not a problem anymore.
              Thank you!.

              Gabriel Maqueda

              unread,
              Jan 19, 2022, 4:17:52 AM1/19/22
              to rabbitmq-users

              Hi Vladimir!

              I think we are having the same problem as you.

              We would like to set a reason into a deadlettered message using the x-first-death-reason header, but we are not able to do it.... so, would you explain us how do you solved this problem?

              Thanks a lot!
              Reply all
              Reply to author
              Forward
              0 new messages