camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paquettd <dan.paque...@lmco.com>
Subject @RecipientList and ProducerTemplate (Camel 1.6 and 1.5)
Date Thu, 26 Feb 2009 15:52:00 GMT

I'm seeing a behavior in camel 1.6 I don't understand. when I used the
producerTemplate to kickoff a workflow that
includes a @RecipientList component I seem to get back the result of the
recipient list... but my other services
end up being called (and their results simply lost to the ether).

Here are some details (scrubbed of the real names; but the same idea)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:camel="http://activemq.apache.org/camel/schema/spring"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 

http://www.springframework.org/schema/beans/spring-beans.xsd
	http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">

    <bean id="serviceA" class="example.ServiceAImpl"/>
    <bean id="serviceB" class="example.ServiceAImpl"/>
    <bean id="serviceC" class="example.ServiceAImpl"/>

    <bean id="myRouter" class="example.MyRouter">
        <property name="passUrl" value="direct:needABC"/>
        <property name="failUrl" value="direct:needBC"/>
    </bean>

    <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
        <template id="myCamelTemplate" defaultEndpoint="direct:test"/>

        <route>
            <from uri="direct:test"/>
            <bean ref="myRouter"/>
        </route>

        <route>
            <from uri="direct:needABC"/>
            <bean ref="serviceA"/>
            <to uri="direct:needBC"/>
        </route>
        
        <route>
            <from uri="direct:needBC"/>
            <bean ref="serviceB"/>
            <bean ref="serviceC"/>
        </route>
        
    </camelContext>

    <bean id="myTester" class="example.MyTester">
        <property name="producerTemplate" ref="myCamelTemplate"/>
    </bean>
</beans>



My router class looks like:

public class MyRouter{

	public String passUrl = null;
	public String failUrl = null;
	
	@RecipientList
	public String route(String body) {
		// for testing always return passUrl
		return passUrl;
	}
	
	public void setPassUrl(String url) {
		passUrl = url;
	}
	
	public void setFailUrl(String url) {
		failUrl = url;
	}
}

And finally my "tester" does this:

template.requestBody(template.getDefaultEndpoint(), "Hello World")

All my services expect a String in this test; they just mutate it
(capitalize, reverse, other trival ops)
for the purpose of testing. I get to all those breakpoints.

Anyway.. requestBody returns "direct:needABC" to me... but then I see
services A,B and C getting called.
If I changed direct:test to seda:test I get back my original input... and
services A,B and C still get called.
Both ways the result are lost.

Am I missing something very obvious?

FYI I was trying to avoid using @RecipientList and using <choose><when> etc
with groovy or javascript to do my
content based routing. Unfortunatly I'm using Java 5 without
javax.scripting. I tried installing
the javax.scripting implementation from java.net but couldn't quite get it
going in my OSGi container.
I guess that's a different question; but that would be my preferred
implementation.
-- 
View this message in context: http://www.nabble.com/%40RecipientList-and-ProducerTemplate-%28Camel-1.6-and-1.5%29-tp22227016p22227016.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.


Mime
View raw message