Hello,

This was originally posted in default Camel forum but I guess camel-users is
best.

Since we upgraded to anything from Camel 2.3 onwards, our InOut() routes are
mis-behaving ;)

After some long and painful debugging we realised that the Splitter()
pattern is causing the problem. The problem is that the Out Exchange does
not contain the expected body() anymore.

Explanation:

As the Exchange propagates down the inOut() routes, the Body gets
transformed from 1 type of object to another as we pass it from bean to
bean. We expect to get back in the synchronous response whatever object is
in the Body at the end of the inOut route, however that is not the case when
a splitter is inserted somewhere in the route. Instead, we get back the body
from the Exchange as it was when it entered the Splitter - so in our case,
that is an ArrayList (since we are asking the splitter to split our list). 

What is interesting is that the Synchronous call is not returned back to the
caller when the Splitter is reached. Camel correctly continues to process
the route (and any further routes defined with inOut()) all the way to the
end before returning to caller. However the Out Exchange does not contain
the expected body(), instead it contains the body() as it was when it hit
the first Splitter.


TestCase:

The  http://camel.465427.n5.nabble.com/file/n3210842/Handler.java
Handler.java  file contains route definitions and 
http://camel.465427.n5.nabble.com/file/n3210842/Router.java Router.java 
contains methods that are called from Router. Class Handler is defined as a
bean in the application spring configuration and referred to as "handler". 

Classes A, B, C and D are simple classes without any fields or methods. 

After running a jUnit test with the following test method: 
    public void testCamel() {
        
        A a = new A();
        
        ProducerTemplate camelTemplate = (ProducerTemplate) 
           
ApplicationContextProvider.getApplicationContext().getBean("camelTemplate");

        Object o = camelTemplate.requestBody("direct:start", a);
        
        System.out.println("Returned: " + o.getClass().getName());
        
        if (o instanceof List) {
            
            for (Object element : (List) o) {
                
                System.out.println("Element: " +
element.getClass().getName());
            }
        }
    }

what gets passed back is a List containing objects of type B 
Returned: java.util.ArrayList
Element: B
Element: B
Element: B

even though a single object of type C should have been returned. 

Please help. We are making extensive use of this Camel feature so we are
struggling to work around.

Thanks in advance and BRegards

For ref: Originally posted here:
http://camel.465427.n5.nabble.com/Synchronous-queue-and-splitter-issue-td3201480.html#a3201480
-- 
View this message in context: 
http://camel.465427.n5.nabble.com/Problem-with-Splitter-in-Synchronous-routes-introduced-in-Camel-2-3-tp3210842p3210842.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to