Announcement Announcement Module
No announcement yet.
Custom Router,Please help... Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom Router,Please help...

    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

  • #2
    which is it that you are looking for Routing or Transformation?


    • #3
      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....


      • #4
        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


        • #5
          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, 02:03 PM.


          • #6
            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:

            <si:payload-type-router input-channel="some-channel">
            		<si:mapping type="java.lang.String" channel="chanel-for-strings"/>
            		<si:mapping type="" channel="chanel-for-bars"/>
            <si:transformer input-channel="chanel-for-strings" ...>
            		. . . .
            <si:transformer input-channel="chanel-for-bars" ...>
            		. . . .


            • #7
              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:


              if MessageType="Transfer" then channel="abc"


              • #8
                Yes you can. Look at XPath router samples here:


                • #9
                  Oleg, Thank you for help!!!


                  • #10
                    Please help, I stuck here, What should be the syntax to get channel value from my customRouterBean

                    <beans:bean id="customRouterBean"




                    public class SwiftMainRouter extends AbstractMessageRouter {

                    ChannelResolver channelResolver;
                    MessageChannel channel =null;

                    protected Collection<MessageChannel> determineTargetChannels(
                    Message<?> message) {
                    // TODO Auto-generated method stub

                    System.out.println("Hello from Custom Router");

                    if (message == null)
                    throw new MessagingException(" message but is null");

                    String channelName="";

                    String msg = message.getPayload().toString();

                    Collection<MessageChannel> channels = new ArrayList<MessageChannel>();

                    channelName = "inboundAdapter";

                    channel = channelResolver.resolveChannelName(channelName);

                    if (channel==null)
                    throw new MessagingException(message, "failed to resolve channel name '" + channelName + "'");


                    return channels;


                    • #11
                      I am not sure I understand the question. What channel?
                      Router receives on input-channel and routs the messages to 'other channels' based on the type of router.
                      If you are writing a completely new router then you are responsible to provide routing logic and maintain collection of channels it will route to.
                      Once you create this bean you configure is as such:
                      <int:channel id="input"/>
                      <int:router input-channel="input" ref="myRouter"/>
                      <bean id="myRouter" class="">
                      <!-- this is where you might want to inject a collection of channels you want to route -->
                      Also, I thought you were routing based on XML. Have you look at XPath router support?


                      • #12
                        yes, This is what have now:

                        <router input-channel="transformInChannel" ref="customRouterBean"/>
                        <beans:bean id="customRouterBean"



                        Please I need injection syntax,How to get channel value from


                        • #13
                          What channel?


                          • #14
                            Can you please look to my class it return the channel "other-channel",Can you please call me to discuss???? -if it's possible...


                            • #15
                              What I think you are asking is how to inject channels into your custom router.
                              You do it through basic Spring dependency injection, you can read more on it here:

                              In your particular case you probably want to inject some type of collection of channels, again here is documentation on how to inject collections:

                              You still did not answer as to why you are not using XPath routers which probably provide all the functionality you need instead of implementing your own class.