I started out using the si-xml:xpath-router but I ran into a roadblock. Am I using correct router but wrong implementation? If I'm using the incorrect router, which one should I be using, i.e. default router, payload-type, or maybe a simple SpEL expression?
Use Case:
I need to route a message based on payload content. The request contains an element and the 'action' I need to perform is contained in one if its attributes, see attribute "command" below.
Example inbound request (comes from a web-service).
<Request>
<Records>
<Record>
<data key="name" value="Jack Bauer" />
<data key="command" value="sendSMS" />
</Record>
</Records>
</Request>
The psuedocode was:
- marshall message.
- route based on value, via xpath-router
but I'm getting the error:
unsupported payload type [javax.xml.transform.dom.DOMResult]
In order to resolve this, I have tried:
adding the attribute "result-transformer" to the transformer bean using ResultToDocumentTransformer. error= failed to resolve channel name ''
adding attribute "result-type" to the transformer using StringResult. error = unsupported payload type [org.springframework.xml.transform.StringResult]
adding both of the above. error = failed to resolve channel name ''
adding the attribute "evaluate-as-string" using true. error = unsupported payload type.
Original Configuration file below:
<gateway id="gateway" default-request-channel="requestChannel"
service-interface="foo.SomeClass" />
<beans:bean id="marshaller"
class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<beans:property name="classesToBeBound">
<beans:list>
<beans:value>com.foo.Request</beans:value>
<beans:value>com.foo.Record</beans:value>
<beans:value>com.foo.Data</beans:value>
</beans:list>
</beans:property>
</beans:bean>
<chain input-channel="requestChannel">
<poller max-messages-per-poll="10" task-executor="executor">
<interval-trigger interval="5000" />
</poller>
<si-xml:marshalling-transformer marshaller="marshaller"/>
<si-xml:xpath-router id="instockRouter" resolution-required="true">
<si-xml:xpath-expression expression="/Request/Records/Record/data[@key='command']"/>
<si-xml:mapping value="sendSMS" channel="SMSChannel"/>
</si-xml:xpath-router>
</chain>
<task:executor id="executor" pool-size="8"/>