camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen" ...@silverbullet.dk>
Subject RE: Content Based Router
Date Tue, 21 Oct 2008 10:54:52 GMT
Hi

You can use bean binding to add a 2nd paramter and annotate it as the @Headers

Public void myMethodInBean(@Headers Map headers, Object payload)

The bean binding is quite powerful. And had a rework on the wiki by James:
http://activemq.apache.org/camel/bean-integration.html

See this wiki for the annotations:
http://activemq.apache.org/camel/parameter-binding-annotations.html


Or you can use the Exchange directly: (if not like annotations)
Public void myMethodInBean(Exchange exchange)





Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: selezovikj [mailto:semir.elezovic@gmail.com] 
Sent: 21. oktober 2008 12:44
To: camel-user@activemq.apache.org
Subject: Content Based Router


I have a camel route configuration in a camel-server.xml file: 

<camelContext id="camel"
xmlns="http://activemq.apache.org/camel/schema/spring">
        <route>
            <from uri="jms:topic:LoggingTopic"/>
            <to uri="bean:msgParser"/>
	   <to uri="bean:contentRouter"/>
        </route>        
</camelContext>

In the contentRouter bean I want, when a certain condition is met to set a
header like setHeader("action", "filterA"), which later I can use to perform
routing logic. 

while ((strLine = br.readLine()) != null)   {
	if(messageName.equals(strLine)){	
                   //SET HEADER or DIRECTLY ROUTE TO FILTER BEAN and then to
FINAL BEAN
	
	} else{

                  //DIRECTLY ROUTE TO FINAL BEAN
        }					
	in.close();
}

I am passing an object to this bean as far as I know. How can I make it
relate to a message on which I can do setHeader ? Later this bean will just
return a message and I will have something like: 

<camelContext id="camel"
xmlns="http://activemq.apache.org/camel/schema/spring">
        <route>
            <from uri="jms:topic:LoggingTopic"/>
            <to uri="bean:msgParser"/>
	   <to uri="bean:contentRouter"/>
        </route>
        <route>
            <from uri="bean:contentRouter"/>
<choice>
      <when>
        <xpath>$action = 'filterA'</xpath>
        <to uri="bean:filter"/>
      </when>
      <otherwise>
        <to uri="bean:final/>
      </otherwise>
    </choice>
</route>
        
</camelContext>

-- 
View this message in context: http://www.nabble.com/Content-Based-Router-tp20087651s22882p20087651.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message