Permalink
Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
273 lines (241 sloc) 10.1 KB
<?xml version="1.0" encoding="UTF-8"?>
<!-- Configures the Camel Context-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:amq="http://activemq.apache.org/schema/core"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<!--
lets enable hawtio logs. See: http://hawt.io/logs/
though you get this enabled by default if you use hawtio-default.war
-->
<bean id="logQuery" class="io.hawt.log.log4j.Log4jLogQuery" lazy-init="false" scope="singleton"
init-method="start" destroy-method="stop"/>
<!-- This creates an embedded ActiveMQ Broker -->
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker1" useJmx="true" schedulerSupport="true">
<networkConnectors>
<networkConnector uri="static:(tcp://localhost:31317)" userName="admin" password="admin"/>
</networkConnectors>
<transportConnectors>
<transportConnector uri="tcp://localhost:31316"/>
</transportConnectors>
<persistenceAdapter>
<kahaDB directory="target/activemq/broker1/data/kahadb"/>
</persistenceAdapter>
<plugins>
<simpleAuthenticationPlugin>
<users>
<authenticationUser username="admin" password="admin" groups="users,admins"/>
</users>
</simpleAuthenticationPlugin>
</plugins>
</broker>
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker2" useJmx="true">
<networkConnectors>
<networkConnector uri="static:(tcp://localhost:31316)" userName="admin" password="admin"/>
</networkConnectors>
<transportConnectors>
<transportConnector uri="tcp://localhost:31317"/>
</transportConnectors>
<persistenceAdapter>
<kahaDB directory="target/activemq/broker2/data/kahadb"/>
</persistenceAdapter>
<plugins>
<simpleAuthenticationPlugin>
<users>
<authenticationUser username="admin" password="admin" groups="users,admins"/>
</users>
</simpleAuthenticationPlugin>
</plugins>
</broker>
<!-- Lets connect the Camel ActiveMQ component to the embedded broker.
See http://camel.apache.org/activemq.html for more information.
-->
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="failover:tcp://localhost:31316"/>
<property name="username" value="admin"/>
<property name="userName" value="admin"/>
<property name="password" value="admin"/>
<property name="preserveMessageQos" value="true"/>
<property name="explicitQosEnabled" value="true"/>
</bean>
<!-- tell Camel to use localhost as the JMX MBean naming to have a fixed name style -->
<bean id="managementName" class="org.apache.camel.management.DefaultManagementNamingStrategy">
<!-- the hostname does not have to be resolvable, it can be any value you want -->
<property name="hostName" value="localhost"/>
<property name="domainName" value="org.apache.camel"/>
</bean>
<!-- use camel-metrics route policy to gather metrics for all routes -->
<bean id="metricsRoutePolicyFactory" class="org.apache.camel.component.metrics.routepolicy.MetricsRoutePolicyFactory"/>
<!-- Here is a sample which processes the input files
(leaving them in place - see the 'noop' flag), and
sends them on a JMS queue. This queue is watched by
another route which then performs content based
routing on the messages using XPath.
-->
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route id="fileInputRoute from file:src/test/data?noop=true">
<from id="inputFiles" uri="file:src/test/data?noop=true"/>
<to id="firstStep" uri="activemq:personnel.records"/>
<to id="secondStep" uri="activemq:very.long.queue.name.goes.here.wow.this.really.is.quite.a.long.queue.name.isnt.it.eh"/>
<bean ref="myBean" method="cheese"/>
<to id="coolBeans" uri="activemq:browse.me"/>
</route>
<route id="foo">
<from id="personnelRecords" uri="activemq:personnel.records"/>
<choice>
<when id="isCityLondon">
<xpath>/person/city = 'London'</xpath>
<to id="messagesUK" uri="file:target/messages/uk"/>
</when>
<otherwise>
<to id="messagesOthers" uri="file:target/messages/others"/>
</otherwise>
</choice>
<aggregate strategyRef="myAgg" completionTimeout="30000">
<correlationExpression>
<constant>true</constant>
</correlationExpression>
<completionPredicate>
<simple>${header.done}</simple>
</completionPredicate>
<completionTimeout>
<header>timeoutnow</header>
</completionTimeout>
<to uri="mock:done"/>
</aggregate>
</route>
<!-- route for having something trigger all the time -->
<route id="timerToAMQ">
<from uri="timer:foo?period=2000"/>
<transform>
<constant>Hello World</constant>
</transform>
<delay><constant>1500</constant></delay>
<setBody><simple>A Delayed ${body}</simple></setBody>
<marshal>
<string charset="iso-8859-1"/>
</marshal>
<setHeader headerName="myHeader">
<constant>This is a new header value</constant>
</setHeader>
<log message="The message contains ${body}" loggingLevel="DEBUG"/>
<to uri="activemq:timer.events"/>
</route>
<route id="bytesToAMQ">
<from uri="timer:foo?period=2000"/>
<transform>
<constant>Hello World</constant>
</transform>
<delay asyncDelayed="true"><constant>1000</constant></delay>
<setBody><simple>A Delayed ${body}</simple></setBody>
<setHeader headerName="myHeader">
<constant>This is a new header value</constant>
</setHeader>
<convertBodyTo type="byte[]"/>
<to uri="activemq:timer.bytes?jmsMessageType=Bytes"/>
</route>
<route id="directRoute">
<from uri="direct:start"/>
<setBody>
<simple>hello!</simple>
</setBody>
<to uri="log:entesb.EVENT?level=INFO"/>
</route>
</camelContext>
<camelContext id="onExceptionContext" xmlns="http://camel.apache.org/schema/spring">
<onException>
<exception>java.lang.Exception</exception>
<choice>
<when>
<xpath>$foo = 'bar'</xpath>
<to uri="direct:b"/>
</when>
<when>
<xpath>$foo = 'cheese'</xpath>
<to uri="direct:c"/>
</when>
<otherwise>
<to uri="direct:d"/>
</otherwise>
</choice>
</onException>
<route>
<from uri="timer://purgeTimer?period=900000"/>
<log loggingLevel="INFO" logName="test" message="testPing..."/>
<to uri="direct:e"/>
</route>
<route>
<from uri="direct:b"/>
<log loggingLevel="INFO" logName="test" message="direct:b"/>
</route>
<route>
<from uri="direct:c"/>
<log loggingLevel="INFO" logName="test" message="direct:c"/>
</route>
<route>
<from uri="direct:d"/>
<log loggingLevel="INFO" logName="test" message="direct:d"/>
</route>
<route>
<from uri="direct:e"/>
<log loggingLevel="INFO" logName="test" message="direct:e"/>
</route>
</camelContext>
<camelContext id="cheese" xmlns="http://camel.apache.org/schema/spring">
</camelContext>
<camelContext id="thingy" xmlns="http://camel.apache.org/schema/spring">
</camelContext>
<camelContext id="bar" xmlns="http://camel.apache.org/schema/spring">
</camelContext>
<camelContext id="quartzCamel" xmlns="http://camel.apache.org/schema/spring">
<route id="quartzRoute1">
<!-- must set -1 due bug in camel-quarz2 -->
<from uri="quartz2:mygroup/mytimer?trigger.repeatInterval=20000&amp;trigger.repeatCount=-1"/>
<log message="Quartz2 mytrigger fired"/>
<delay><constant>10000</constant></delay>
<log message="Quartz2 mytrigger done"/>
</route>
<route id="quartzRoute2">
<from uri="quartz2:mygroup/myothertimer?cron=0/30+*+*+*+*+?"/>
<log message="Quartz2 myothertrigger fired"/>
</route>
</camelContext>
<camelContext id="otherQuartzCamel" xmlns="http://camel.apache.org/schema/spring">
<route id="otherQuartzRoute">
<from uri="quartz2other:foo/bar?cron=0/45+*+*+*+*+?"/>
<log message="Other Quartz2 foo/bar fired"/>
</route>
</camelContext>
<!-- lets have a Camel with the Rest DSL too -->
<camelContext id="restCamel" xmlns="http://camel.apache.org/schema/spring">
<restConfiguration component="restlet" bindingMode="json">
<dataFormatProperty key="prettyPrint" value="true"/>
</restConfiguration>
<rest path="/user" consumes="application/json" produces="application/json">
<get uri="/view/{id}" outType="io.hawt.camel.rest.User">
<to uri="bean:userService?method=getUser(${header.id})"/>
</get>
<get uri="/list" outType="io.hawt.camel.rest.User[]">
<to uri="bean:userService?method=listUsers"/>
</get>
<put uri="/update" type="io.hawt.camel.rest.UserService" outType="io.hawt.camel.rest.User">
<to uri="bean:userService?method=updateUser"/>
</put>
</rest>
</camelContext>
<!-- dummy bean for camel routes -->
<bean id="myAgg" class="io.hawt.camel.sample.MyAggregationStrategy"/>
<bean id="userService" class="io.hawt.camel.rest.UserService"/>
<bean id="myBean" class="io.hawt.camel.sample.CheeseBean"/>
<bean id="quartz2" class="org.apache.camel.component.quartz2.QuartzComponent">
<property name="propertiesFile" value="myquartz.properties"/>
</bean>
<bean id="quartz2other" class="org.apache.camel.component.quartz2.QuartzComponent">
<property name="propertiesFile" value="myotherquartz.properties"/>
</bean>
<!-- infinispan demo -->
<bean id="infinispanFactory" class="io.hawt.example.infinispan.InfinispanDemo" init-method="init" lazy-init="false"/>
</beans>