-
1. Re: camel, routing by operation
synclpz Dec 10, 2013 2:06 PM (in response to staffsgull)1 of 1 people found this helpfulMay be use OperationSelector in service binding and provide different routes for different operations?
-
2. Re: camel, routing by operation
staffsgull Dec 10, 2013 5:04 PM (in response to synclpz)Thanks for the reply Viktor. I could use that, or a BPEL with an Operation split, but I was hoping to be able to split in Camel to keep this down to one component.
I have seen ?dataFormat=PAYLOAD for beans but not for Web Service. the dataFormat=PAYLOAD allows the route to see operationName as a value in the header.
-
3. Re: Re: camel, routing by operation
kcbabo Dec 10, 2013 8:15 PM (in response to staffsgull)Rod,
Can you file a SwitchYard JIRA requesting that operation name is set as a Camel message header automatically? I'm going to describe how you can do it on your own below, but we really should just do this OOTB.The way to get this done today is to introduce code which maps the operation name from a SwitchYard exchange into a context property. This context property is subsequently mapped into the Camel exchange in your route. There are two ways to introduce this code: (1) ExchangeInterceptor or (2) MessageComposer. I would prefer the ExchangeInterceptor route since it's easy to implement and it will set the operation name as a context property for every exchange in your application. If this turns out to be undesirable for some reason, you can introduce filtering logic in your interceptor or go the MessageComposer route. The ExchangeInterceptor code would look something like this:
@Named("OperationName") public class OperationNameInterceptor implements ExchangeInterceptor { public void before(String target, Exchange exchange) throws HandlerException { exchange.getContext().setProperty( "operationName", exchange.getContract().getConsumerOperation().getName()); } public void after(String target, Exchange exchange) throws HandlerException { } public List<String> getTargets() { return Arrays.asList(PROVIDER); } }
You could then access the operation name as a message property like this:
from("switchyard://MyService") .log("operation name is ${header.operationName}")
hth,
keith
-
4. Re: camel, routing by operation
staffsgull Dec 11, 2013 5:14 PM (in response to kcbabo)Thanks for that Keith,
I will try that in the next couple of days, it is a solution, but as you say, I think Camel should present this as a header value as this i one of the most common routing rules I use. See it's all me,me,me :-)
I will post a JIRA request as well.
IDH
Rod