Camel ComponentsThere now follows the documentation on each Camel component. ActiveMQ ComponentThe ActiveMQ component allows messages to be sent to a JMS URI formatactivemq:[topic:]destinationName So for example to send to queue FOO.BAR you would use activemq:FOO.BAR You can be completely specific if you wish via activemq:queue:FOO.BAR If you want to send to a topic called Stocks.Prices then you would use activemq:topic:Stocks.Prices Configuring the Connection FactoryThe following test case camelContext.addComponent("activemq", activeMQComponent("vm://localhost?broker.persistent=false")); See AlsoCXF ComponentThe cxf: component provides integration with Apache CXF URI formatcxf:address See AlsoDirect ComponentThe direct: component provides direct, synchronous invocation of any consumers when a producer sends a message exchange. URI formatdirect:someName Where someName can be any string to uniquely identify the endpoint Options
See AlsoFile ComponentThe File component provides access to file systems; allowing files to be processed by any other Camel Components or messages from other components can be saved to disk. URI formatfile:fileName Where fileName represents the underlying file name URI Options
By default the file is locked for the duration of the processing. Also when files are processed they are moved into the .camel directory; so that they appear to be deleted. Message HeadersThe following message headers can be used to affect the behaviour of the component
See AlsoFTP/SFTP/WebDAV ComponentThis component provides access to remote file systems over the FTP, SFTP and WebDAV protocols URI formatftp://host[:port]/fileName[?options] sftp://host[:port]/fileName[?options] webdav://host[:port]/fileName[?options] Where fileName represents the underlying file name or directory Options
See AlsoHTTP ComponentThe http: component provides HTTP based endpoints for exposing HTTP resources or consuming external HTTP resources. URI formathttp:hostname[:port][/resourceUri] See AlsoJBI ComponentThe jbi: component provides integration with a JBI Service Bus such as provided by Apache ServiceMix URI formatjbi:service:serviceNamespace[sep]serviceName jbi:endpoint:serviceNamespace[sep]serviceName[sep]endpointName jbi:name:endpointName The separator used will be:
For more details of valid JBI URIs see the ServiceMix URI Guide Using the jbi:service: or jbi:endpoint: URI forms will set the service QName on the JBI endpoint to the exact one you give. Otherwise the default Camel JBI Service QName will be used which is {http://activemq.apache.org/camel/schema/jbi}endpoint
Examplesjbi:service:http://foo.bar.org/MyService jbi:endpoint:urn:foo:bar:MyService:MyEndpoint jbi:endpoint:http://foo.bar.org/MyService/MyEndpoint jbi:name:cheese Creating a JBI Service UnitIf you have some Camel routes you want to deploy inside JBI as a Service Unit you can use the JBI Service Unit Archetype to create a new project. If you have an existing maven project which you need to convert into a JBI Service Unit you may want to refer to the ServiceMix Maven JBI Plugins
Your pom.xml should look something like this to enable the jbi-service-unit packaging. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>myGroupId</groupId> <artifactId>myArtifactId</artifactId> <packaging>jbi-service-unit</packaging> <version>1.0-SNAPSHOT</version> <name>A Camel based JBI Service Unit</name> <url>http://www.myorganization.org</url> <properties> <camel-version>1.0.0</camel-version> <servicemix-version>3.2-incubating</servicemix-version> </properties> <dependencies> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-jbi</artifactId> <version>${camel-version}</version> </dependency> <dependency> <groupId>org.apache.servicemix</groupId> <artifactId>servicemix-core</artifactId> <version>${servicemix-version}</version> <scope>provided</scope> </dependency> </dependencies> <build> <defaultGoal>install</defaultGoal> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> <!-- creates the JBI deployment unit --> <plugin> <groupId>org.apache.servicemix.tooling</groupId> <artifactId>jbi-maven-plugin</artifactId> <version>${servicemix-version}</version> <extensions>true</extensions> </plugin> </plugins> </build> </project> See AlsoJMS ComponentThe JMS component allows messages to be sent to a JMS URI formatjms:[topic:]destinationName?properties So for example to send to queue FOO.BAR you would use jms:FOO.BAR You can be completely specific if you wish via jms:queue:FOO.BAR If you want to send to a topic called Stocks.Prices then you would use jms:topic:Stocks.Prices NotesIf you wish to use durable topic subscriptions, you need to specify both clientId and durableSubscriberName. Note that the value of the clientId must be unique and can only be used by a single JMS connection instance in your entire network. You may prefer to use Virtual Topics
PropertiesYou can configure lots of different properties on the JMS endpoint which map to properties on the JMSConfiguration POJO
See AlsoJPA ComponentThe jpa: component allows you to work with databases using JPA (EJB 3 Persistence) such as for working with OpenJPA, Hibernate, TopLink to work with relational databases. Sending to the endpointSending POJOs to the JPA endpoint inserts entities into the database. The body of the message is assumed to be an entity bean (i.e. a POJO with an @Entity annotation on it). If the body does not contain an entity bean then use a Message Translator in front of the endpoint to perform the necessary conversion first. Consuming from the endpointConsuming messages removes (or updates) entities in the database. This allows you to use a database table as a logical queue, consumerse take messages from the queue and then delete/update them to logically remove them from the queue. If you do not wish to delete the entity when it has been processed you can specify ?consumeDelete=false on the URI. This will result in the entity being processed each poll. If you would rather perform some update on the entity to mark it as processed (such as to exclude it from a future query) then you can annotate a method with @Consumed URI formatjpa:[entityClassName] For sending to the endpoint, the entityClassName is optional. If specified it is used to help use the Type Conversion For consuming the entityClassName is mandatory. Options
See AlsoMail ComponentThe mail: component provides access to Email via Spring's Mail support and the underlying JavaMail system URI formatpop://[user-info@]host[:port][?password=somepwd] imap://[user-info@]host[:port][?password=somepwd] smtp://[user-info@]host[:port][?password=somepwd] which supports either POP, IMAP or SMTP underlying protocols.
See AlsoMINA ComponentThe mina: component is a transport for working with Apache MINA URI formatmina:tcp://hostname[:port] mina:udp://hostname[:port] mina:multicast://hostname[:port] Options
See Also|Mock ComponentTesting of distributed and asynchronous processing is notoriously difficult. The Mock Component provides a great tool for creating good integration test cases based on the Enterprise Integration Patterns using the various Components in Camel. The Mock component provides a powerful declarative testing mechanism which is similar to jMock This allows you to test various things like
URI formatmock:someName Where someName can be any string to uniquely identify the endpoint ExamplesHere's a simple example of MockEndpoint in use. First the endpoint is resolved on the context. Then we set an expectation, then after the test has run we assert our expectations are met. MockEndpoint resultEndpoint = context.resolveEndpoint("mock:foo", MockEndpoint.class); resultEndpoint.expectedMessageCount(2); // send some messages ... // now lets assert that the mock:foo endpoint received 2 messages resultEndpoint.assertIsSatisfied(); You typically always call the assertIsSatisfied() method Setting expectationsYou can see from the javadoc of MockEndpoint
Here's another example resultEndpoint.expectedBodiesReceived("firstMessageBody", "secondMessageBody", "thirdMessageBody"); Adding expectations to specific messagesIn addition you can use the message(int messageIndex) For example to add expectations of the headers or body of the first message (using zero based indexing like java.util.List), you can use this code resultEndpoint.message(0).header("foo").isEqualTo("bar"); There are some examples of the Mock endpoint in use in the camel-core processor tests See AlsoPojo ComponentThe pojo: component is now just an alias for the Bean component. See AlsoQuartz ComponentThe quartz: component provides a scheduled delivery of messages using the Quartz scheduler URI formatquartz://timerName?parameters quartz://groupName/timerName?parameters quartz://groupName/timerName/cronExpression You can configure the Trigger and JobDetail using the parameters
For example the following routing rule will fire 2 timer events to the endpoint mock:results from("quartz://myGroup/myTimerName?trigger.repeatInterval=2&trigger.repeatCount=1").to("mock:result"); Using Cron TriggersQuartz supports Cron-like expressions For example the following will fire a message at 12pm (noon) every day from("quartz://myGroup/myTimerName/0/0/12/*/*/$").to("activemq:Totally.Rocks"); which is equivalent to using the cron expression 0 0 12 * * ? The following table shows the URI character encodings we use to preserve valid URI syntax
See AlsoQueue Component
The queue: component provides asynchronous SEDA Note that queues are only visible within a single CamelContext. If you want to communicate across CamelContext instances such as to communicate across web applications, see the VM component. Note also that this component has nothing to do with JMS, if you want a distributed SEA then try using either JMS or ActiveMQ or even MINA URI formatqueue:someName Where someName can be any string to uniquely identify the endpoint within the current CamelContext See AlsoRMI ComponentThe rmi: component bind the PojoExchanges Since this binding is just using RMI, normal RMI rules still apply in regards to what the methods can be used over it. This component only supports PojoExchanges URI formatrmi://rmi-regisitry-host:rmi-registry-port/registry-path
For example: rmi://localhost:1099/path/to/service
UsingTo call out to an existing RMI service registered in an RMI registry, create a Route similar to: from("pojo:foo").to("rmi://localhost:1099/foo"); To bind an existing camel processor or service in an RMI registry, create a Route like: RmiEndpoint endpoint= (RmiEndpoint) endpoint("rmi://localhost:1099/bar"); endpoint.setRemoteInterfaces(ISay.class); from(endpoint).to("pojo:bar"); Notice that when binding an inbound RMI endpoint, the Remote interfaces exposed must be specified. See AlsoTimer ComponentThe timer: component provides timed events to Bean component. You can only consume events from this endpoint. It produces BeanExchange URI formattimer:name?options Where options is a query string that can specify any of the following parameters:
UsingTo setup a route that generates an event every 500 seconds: from("timer://foo?fixedRate=true&delay=0&period=500").to("pojo:bar");
Note that the "bar" pojo registered should implement Runnable See AlsoXMPP ComponentThe xmpp: component implements an XMPP (Jabber) transport. URI formatxmpp:hostname[:port][/room] The component supports both room based and private person-person conversations See Also |