For Q1,
I think you can define the route like this
from(xxx)
    .to("bean:UUIDGenerator")
    .to("bean:ConvertImportFileWSToImportJob")
    .wireTap("direct:splitter")
    .to("bean:SetResponseObject");

from("direct:splitter") .split().method("FileImportJobSplitterBean","splitMessage")
.recipientList(header("destination"));

For Q2
You need to define the aggregation in the split like this[1]

[1]http://camel.apache.org/splitter.html#Splitter-Splitaggregaterequest%2Freplysample

On Mon Jun 25 19:29:23 2012, panzerhans wrote:
I have a compound problem that i am unsure if has arisen due to lack of
architectural understanding.

I have a route that consumes a POJO call from a contract first Webservice.
This message is a XML that is split up into pieces and consumed individually
(as JMS messages). In the process of calling this I need to:

1. When I have consumed the initial WS service call I wish to respond with a
specific message
2. After all the split messages has been completed I would like to respond
back on another external service that the messages was either processed OK
or With errors (depending if exceptions occurred during JMS consumption).

Here is my initial routedef. (Java DSL):
----------
onException(Throwable.class).handled(true)
                 .to("bean:GenericDocumentErrorHandler?method=handle")
                 .to("smtp:mailhost.mycomp.no?contentType=text/html")
                 .to("bean:JobCompleted");

  from("cxf:bean:import-webservice?dataFormat=POJO")
                 .routeId("FileImportWSRoute")
                 .to("bean:UUIDGenerator")
                 .to("bean:ConvertImportFileWSToImportJob")
                     .split().method("FileImportJobSplitterBean",
"splitMessage")
                         .recipientList(header("destination"));
---------

The ConvertImportFileWSToImportJob does some data manipulation and sets the
exchange.body on the outbound message to the data type that is expected by
the caller of the Webservice that I serve. I then send that exchange to the
splitter (which fetches the actual split-payload from a header. However it
refuses to respond back to the caller, I assume this is due to that the
route keeps going into the split function and then to the JMS. I therefore
modified this to the following route:

----------
onException(Throwable.class).handled(true)
                 .to("bean:GenericDocumentErrorHandler?method=handle")
                 .to("smtp:mailhost.mycomp.no?contentType=text/html")
                 .to("bean:JobCompleted");

  from("cxf:bean:import-webservice?dataFormat=POJO")
                 .routeId("FileImportWSRoute")
                 .to("bean:UUIDGenerator")

.to("bean:ConvertImportFileWSToImportJob")*.wireTap("bean:RespondToWSCaller")*
                     .split().method("FileImportJobSplitterBean",
"splitMessage")
                         .recipientList(header("destination"));
---------
The RespondToWSCaller copies all headers from the inbound message and sets
the out body from the in body. Still no message propagates back to the
caller.

About Question 2.
Is it possible to use an aggregation by setting a header in the
"ConvertImportFileWSToImportJob" bean e.g.
exchange.getOut.setHeader("TotalMessages", 50) and then in the end route set
a *success constant*, and aggregate on that? Or is it impossible to monitor
the JMS consumer routes from the initial producer?

-------- Example JMS consumer route ------
from("activemq:queue:" + ServiceNames.ImportTest.toString() +
"?concurrentConsumers=1")
                 .routeId(ServiceNames.ImportTest.toString())
                 *.setHeader("Success", constant("1"));*
--------


--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-cxf-jax-ws-POJO-and-response-tp5715039.html
Sent from the Camel - Users mailing list archive at Nabble.com.



--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang

Reply via email to