I need to build the Router logic for my msg pipe. Diff chanell will use diff XSD to Transform XML data to txt format.if you have any examples,please let me know.
Thank you
I need to build the Router logic for my msg pipe. Diff chanell will use diff XSD to Transform XML data to txt format.if you have any examples,please let me know.
Thank you
which is it that you are looking for Routing or Transformation?
Oleg Zhurakousky
Spring Integration team
http://twitter.com/z_oleg
http://blog.springsource.com/author/ozhurakousky/
I'm looking for a custom router logic.My msg's are in XML format.
I need to build the router logic to output message to different channel.Each channel will use XSD file for XML parser(jaxb),so I can get access to msg data in transformer.
For example: if Mesage Name is "ABC" --->channel is "XYZ" and XSD file for this chanell to pars xml will be "YYY" .
Thank you vm for your help....
What do you mean channels with XSD? Channels only receive and dispatch (not process) messages? Look at them as connectors between endpoints.
As for the routers there ar numerous routing techniques currently available within Spring Integration which means there is more then one way to do the same operation (routing in your case), so when you say "Massage Name ABC" - what is ABC? payload? header name/value? something inside the payload?
Please be more descriptive as to what are you trying to accomplish
Oleg Zhurakousky
Spring Integration team
http://twitter.com/z_oleg
http://blog.springsource.com/author/ozhurakousky/
Very sorry if I'm not clear,plus I'm new to Integration:
I'm doing the fillowing steps in my process.
1.I'm spolling the directory to get incoming msg as XML file.
2.I push msg to the channel
3.I transform the xml msg to text(Swift) format msg.
4.Log msg to DB table
6.Send msg to MQ.
Now for step #3 I use the XML schema file(.xsd) to parce the XML msg and get Mesage data value in Transformer.When it parce(jaxb) the new java class is created to get data value.
Issue with XML schema:
I can not parce the XML msg with the same schema.I have 3 different Message format. Based on msg type(payload) ,Message needs to be parce with different schema.
I think I need to implement the Router to output msg to different channel for parcing and use different transformer for each channel.
Thank you for help...
Last edited by mikespring69; Jun 25th, 2010 at 02:03 PM.
Since you said you need to route it based on payload type all you need is PayloadTypeRouter which will route incoming message to different channels based on the payload type of the incoming message and could be easily configured as such:
Code:<si:payload-type-router input-channel="some-channel"> <si:mapping type="java.lang.String" channel="chanel-for-strings"/> <si:mapping type="org.foo.Bar" channel="chanel-for-bars"/> </si:payload-type-router> <si:transformer input-channel="chanel-for-strings" ...> . . . . </si:transformer> <si:transformer input-channel="chanel-for-bars" ...> . . . . </si:transformer>
Oleg Zhurakousky
Spring Integration team
http://twitter.com/z_oleg
http://blog.springsource.com/author/ozhurakousky/
The Payload will represent my xml msg,can I get the field value inside of my PayloadRouter? -For example ,I have xml file with field:
<MessageType>Transfer</MessageType>
if MessageType="Transfer" then channel="abc"
Yes you can. Look at XPath router samples here:
https://src.springsource.org/svn/spr...on/xml/router/
Oleg Zhurakousky
Spring Integration team
http://twitter.com/z_oleg
http://blog.springsource.com/author/ozhurakousky/
Oleg, Thank you for help!!!
Please help, I stuck here, What should be the syntax to get channel value from my customRouterBean SwiftMainRouter.java
<beans:bean id="customRouterBean"
class="com.util.SwiftMainRouter">
???????????
</beans:bean>
public class SwiftMainRouter extends AbstractMessageRouter {
ChannelResolver channelResolver;
MessageChannel channel =null;
@Override
protected Collection<MessageChannel> determineTargetChannels(
Message<?> message) {
// TODO Auto-generated method stub
System.out.println("Hello from Custom Router");
if (message == null)
{
throw new MessagingException("SwiftMainRouter.java-Expected message but is null");
}
String channelName="";
String msg = message.getPayload().toString();
Collection<MessageChannel> channels = new ArrayList<MessageChannel>();
if(!msg.equalsIgnoreCase("A"))
{
channelName = "inboundAdapter";
}
channel = channelResolver.resolveChannelName(channelName);
if (channel==null)
{
throw new MessagingException(message, "failed to resolve channel name '" + channelName + "'");
}
channels.add(channel);
return channels;
}