Uploaded image for project: 'Spring Integration'
  1. Spring Integration
  2. INT-3535

JsonType of request overrides response type when using JMS inbound gateway in combination with json converters (jackson2)

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Complete
    • 4.0.4
    • 4.1 RC1
    • JMS Support
    • Windows

    Description

      I believe that the issue described in INT-3285 still exists for JMS based gateways.
      I have a unit test where i post a request message of type java.lang.String and expect another type in the reply.
      The headers with the type from the request are copied over the header value that is provided by the json messageconverter.

      The problem is located in the function

      org.springframework.integration.jms.DefaultJmsHeaderMapper.fromHeaders(MessageHeaders headers, javax.jms.Message jmsMessage)

      The workaround i used is to add "jms_" to the value of typeIdPropertyName. I saw in the code that these headers are not copied. It worked for now.

      		<bean id="jsonMessageConverter"
      			class="org.springframework.jms.support.converter.MappingJackson2MessageConverter">
      			<property name="targetType" value="TEXT" />
      			<property name="typeIdPropertyName" value="jms_javatype" />
      		</bean>
      

      Some example code:

      Command.java
      @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "jms_javatype")
      @Component
      public class Command {
      	@JsonProperty("id")
      	public String id;
      	@JsonProperty("amount")
      	public Integer	  amount;
      	
      	public Command(String id, int amount) {
      		this.id = id;
      		this.amount = amount;
      	}
      
      	public Command() {
      	}
      }
      

      Attachments

        Activity

          People

            abilan Artem Bilan
            Joost van Weenen Joost van Weenen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: