The root element of the router schema is camelContext
, which is
defined in the XML namespace,
http://activemq.apache.org/camel/schema/spring
. Router configurations
are typically embedded in other XML configuration files (for example, in a Spring
configuration file). In general, whenever a router configuration is embedded in another
configuration file, you must specify the location of the router schema (so that the router
configuration can be parsed). Example 3.1 shows how to embed the router
configuration, camelContext
, in an arbitrary document,
DocRootElement
.
Example 3.1. Specifying the Router Schema Location
<DocRootElement
... xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd"> <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> <!-- Define your routing rules here --> </camelContext> </DocRootElement
>
where the schema location is specified as
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
, which
gives the location of the schema on the Apache Web site. This location always contains the latest, most up-to-date version of the XML
schema. If you prefer to tie your configuration to a specific version of the schema, change
the schema file name to
camel-spring-
Version
.xsd
,
where Version
can be one of: 1.0.0
,
1.1.0
, 1.2.0
, 1.3.0
, or
1.4.0
. For example, the location of schema version 1.4.0 would be specified
as
http://activemq.apache.org/camel/schema/spring/camel-spring-1.4.0.xsd
.
Example 3.2 shows an example of embedding a router configuration,
camelContext
, in a Spring configuration file.
Example 3.2. Router Schema in a Spring Configuration File
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd"> <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> <!-- Define your routing rules in here --> </camelContext> <!-- Other Spring configuration --> <!-- ... --> </beans>