Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Custom Router,Please help...

  1. #1
    Join Date
    Jun 2010
    Posts
    15

    Default 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. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

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

  3. #3
    Join Date
    Jun 2010
    Posts
    15

    Default

    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. #4
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    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. #5
    Join Date
    Jun 2010
    Posts
    15

    Default

    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.

  6. #6
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    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>

  7. #7
    Join Date
    Jun 2010
    Posts
    15

    Default

    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"

  8. #8
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Yes you can. Look at XPath router samples here:
    https://src.springsource.org/svn/spr...on/xml/router/

  9. #9
    Join Date
    Jun 2010
    Posts
    15

    Default

    Oleg, Thank you for help!!!

  10. #10
    Join Date
    Jun 2010
    Posts
    15

    Default

    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;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •