implementation.camel
beve Apr 11, 2011 2:54 AMHi,
I'm working on this jira and posting for some feedback. I've put together a suggestion for this which can be found here.
A Camel route can be used as the implementation for a service. This is done by using the 'implementation.camel' element which can contain a Camel route. SwitchYard takes care of creating a service for the interface which sole purpose is to trigger the Camel route. It does this by creating a 'from' endpoint that triggers the Camel route. This allows SwitchYard clients to use the service interface to invoke the Camel route.
<sd:switchyard xmlns="urn:switchyard-component-camel:config:1.0" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:sd="urn:switchyard-config:switchyard:1.0" xmlns:bean="urn:switchyard-component-bean:config:1.0"> <sca:composite> <sca:component name="WarehouseComponent" > <bean:implementation.bean class="org.switchyard.component.camel.deploy.support.WarehouseServiceImpl"/> <sca:service name="WarehouseService" promote="WarehouseService"> <sca:interface.java interface="org.switchyard.component.camel.deploy.support.WarehouseService"/> </sca:service> </sca:component> <sca:component name="CamelComponent"> <sca:service name="OrderService" > <sca:interface.java interface="org.switchyard.component.camel.deploy.support.OrderService"/> </sca:service> <sca:reference name="WarehouseService"> <sca:interface.java interface="org.switchyard.component.camel.deploy.support.WarehouseService"/> </sca:reference> <implementation.camel> <route xmlns="http://camel.apache.org/schema/spring" id="Camel Test Route"> <log message="ItemId [${body}]"/> <to uri="switchyard://WarehouseService?operationName=hasItem"/> <log message="Title Name [${body}]"/> </route> </implementation.camel> </sca:component> </sca:composite> </sd:switchyard>
As you can see in the above configuration that the route in 'implementation.camel' does not contain a 'from' route. This is mainly to demonstrate that a 'from' route is created by SwitchYard. It is perfectly legal to have multiple 'from' routes and SwitchYard supports. This allows users to use a route and copy it in to a SwitchYard configuration and have it exposed as a SwitchYard services as well as the possible other 'form' components.
The above would be invokable by using the following code from a SwitchYard test:
String title = newInvoker("OrderService").operation("getTitleForItem").sendInOut("10").getContent(String.class);
Running the above code snippet would generate the following in you console log:
18:05:14,968 INFO [impl.DefaultCamelContext] Total 0 routes, of which 0 is started. 18:05:14,969 INFO [impl.DefaultCamelContext] Apache Camel 2.6.0 (CamelContext: camel-1) started in 0.757 seconds 18:05:15,880 INFO [impl.DefaultCamelContext] Route: Camel Test Route started and consuming from: Endpoint[vm://CamelComponent/OrderService] 18:05:15,880 INFO [impl.DefaultCamelContext] Apache Camel 2.6.0 (CamelContext: camel-1) is starting 18:05:15,880 INFO [impl.DefaultCamelContext] Total 2 routes, of which 2 is started. 18:05:15,880 INFO [impl.DefaultCamelContext] Apache Camel 2.6.0 (CamelContext: camel-1) started in 0.000 seconds 18:05:15,964 INFO [Camel Test Route] ItemId [10] 18:05:15,966 INFO [Camel Test Route] Title Name [Fletch]
Notice the Camel Endpoint 'vm://CamelComponent/OrderService', this is the endpoint that SwitchYard generates and currently defaults to 'vm' but we should make this configurable.
Any thoughts on this?
Regards,
/Daniel