Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-9560

RabbitMQ InOut Producer generates a null body response when a correlationId is used

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.16.2
    • 2.16.3, 2.17.0
    • camel-rabbitmq
    • None
    • Novice

    Description

      The use case uses a correlationId with RabbitMQ InOut Producer :

      from("direct:route")
         .setHeader(RabbitMQConstants.EXCHANGE_NAME, constant("exchange"))
         .setHeader(RabbitMQConstants.CORRELATIONID, constant("123"))
         .inOut("rabbitmq://...")
      

      The response always contains a null out body message.

      The problem is located when restoring the original correlation id in org.apache.camel.component.rabbitmq.reply.ReplyManagerSupport :

      public void processReply(ReplyHolder holder)
      
      // restore correlation id in case the remote server messed with it
      if (holder.getOriginalCorrelationId() != null) {
         if (exchange.getOut() != null) {
            exchange.getOut().setHeader(RabbitMQConstants.CORRELATIONID, 
               holder.getOriginalCorrelationId());
         } else {
            exchange.getIn().setHeader(RabbitMQConstants.CORRELATIONID, 
               holder.getOriginalCorrelationId());
         }
      }
      

      The test exchange.getOut() is always successful because of the lazy creation in DefaultExchange.getOut

      public Message getOut() {
         // lazy create
         if (out == null) {
            out = (in != null && in instanceof MessageSupport)
            ? ((MessageSupport)in).newInstance() : new DefaultMessage();
            configureMessage(out);
         }
         return out;
      }
      

      The in body message contains the correct response from RabbitMQ. However, since the out message will be always created with a null body, the null body response will be returned in the pipeline

      Attachments

        1. camel_9560.patch
          1 kB
          Onur Akdemir

        Activity

          People

            davsclaus Claus Ibsen
            arnaudchotard Arnaud CHOTARD
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: