Reputation: 1903
I have some existing web application program develop by pass senior and now I am supporting and study on it. I tried to read many articles from internet about the Apache Camel, but still cant get the point.
Let me show some Class code that extends RouteBuilder
:
This is from FserviceRouteBuilder
class:
@Override
public void configure() throws Exception {
log.debug( "FServiceRouteBuilder configure" );
errorHandler( deadLetterChannel( ).maximumRedeliveries( 0 ) );
from( this.from ).process( requestProcessor ).process(
transformProcessor );
log.debug( "FServiceRouteBuilder configure end" );
}
And this is from MyBillRouteBuilder
:
@Override
public void configure() throws Exception {
log.debug( ">>MybillRouteBuilder configure" );
errorHandler( deadLetterChannel( ).maximumRedeliveries( 0 ) );
from( this.from ).process( requestProcessor ).to(
"direct:_mybill-process-response" );
if ( transformProcessor != null ) {
from( "direct:_mybill-process-response" ).process(
transformProcessor );
}
log.debug( ">>MybillRouteBuilder configure end" );
}
What I saw from the different is, the MyBillRouteBuilder
use the to()
method, which is to( "direct:_myebill-process-response" )
, but FServiceRouteBuilder
didn't do in that way.
But both of them work. I tried to change the FServiceRouteBuilder
to follow to use the to()
method, and its work as well.
Both of them also calling and processing particular web service with SOAP method.
May I know what is the to()
actually doing? And what is the different to use it and without it?
Sorry I am very very new to this.
Upvotes: 0
Views: 1804
Reputation: 27018
The main difference is that in FServiceRouteBuilder all the steps in your route runs in the same Thread.
from( this.from ).process( requestProcessor ).process(
transformProcessor );
Both the processors(requestProcessor, transformProcessor) runs in the same Thread. You can confirm this by just logging a statement in both processor like Thread.currentThread().getId()
.
Whereas with MyBillRoutebuilder your second processor(transformProcessor) is decoupled from first(using a to
) and it runs in a separate thread.
from( this.from ).process( requestProcessor ).to(
"direct:_mybill-process-response" );
if ( transformProcessor != null ) {
from( "direct:_mybill-process-response" ).process(
transformProcessor );
}
Upvotes: 1