1
votes

I'm new to Camel and trying to do simple thing. Inside Camel I want to expose Web Service that will have Request and Response

public Response myMethod(Request r) {
//some logic here
}

Inside this method I will do request validation: and if invalid I will reply with certain code (FAILURE) in Response.

If it is valid, then I will ALSO reply with another code (SUCCESS).

In case of success I need Camel route to kick in, take Request, transform it and send to another service.

What I do not understand is - how do I reply to the client with Response and AT THE SAME time will kick off Camel Route.

Tried to find that example on Google ... was not able to. Can Camel do what I want ?

3
Just wanted to clarify. After the request validation portion of the code, will there be any other response returned or is the request validation the only response that will be returned? - David
Only 1 Response will be returned - bogdatov

3 Answers

0
votes

I am not quit sure I understand your question but to reply back and to continue your flow you can use Camel wiretap functionality. You can find example and explanation here. http://camel.apache.org/wire-tap.html

0
votes

You can use the request reply EIP that camel supports. I can imagine your route looking something like this:

from(start)
    .bean(validation)
    .setExchangePattern(ExchangePattern.InOnly)
    .to(end);
0
votes

I think you are expecting something like this.

from("timer:foo?repeatCount=1").bean(validationBean).when(header.returncode==200).bean(nextbean).otherwise().log("you dont have access!!").end();

In validation bean, access the webservices and set the header of retruncode for validation and set another header for reply value to get the those values in the exchange of nextbean.