Announcement Announcement Module
Collapse
No announcement yet.
Setting ContentType from spring integration? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Setting ContentType from spring integration?

    Recently we've begun using spring integration for our AMQP related work and one annoyance I've been having is that when we use the spring-integration object-to-json converter the published message always has a contentType of text/plain.

    What is the right way to fix this? I tried using a header-enricher to add a contentType to the headers but it still doesn't give us the right contentType in the end.

    Thanks,
    James

  • #2
    James, I think you need to use the AmqpHeaders.CONTENT_TYPE header name in the header-enricher.

    We should probably consider supporting just "content-type" (without the amqp_ prefix) there as we do with HTTP.

    Comment


    • #3
      There is also an open JIRA here https://jira.springsource.org/browse/INT-2453 to have the transformer set it (with a boolean to disable).

      Comment


      • #4
        Thanks. It would make sense for me to have it just support content-type as everything leading up to the outbound gateway is generic with the outbound gateway being RabbitMQ, JMS or a REST service.

        Comment


        • #5
          I just tried the following

          Code:
          	<int:header-enricher input-channel="outboundMessageChannel" output-channel="amqpChannel">
          		<int:header name="amqp_contentType" value="application/json"></int:header>	
          	</int:header-enricher>
          However my AMQP messages still have a content_type of text/plain.

          Comment


          • #6
            Originally posted by jamescarr99 View Post
            I just tried the following

            Code:
            	<int:header-enricher input-channel="outboundMessageChannel" output-channel="amqpChannel">
            		<int:header name="amqp_contentType" value="application/json"></int:header>	
            	</int:header-enricher>
            However my AMQP messages still have a content_type of text/plain.
            FYI, it seems that the int-amqp:outbound-gateway ignores the header, while int-amqp:outbound-channel-adapter adds it to the message (which is what I was supposed to be looking at anyway.

            I'll make a test case for it and open a JIRA (if one doesn't already exist).

            Comment

            Working...
            X