Spring AMQP
  1. Spring AMQP
  2. AMQP-170

Message header value has type com.rabbitmq.client.impl.LongStringHelper.ByteArrayLongString

    Details

    • Type: Defect Defect
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Complete
    • Affects Version/s: 1.0.0.RC1
    • Fix Version/s: 1.0.0.RC2
    • Component/s: RabbitMQ
    • Labels:
      None

      Description

      The problem has happened using spring-integration-amqp.
      Trying to read a value from the header of a message I get that this value is of com.rabbitmq.client.impl.LongStringHelper.ByteArrayLongString type, when it was supposed to be String.

        Activity

        Hide
        Mark Fisher added a comment -

        The LongString enables large amounts of data (up to 4gb) to be passed and accessed as a DataInputStream.

        What I'm considering is modifying our RabbitUtils.createMessageProperties() method so that any header value of LongString type that has a length() value of less than N bytes will be converted to a plain ole java.lang.String (via calling the toString() method on that LongString instance... a ByteArrayLongString impl). The question is what N should be. I'm concerned that it will be an arbitrary decision, but I'm leaning toward something "reasonable" like 1024.

        Also, for values >= N, should we keep the value as a LongString or go ahead and grab the DataInputStream to add in our header map?

        Show
        Mark Fisher added a comment - The LongString enables large amounts of data (up to 4gb) to be passed and accessed as a DataInputStream. What I'm considering is modifying our RabbitUtils.createMessageProperties() method so that any header value of LongString type that has a length() value of less than N bytes will be converted to a plain ole java.lang.String (via calling the toString() method on that LongString instance... a ByteArrayLongString impl). The question is what N should be. I'm concerned that it will be an arbitrary decision, but I'm leaning toward something "reasonable" like 1024. Also, for values >= N, should we keep the value as a LongString or go ahead and grab the DataInputStream to add in our header map?
        Hide
        Mark Fisher added a comment -

        I implemented this by converting the LongString header values to a String if 1024 bytes or less and a DataInputStream otherwise.

        Show
        Mark Fisher added a comment - I implemented this by converting the LongString header values to a String if 1024 bytes or less and a DataInputStream otherwise.
        Hide
        Mark Fisher added a comment -

        In hindsight, 1024 bytes seems too small for the threshold. Even 1024*1024 (1 MB) might be better. Perhaps something in between... Thoughts?

        Show
        Mark Fisher added a comment - In hindsight, 1024 bytes seems too small for the threshold. Even 1024*1024 (1 MB) might be better. Perhaps something in between... Thoughts?
        Hide
        Marco Ziccardi added a comment -

        Isn't String dimension limited by the length value? Due to the fact I think it's saved as an integer we should have up to 2^32 - 1 unicode chars. Why are you looking for an upper bound to use DataInputStream? Are you worried about performances? In that case I think 1024*1024 would be ok, I can't imagine other "reasonable" values.
        Thank you Mark for your work

        Show
        Marco Ziccardi added a comment - Isn't String dimension limited by the length value? Due to the fact I think it's saved as an integer we should have up to 2^32 - 1 unicode chars. Why are you looking for an upper bound to use DataInputStream? Are you worried about performances? In that case I think 1024*1024 would be ok, I can't imagine other "reasonable" values. Thank you Mark for your work
        Hide
        Mark Fisher added a comment -

        The reason I'm using a threshold is to avoid loading very large Strings into memory (the values can be up to 4gb).

        Anything under the threshold will be a String, but above the threshold we'll add the DataInputStream as the value so that a consumer receiving that Message could decide when/how to stream the content.

        Show
        Mark Fisher added a comment - The reason I'm using a threshold is to avoid loading very large Strings into memory (the values can be up to 4gb). Anything under the threshold will be a String, but above the threshold we'll add the DataInputStream as the value so that a consumer receiving that Message could decide when/how to stream the content.
        Hide
        Dayanand added a comment -

        This issue still exist.
        it is occurring when i am trying to receive AMQP message through AMQP inbound-channel-adapter connected to http:outbound-gateway

        http:outbound-gateway throws following Error

        Caused by: java.lang.IllegalArgumentException: Expected MediaType or String value for 'Content-Type' header value, but received: class com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString
        at org.springframework.integration.http.support.DefaultHttpHeaderMapper.setHttpHeader(DefaultHttpHeaderMapper.java:571)

        analyzing the spring-integration-amqp code pointed the problem in org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper.toHeaders() method

        Show
        Dayanand added a comment - This issue still exist. it is occurring when i am trying to receive AMQP message through AMQP inbound-channel-adapter connected to http:outbound-gateway http:outbound-gateway throws following Error Caused by: java.lang.IllegalArgumentException: Expected MediaType or String value for 'Content-Type' header value, but received: class com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString at org.springframework.integration.http.support.DefaultHttpHeaderMapper.setHttpHeader(DefaultHttpHeaderMapper.java:571) analyzing the spring-integration-amqp code pointed the problem in org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper.toHeaders() method
        Hide
        Dave Syer added a comment - - edited

        Can you raise an issue with Spring Integration if the problem is there (this JIRA ticket seems unrelated)?

        Show
        Dave Syer added a comment - - edited Can you raise an issue with Spring Integration if the problem is there (this JIRA ticket seems unrelated)?
        Hide
        Dayanand added a comment -
        Show
        Dayanand added a comment - its already created... https://jira.springsource.org/browse/INT-2121

          People

          • Assignee:
            Mark Fisher
            Reporter:
            Marco Ziccardi
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: