Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Routing/Mediation service

The routing/mediation between services/bundles will be created using Spring DSL language. We will describe its creation/genesis step by step.

First, create the file camel-context.xml in the directory src/main/resources/META-INF/spring and add the lines :

Code Block

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:camel="http://camel.apache.org/schema/spring"
	xmlns:osgi="http://www.springframework.org/schema/osgi"
	xmlns:cxf="http://camel.apache.org/schema/cxf"
	xsi:schemaLocation="
	    http://www.springframework.org/schema/beans
		http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
		http://www.springframework.org/schema/osgi
		http://www.springframework.org/schema/osgi/spring-osgi.xsd
		http://camel.apache.org/schema/osgi
		http://camel.apache.org/schema/osgi/camel-osgi.xsd
		http://camel.apache.org/schema/spring
		http://camel.apache.org/schema/spring/camel-spring.xsd
		http://camel.apache.org/schema/cxf
		http://camel.apache.org/schema/cxf/camel-cxf.xsd">
</beans>

Compare to a simple camel project, the spring beans tag has been enriched with new namespaces :

Now, that the schema/namespaces are declared, we can start to create beans reference or import resources that our routing engine will use.

1) Webservice infrastructure : CXF

We will use the CXF framework to deploy the reportincident webservice and run it into the OSGI platform

To work with it, resources (= spring beans) declared in CXF project must be imported using the command import resource.

Code Block

...
 <import resource="classpath:META-INF/cxf/cxf.xml" />
 <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
 <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
 <import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml" /> 
...

These imports will be used by spring at the bundle startup to instantiate the beans defined in these files. These beans are responsible in fact to deploy the architecture of the CXF bus top of the OSGI server and to provide a servlet that we will use to communicate with webservices engine of CXF.

Remark : for the purpose of this tutorial, we have packaged this configuration into the camel-spring file but it could be defined in a separate xml file with by example the component/endpoint that Camel will use to communicate with CXF bus. This allows you to separate routing from parameters to be provided to configure endpoints.

The camel CXF endpoint is configurated like this :

Code Block

	<!-- webservice endpoint --> 
	<cxf:cxfEndpoint id="reportIncident"
		address="/camel-example/incident"
		serviceClass="org.apache.camel.example.reportincident.ReportIncidentEndpoint"
		xmlns:s="http://reportincident.example.camel.apache.org">
	</cxf:cxfEndpoint>

Remarks :

  • the address corresponds to the URI address of the web services,
  • the serviceClass is the name of the class used work with the webservices and deployed in the bundle reportincident.webservice
  • xmlns is the namespace of the reportincident webservice

2) Queueing engine

Web

Packaging and deployment

...