[CONF] Apache Camel Tutorial-JmsRemoting
Claus Ibsen edited the page: Tutorial-JmsRemoting Comment: CAMEL-7252 ... This tutorial aims to guide the reader through the stages of creating a project which uses Camel to facilitate the routing of messages from a JMS queue to a Spring service. The route works in a synchronous fashion returning a response to the client. Table of Contents Prerequisites This tutorial uses Maven to setup the Camel project and for dependencies for artifacts. ... Pattern Description Message Channel We need a channel so the Clients can communicate with the server. Message The information is exchanged using the Camel Message interface. Message Translator This is where Camel shines as the message exchange between the Server and the Clients are text based strings with numbers. However our business service uses int for numbers. So Camel can do the message translation automatically. Message Endpoint It should be easy to send messages to the Server from the the clients. This is archived achieved with Camels powerful Endpoint pattern that even can be more powerful combined with Spring remoting. The tutorial have has clients using each kind of technique for this. Point to Point Channel We using JMS queues so there are only one receive of the message exchange The client and server exchanges data using point to point using a JMS queue.
[CONF] Apache Camel Tutorial-JmsRemoting
Tutorial-JmsRemoting Comment edited by Timo Veldt : Changes (1) ... {code:xml} bean id=connectionFactory class=org.apache.activemq.ActiveMQConnectionFactory property name=brokerURL value=tcp://localhost:6000 value=tcp://localhost:${tcp.port} / /bean {code} Full Content It looks the Spring example for the client misses the connectionManager definition. I had to add the following to the XML definitions. bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" property name="brokerURL" value="tcp://localhost:${tcp.port}" / /bean Stop watching space | Change email notification preferences View Online | Reply To This
[CONF] Apache Camel Tutorial-JmsRemoting
Tutorial-JmsRemoting Page comment added by Christian Mueller The configuration !-- Camel JMSProducer to be able to send messages to a remote Active MQ server -- bean id="jms" class="org.apache.activemq.camel.component.ActiveMQComponent" property name="brokerURL" value="tcp://localhost:${tcp.port}"/ /bean sets up the connection factory under the cover. In reply to a comment by Timo Veldt: It looks the Spring example for the client misses the connectionManager definition. I had to add the following to the XML definitions. Stop watching space | Change email notification preferences View Online | Reply To This
[CONF] Apache Camel Tutorial-JmsRemoting
Tutorial-JmsRemoting Page comment added by Timo Veldt It looks the Spring example for the client misses the connectionManager definition. I had to add the following to the XML definitions. bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" property name="brokerURL" value="tcp://localhost:6000" / /bean Stop watching space | Change email notification preferences View Online | Reply To This
[CONF] Apache Camel Tutorial-JmsRemoting
Tutorial-JmsRemoting Page edited by Claus Ibsen Changes (5) ... As we use spring xml configuration for the ActiveMQ JMS broker we need this dependency: {snippet:id=e2|lang=xml|url="" And dependencies for the AOP enable server example. These dependencies are of course only needed if you need full blown AOP stuff using AspejctJ with bytecode instrumentation. {snippet:id=e3|lang=xml|url="" h2. Writing the Server ... | jms bean | Creates the Camel JMS component | h3. AOP Enabled Server The example has an enhanced Server example that uses fullblown AspejctJ AOP for doing a audit tracking of invocations of the business service. We leverage Spring AOP support in the {{camel-server-aop.xml} configuration file. First we must declare the correct XML schemas to use: {snippet:id=e1|lang=xml|url="" Then we include all the existing configuration from the normal server example: {snippet:id=e2|lang=xml|url="" Then we enable the AspejctJ AOP auto proxy feature of Spring that will scan for classes annotated with the @Aspect annotation: {snippet:id=e3|lang=xml|url="" Then we define our Audit tracker bean that does the actual audit logging. Its also the class that is annotated with the @Aspect so Spring will pick this up, as the aspect. {snippet:id=e4|lang=xml|url="" And the gem is that we inject the AuditTracker aspect bean with a [Camel endpoint|Endpoint] that defines where the audit should be stored. Noticed how easy it is to setup as we have just defined an endpoint URI that is [file based|File], meaning that we stored the audit tracks as files. We can change this tore to any [Camel components|Components] as we wish. To store it on a JMS queue simply change the URI to *jms:queue:audit*. {snippet:id=e5|lang=xml|url="" And the full blown Aspejct for the audit tracker java code: {snippet:id=e1|lang=java|url="" h3. Run the Server ... {{mvn compile exec:java \-PCamelServer}} Or for the AOP enabled Server example: {{mvn compile exec:java \-PCamelServerAOP}} h2. Writing The Clients This sample has three clients demonstrating different Camel techniques for communication - CamelClient using the [ProducerTemplate] for Spring template style coding - CamelRemoting using Spring Remoting - CamelEndpoint using the Message Endpoint EIP pattern using a neutral Camel API ... And the CamelClient source code: {snippet:id=e1|lang=java|url="" The {{ProducerTemplate}} is retrieved from a Spring {{ApplicationContext}} and used to manually place a message on the numbers JMS queue. The {{requestBody}} method will use the exchange pattern (*ExchangePattern.InOut*) InOut, which states that the call should be synchronous, and that we will receive the caller expects a response. Before running the client be sure that both the ActiveMQ broker and the {{CamelServer}} are running. ... Full Content Tutorial on Spring Remoting with JMS ThanksThis tutorial was kindly donated to Apache Camel by Martin Gilday. Preface This tutorial aims to guide the reader through the stages of creating a project which uses Camel to facilitate the routing of messages from a JMS queue to a Spring service. The route works in a synchronous fashion returning a response to the client. Tutorial on Spring Remoting with JMS Preface Prerequisites Distribution About Create the Camel Project Update the POM with Dependencies Writing the Server Create the Spring Service Define the Camel Routes Configure Spring Run the Server Writing The Clients Client Using The ProducerTemplate Client Using Spring Remoting Client Using Message Endpoint EIP Pattern Run the Clients Using the Camel Maven Plugin Using Camel JMX See Also Prerequisites This tutorial uses Maven to setup the Camel project and for dependencies for artifacts. Distribution This sample is distributed with the Camel distribution as examples/camel-example-spring-jms. About This tutorial is a simple example that demonstrates more the fact how well Camel is seamless integrated with Spring to leverage the best of both worlds. This sample is client server solution using JMS messaging as the transport. The sample has two flavors of servers and also for clients demonstrating different techniques for easy communication. The Server is a JMS message broker that routes incoming messages to a business service that does computations on the received message and returns a response. The EIP patterns used in this sample are: Pattern Description Message Channel
[CONF] Apache Camel Tutorial-JmsRemoting
Tutorial-JmsRemoting Page edited by Claus Ibsen Tutorial on Spring Remoting with JMS ThanksThis tutorial was kindly donated to Apache Camel by Martin Gilday. Preface This tutorial aims to guide the reader through the stages of creating a project which uses Camel to facilitate the routing of messages from a JMS queue to a Spring service. The route works in a synchronous fashion returning a response to the client. Tutorial on Spring Remoting with JMS Preface Prerequisites Distribution About Create the Camel Project Update the POM with Dependencies Writing the Server Create the Spring Service Define the Camel Routes Configure Spring AOP Enabled Server Run the Server Writing The Clients Client Using The ProducerTemplate Client Using Spring Remoting Client Using Message Endpoint EIP Pattern Run the Clients Using the Camel Maven Plugin Using Camel JMX See Also Prerequisites This tutorial uses Maven to setup the Camel project and for dependencies for artifacts. Distribution This sample is distributed with the Camel distribution as examples/camel-example-spring-jms. About This tutorial is a simple example that demonstrates more the fact how well Camel is seamless integrated with Spring to leverage the best of both worlds. This sample is client server solution using JMS messaging as the transport. The sample has two flavors of servers and also for clients demonstrating different techniques for easy communication. The Server is a JMS message broker that routes incoming messages to a business service that does computations on the received message and returns a response. The EIP patterns used in this sample are: Pattern Description Message Channel We need a channel so the Clients can communicate with the server. Message The information is exchanged using the Camel Message interface. Message Translator This is where Camel shines as the message exchange between the Server and the Clients are text based strings with numbers. However our business service uses int for numbers. So Camel can do the message translation automatically. Message Endpoint It should be easy to send messages to the Server from the the clients. This is archived with Camels powerful Endpoint pattern that even can be more powerful combined with Spring remoting. The tutorial have clients using each kind of technique for this. Point to Point Channel We using JMS queues so there are only one receive of the message exchange Event Driven Consumer Yes the JMS broker is of course event driven and only reacts when the client sends a message to the server. We use the following Camel components: Component Description ActiveMQ We use Apache ActiveMQ as the JMS broker on the Server side Bean We use the bean binding to easily route the messages to our business service. This is a very powerful component in Camel. File In the AOP enabled Server we store audit trails as files. JMS Used for the JMS messaging Create the Camel Project For the purposes of the tutorial a single Maven project will be used for both the client and server. Ideally you would break your application down into the appropriate components. mvn archetype:create -DgroupId=org.example -DartifactId=CamelWithJmsAndSpring Update the POM with Dependencies First we need to have dependencies for the core Camel jars, its spring, jms components and finally ActiveMQ as the message broker. !-- required by both client and server -- dependency groupIdorg.apache.camel/groupId artifactIdcamel-core/artifactId /dependency dependency groupIdorg.apache.camel/groupId artifactIdcamel-jms/artifactId /dependency dependency groupIdorg.apache.camel/groupId artifactIdcamel-spring/artifactId /dependency dependency groupIdorg.apache.activemq/groupId artifactIdactivemq-camel/artifactId /dependency As we use spring xml configuration for the ActiveMQ JMS broker we need this dependency: !-- xbean is required for ActiveMQ broker configuration in the spring xml file -- dependency groupIdorg.apache.xbean/groupId artifactIdxbean-spring/artifactId /dependency And dependencies for the AOP enable server example. These dependencies are of course only needed if you need full blown AOP stuff using AspejctJ with bytecode instrumentation. !-- required jars for aspectj AOP support -- dependency groupIdorg.springframework/groupId artifactIdspring-aop/artifactId version${spring-version}/version /dependency dependency groupIdorg.aspectj/groupId artifactIdaspectjrt/artifactId version1.6.2/version /dependency dependency groupIdorg.aspectj/groupId artifactIdaspectjweaver/artifactId version1.6.2/version /dependency dependency groupIdcglib/groupId artifactIdcglib-nodep/artifactId version2.1_3/version