質問

I have the following XML payload, which I'm trying to use for Spring Integration and Spring Integration AMQP:

<?xml version="1.0" encoding="UTF-8"?>
<order>
   <items>
      <item_name>Item1</item_name>
   </items>
   <items>
      <item_name>Item2</item_name>
   </items>
   <items>
      <item_name>Item3</item_name>
   </items>
</order>

I'm splitting the message by using a xpath-splitter:

<int-xml:xpath-splitter input-channel="amqpInboundChannel" output-channel="aggregateChannel">
    <int-xml:xpath-expression expression="//items"></int-xml:xpath-expression>
</int-xml:xpath-splitter>

I works fine and the message are being split into 3 new messages e.g. with this payload:

<?xml version="1.0" encoding="UTF-8"?>
<items>
   <item_name>Item1</item_name>
</items>

After this step the messages are being aggregated using this setup:

<int:aggregator input-channel="aggregateChannel" output-channel="channelSJ" message-store="messageStore">
</int:aggregator>

<bean id="messageStore" class="org.springframework.integration.store.SimpleMessageStore" />

As a final step the message is being sent to an exchange using this outbound-channel-adapter:

<amqp:outbound-channel-adapter channel="channelSJ" exchange-name="ex_store" routing-key="sj" amqp-template="rabbitTemplate" header-mapper="myHeaderMapper"/>

<int:channel id="channelSJ">
    <int:interceptors>
        <int:wire-tap channel="logger"/>
    </int:interceptors>      
</int:channel>

Unfortunately something goes wrong, because i end up with something like this payload. I need it to remain in XML format.

enter image description here

役に立ちましたか?

解決

You are sending a Collection of Strings the the AMQP adapter.

By default, that adapter can only handle String, byte[] and Serializable; in this case he will use Java serialization because the Collection is Serializable.

You have a couple of options...

  • use a JsonMessageConverter in the adapter's amqp-template and the collection will be rendered as JSON.
  • add a transformer between the aggregator and the adapter to transform the collection back to a single String.
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top