|
Page Edited :
CAMEL :
Camel Transport for CXF
Camel Transport for CXF has been edited by willem jiang (Sep 19, 2008). Change summary: Added the description for <camel:destination> and <camel:conduit> What's the Camel Transport for CXFIn CXF you offer or consume a webservice by defining it´s address. The first part of the address specifies the protocol to use. For example address="http://localhost:90000" in an endpoint configuration means your service will be offered using the http protocol on port 9000 of localhost. When you integrate Camel Tranport into CXF you get a new transport "camel". So you can specify address="camel://direct:MyEndpointName" to bind the CXF service address to a camel direct endpoint. Technically speaking Camel transport for CXF is a component which implements the CXF transport API Integrate Camel into CXF transport layerTo include the Camel Tranport into your CXF bus you use the CamelTransportFactory. You can do this in Java as well as in Spring. Setting up the Camel Transport in SpringYou can use the following snippet in your applicationcontext if you want to configure anything special. If you only want to activate the camel transport you do not have to do anything in your application context. As soon as you include the camel-cxf jar in your app cxf will scan the jar and load a CamelTransportFactory for you. <bean class="org.apache.camel.component.cxf.transport.CamelTransportFactory"> <property name="bus" ref="cxf" /> <property name="camelContext" ref="camelContext" /> <property name="transportIds"> <list> <value>http://cxf.apache.org/transports/camel</value> </list> </property> </bean>
The conduit elementYou configure an Camel transport client using the camel:conduit element and its children. The camel:conduit element takes a single attribute, name, that specifies the WSDL port element that corresponds to the endpoint. The value for the name attribute takes the form portQName.camel-conduit. For example, the code below shows the camel:conduit element that would be used to add configuration for an endpoint that was specified by the WSDL fragment <port binding="widgetSOAPBinding" name="widgetSOAPPort> if the endpoint's target namespace was http://widgets.widgetvendor.net http-conf:conduit Element ... <camelContext id="conduit_context" xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="direct:EndpointA" /> <to uri="direct:EndpointB" /> </route> </camelContext> <camel:conduit name="{http://widgets/widgetvendor.net}widgetSOAPPort.camel-conduit"> <camel:camelContextRef>conduit_context</camel:camelContextRef> </camel:conduit> <camel:conduit name="*.camel-conduit"> <!-- you can also using the wild card to specify the camel-conduit that you want to configure --> ... </camel:conduit> ... The camel:destination element has a number of child elements that specify configuration information. They are described below.
Example Using Camel as a load balancer for CXFThis example show how to use the camel load balance feature in CXF, and you need load the configuration file in CXF and publish the endpoints on the address "camel://direct:EndpointA" and "camel://direct:EndpointB" <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://cxf.apache.org/transports/camel" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://cxf.apache.org/transports/camel http://cxf.apache.org/transports/camel.xsd http://activemq.apache.org/camel/schema/cxfEndpoint http://activemq.apache.org/camel/schema/cxf/cxfEndpoint.xsd http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd "> <bean id = "roundRobinRef" class="org.apache.camel.processor.loadbalancer.RoundRobinLoadBalancer" /> <camelContext id="dest_context" xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="jetty:http://localhost:9090/GreeterContext/GreeterPort"/> <loadBalance ref="roundRobinRef"> <to uri="direct:EndpointA"/> <to uri="direct:EndpointB"/> </loadBalance> </route> </camelContext> <camel:destination name="{http://apache.org/hello_world_soap_http}CamelPort.camel-destination"> <camel:camelContextRef>dest_context</camel:camelContextRef> </camel:destination> </beans> Complete Howto and Example for attaching Camel to CXF |
Unsubscribe or edit your notifications preferences
