svn commit: r761197 - in /camel/branches/camel-1.x: ./ camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java components/camel-xmpp/src/test/resources/

2009-04-02 Thread ningjiang
Author: ningjiang
Date: Thu Apr  2 08:20:18 2009
New Revision: 761197

URL: http://svn.apache.org/viewvc?rev=761197view=rev
Log:
Merged revisions 761194 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk


  r761194 | ningjiang | 2009-04-02 15:56:51 +0800 (Thu, 02 Apr 2009) | 1 line
  
  CAMEL-1509 Made isStarted() better as Claus suggested


Modified:
camel/branches/camel-1.x/   (props changed)

camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java
camel/branches/camel-1.x/components/camel-xmpp/src/test/resources/   (props 
changed)

Propchange: camel/branches/camel-1.x/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Apr  2 08:20:18 2009
@@ -1 +1 @@
-/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175,755136,755487,756313,756348,756870,756939,757636,757693,757743,757865,758539,758563,758600,758617,758692,758990,759362,759453,759887,759931,760003,760890,760909,760937
+/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175,755136,755487,756313,756348,756870,756939,757636,757693,757743,757865,758539,758563,758600,758617,758692,758990,759362,759453,759887,759931,760003,760890,760909,760937,761194

Propchange: camel/branches/camel-1.x/
--
Binary property 'svnmerge-integrated' - no diff available.

Modified: 
camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java?rev=761197r1=761196r2=761197view=diff
==
--- 
camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java
 (original)
+++ 
camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/impl/ServiceSupport.java
 Thu Apr  2 08:20:18 2009
@@ -72,7 +72,7 @@
  * @return true if this service has been started
  */
 public boolean isStarted() {
-return started.get();
+return started.get()  !starting.get();
 }
 
 /**

Propchange: camel/branches/camel-1.x/components/camel-xmpp/src/test/resources/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Apr  2 08:20:18 2009
@@ -1 +1 @@
-/camel/trunk/components/camel-xmpp/src/test/resources:757693,757743,757865,758539,758563,758617,758692,758990,759362,759887,759931,760890,760909,760937
+/camel/trunk/components/camel-xmpp/src/test/resources:757693,757743,757865,758539,758563,758617,758692,758990,759362,759887,759931,760890,760909,760937,761194




[CONF] Apache Camel: Error Handler (page edited)

2009-04-02 Thread confluence










Page Edited :
CAMEL :
Error Handler



 
Error Handler
has been edited by Claus Ibsen
(Apr 02, 2009).
 

 
 (View changes)
 

Content:
Error Handler

Camel supports pluggable ErrorHandler strategies to deal with errors processing an Event Driven Consumer. An alternative is to specify the error handling directly in the DSL using the Exception Clause.

Some current implementations include


	DefaultErrorHandler is the default error handler in Camel 2.0 onwards. This error handler does not support a deal letter queue, it will propagate exceptions back to the caller, as if there where no error handler at all. It has a limited set of features.
	Dead Letter Channel which supports attempting to redeliver the message exchange a number of times before sending it to a dead letter endpoint
	LoggingErrorHandler for just catching and logging exceptions
	NoErrorHandler for no error handling
	Transaction for transactional error handling (Spring based). See the Transactional Client EIP pattern.



Camel 2.0 has new default error handler
In Camel 2.0 onwards there default error handler is changed from Dead Letter Channel to DefaultErrorHandler. This error handler does not support a dead letter queue and will return exceptions back to the caller. This is what you expects when working with regular Java that exceptions will be thrown back to the caller. This error handler supports a limited set of features. 

Introduction
For introduction and background material see Error handling in Camel. 

Exception Clause
Using Error Handler combined with Exception Clause is a very powerful ally. We encourage end-users to use this combination in your error handling strategies. See samples and Exception Clause. 

Transaction
If the route is transactional then the Dead Letter Channel is disabled. The exchange.isTransacted() is used to determine if an Exchange is transacted or not.
So if you are using transacted routes then you should configure the TransactionErrorHandler instread of DeadLetterChannel. See Transactional Client for further details and samples.

These error handlers can be applied in the DSL to an entire set of rules or a specific routing rule as we show in the next examples. Error handling rules are inherited on each routing rule within a single RouteBuilder

Short Summary of the provided Error Handlers

DefaultErrorHandler new in Camel 2.0

The DefaultErrorHandler is the new default error handler in Camel 2.0. It only supports a limited set of features such as catching exception and using the Exception Clause. It does not support redelivery, delays or the likes. It will propagate exceptions back to the original caller. It does not have any dead letter queue.

Dead Letter Channel

The Dead Letter Channel is the default error handler in Camel 1.x, which is automatically configured for you. By default Camel will redeliver at most 6 times using 1 second delay, and if the exchange failed it will be logged at ERROR level.

You can configure the default dead letter endpoint to use:

RouteBuilder builder = new RouteBuilder() {
public void configure() {
// using dead letter channel with a seda queue for errors
errorHandler(deadLetterChannel("seda:errors"));

// here is our route
from("seda:a").to("seda:b");
}
};


Logging Error Handler

The logging error handler will log (by default at ERROR level) whenever an uncaught exception is thrown. The logging category, logger and level may all be defined in the builder.


errorHandler(loggingErrorHandler("mylogger.name").level(LoggingLevel.INFO));


This would create an error handler which logs exceptions using the category mylogger.name and uses the level INFO for all log messages created.

from("seda:a").errorHandler(loggingErrorHandler("mylogger.name").level(LoggingLevel.DEBUG)).to("seda:b");


Loggers may also be defined for specific routes.

No Error Handler

The no error handler is to be used for disabling error handling. 

errorHandler(noErrorHandler());


Scopes
The error handler is scoped as either

	global
	per route specific
	or policy based (this applies for transactional exchanges only)



The following example shows how you can register a global error handler (in this case using the logging handler)

RouteBuilder builder = new RouteBuilder() {
public void configure() {
// use logging error handler
errorHandler(loggingErrorHandler("com.mycompany.foo"));

// here is our regular route
from("seda:a").to("seda:b");
}
};


The following example shows how you can register a route specific error handler; the customized logging handler is only registered for the route from Endpoint seda:a

RouteBuilder builder = new RouteBuilder() {
public void configure() {
// this route is using a nested logging error handler
from("seda:a")
   

[CONF] Apache Camel: HTTP (page edited)

2009-04-02 Thread confluence










Page Edited :
CAMEL :
HTTP



 
HTTP
has been edited by Claus Ibsen
(Apr 02, 2009).
 

 
 (View changes)
 

Content:
HTTP Component

The http: component provides HTTP based endpoints for consuming external HTTP resources (as a client to call external servers using HTTP).

URI format


http:hostname[:port][/resourceUri][?options]


Will default use port 80 for http and 443 for https. 

camel-http vs camel-jetty
You can only produce to endpoints generated by the HTTP component. Therefore it should never be used as input into your camel Routes. To bind/expose an HTTP endpoint via a http server as input to a camel route, you can use the Jetty Component

Options



 Name 
 Default Value 
 Description 


 throwException 
 true 
 Camel 2.0: Option to disable throwing the HttpOperationFailedException in case of failed responses from the remote server. This allows you to get all responses regardles of the HTTP status code. 


 httpBindingRef 
 null 
 Reference to a org.apache.camel.component.http.HttpBinding in the Registry. 


 username 
 null 
 Username for basic http authentication. 


 password 
 null 
 Password for basic http authentication. 


 httpClientConfigurerRef 
 null 
 Reference to a org.apache.camel.component.http.HttpClientConfigurer in the Registry. 


 httpClient.XXX 
 null 
 Setting options on the HttpClientParams. For instance httpClient.soTimeout(5000) will set the SO_TIMEOUT to 5 seconds. 



Message Headers

Camel 1.x


 Name 
 Type 
 Description 


 HttpProducer.HTTP_URI 
 String 
 Camel 1.5.1: URI to call. Will override existing URI set directly on the endpoint. Is set on the IN message. 


 HttpProducer.HTTP_RESPONSE_CODE 
 int 
 The http response code from the external server. Is 200 for OK. Is set on the OUT message. 


 HttpProducer.QUERY 
 String 
 URI parameters. Will override existing URI parameters set directly on the endpoint. Is set on the IN message. 



Camel 2.0


 Name 
 Type 
 Description 


 HttpConstants.HTTP_URI 
 String 
 URI to call. Will override existing URI set directly on the endpoint. Is set on the IN message. 


 HttpConstants.HTTP_PATH 
 String 
 Request URI's path. Is set on the IN message. 


 HttpConstants.HTTP_QUERY 
 String 
 URI parameters. Will override existing URI parameters set directly on the endpoint. Is set on the IN message. 


 HttpConstants.HTTP_CHARACTER_ENCODING 
 String 
 Character encoding. Is set on the IN message. 


 HttpConstants.HTTP_CONTENT_TYPE 
 String 
 Content type. Is set on the IN message. 


 HttpConstants.HTTP_RESPONSE_CODE 
 int 
 The http response code from the external server. Is 200 for OK. Is set on the OUT message. 



Message Body
Camel will store the http response from the external server on the OUT body. All headers from the IN message will be copied to the OUT message so headers is preserved during routing. 
Additionally Camel will add the http response headers as well to the OUT message.

Response code
Camel will handle according to the http response code:

	response code is between 100..299 then Camel regard it as a success response
	response code is between 300..399 then Camel regard it as a redirection was returned and will throw a HttpOperationFailedException with the information
	response code is 400+ then Camel regard it as a external server failure and will throw a HttpOperationFailedException with the information



throwException
The option throwException can be set to false to prevent the HttpOperationFailedException to be thrown for failed response codes. This allows you to get any response from the remote server.
There is a sample below demonstrating this.

HttpOperationFailedException
This exception contains the following information

	the http status code
	the http status line (text of the status code)
	redirect location if server returned a redirect
	responseBody as a java.io.InputStream if server provided a body as response



Calling using GET or POST
In Camel 1.5 the following algorithm is used to determine if either GET or POST http method should be used:
1. Use method provided in header
2. GET is query string is provided in header
3. GET if endpoint is configured with a query string
4. POST if there is data to send (body is not null)
5. GET otherwise

Configuring URI to call
You can set the http producer's URI directly form the endpoint URI. In the route below Camel will call our to the external server oldhost using HTTP.

from("direct:start")
	.to("http://oldhost");


And the equivalent spring sample:

camelContext xmlns="http://activemq.apache.org/camel/schema/spring"
  route
from uri="direct:start"/
to uri="http://oldhost"/
  /route
/camelContext


In Camel 1.5.1 you can override the http endpoint URI by adding a header with the key HttpProducer.HTTP_URI on the message.

from("direct:start")

svn commit: r761334 - in /camel/trunk/components/camel-http/src: main/java/org/apache/camel/component/http/HttpProducer.java test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java

2009-04-02 Thread davsclaus
Author: davsclaus
Date: Thu Apr  2 16:15:48 2009
New Revision: 761334

URL: http://svn.apache.org/viewvc?rev=761334view=rev
Log:
CAMEL-1504: HTTP_PATH header is now also used when building URI to call http 
service with. Applied patch with thanks to Mathis Schwuchow.

Added:

camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java
   (with props)
Modified:

camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java

Modified: 
camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java?rev=761334r1=761333r2=761334view=diff
==
--- 
camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
 (original)
+++ 
camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
 Thu Apr  2 16:15:48 2009
@@ -201,6 +201,19 @@
 uri = ((HttpEndpoint)getEndpoint()).getHttpUri().toString();
 }
 
+// append HTTP_PATH to HTTP_URI if it is provided in the header
+String path = exchange.getIn().getHeader(HttpConstants.HTTP_PATH, 
String.class);
+if (path != null) {
+// make sure that there is exactly one / between HTTP_URI and 
HTTP_PATH
+if (!uri.endsWith(/)) {
+uri = uri + /;
+}
+if (path.startsWith(/)) {
+path = path.substring(1);
+}
+uri = uri.concat(path);
+}
+
 HttpMethod method = methodToUse.createMethod(uri);
 
 if (queryString != null) {

Added: 
camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java?rev=761334view=auto
==
--- 
camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java
 (added)
+++ 
camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java
 Thu Apr  2 16:15:48 2009
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the License); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http;
+
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class HttpGetWithPathHeaderTest extends HttpGetTest {
+
+@Override
+protected RouteBuilder createRouteBuilder() throws Exception {
+return new RouteBuilder() {
+public void configure() {
+from(direct:start)
+.setHeader(HttpConstants.HTTP_PATH, constant(search))
+.setHeader(HttpConstants.HTTP_QUERY, 
constant(hl=enq=activemq))
+.to(http://www.google.com;).to(mock:results);
+}
+};
+}
+}

Propchange: 
camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java
--
svn:eol-style = native

Propchange: 
camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpGetWithPathHeaderTest.java
--
svn:keywords = Rev Date




[CONF] Apache Camel: Mail (comment added)

2009-04-02 Thread confluence










Comment Added :
CAMEL :
Re: Mail




Mail
commented on by Ryan Gardner
(Apr 02, 2009).


Comment:
Sending a multipart/alternative email

Sending a multipart/alternative email is a common way to send both a plain text version and a text/html version of an email at the same time. This allows clients which are not able to render HTML emails to still display the plain text version.

In Camel 1.6.1 you can specify an alternate body to be included setting the header CamelMailAlternateBody on the message prior to sending it. This should be set to a string which contains the plain text version of your email. 

Sending mail attachments inline

In some cases, you would like to send your attachments inline. Some mail clients support rendering inline attachments using Content-ID references (see http://www.ietf.org/rfc/rfc2111.txt ) like this: 

img src=""/  when the attached image has a tag "ContentID: 0...@boo.com". To do this in apache camel, name the attachment that you add to the message starting with the prefix "cid:" and configure the exchange to useInlineAttachments=true and the header will be added to the MIME body to specify the "ContentID: the part after the cid:" on the attachment to make this work. 

If you intend to send inline images and use this method to attach them, be sure to test this on the various email clients you intend to send email to.











Powered by
Atlassian Confluence
(Version: 2.2.9 Build:#527 Sep 07, 2006)
-
Bug/feature request

Unsubscribe or edit your notifications preferences








[CONF] Apache Camel: How does Camel compare to Synapse (page edited)

2009-04-02 Thread confluence










Page Edited :
CAMEL :
How does Camel compare to Synapse



 
How does Camel compare to Synapse
has been edited by James Strachan
(Apr 02, 2009).
 

 
 (View changes)
 

Content:
How does Camel compare to Synapse?


	the Camel community is way more active according to the nabble statistics (Synapse is inside the Apache Web Services bar) or by comparing Camel and Synapse on markmail.
	Camel is the default routing engine included in Apache ActiveMQ for Message Orientated middleware with EIP and Apache ServiceMix the ESB based around OSGi and JBI at Apache
	Camel is designed to work with pretty much all kinds of transport, in particular its been designed from the ground up to work nicely inside a web services stack, JMS or inside a JBI based ESB as well as working with any Data Format - not just SOAP - as well as implementing all the Enterprise Integration Patterns in both Java and Spring XML. When we first looked at Synapse it was based around Axis 2 and WS-* though apparently thats no longer the case.
	more detailed write up is here (with a slight Synapse bias since the author mostly uses Synapse 













Powered by
Atlassian Confluence
(Version: 2.2.9 Build:#527 Sep 07, 2006)
-
Bug/feature request

Unsubscribe or edit your notifications preferences








[CONF] Apache Camel: How does Camel compare to Synapse (page edited)

2009-04-02 Thread confluence










Page Edited :
CAMEL :
How does Camel compare to Synapse



 
How does Camel compare to Synapse
has been edited by James Strachan
(Apr 02, 2009).
 

 
 (View changes)
 

Content:
How does Camel compare to Synapse?

We are Camel developers so take what you read here with a pinch of salt. If you want to read a less biased comparison try reading this review which has a slight Synapse bias since the author mostly uses Synapse 

However we think the main differences are:


	the Camel community is way more active according to the nabble statistics (Synapse is inside the Apache Web Services bar) or by comparing Camel and Synapse on markmail
 .
	Camel is the default routing engine included in Apache ActiveMQ for Message Orientated middleware with EIP and Apache ServiceMix the ESB based around OSGi and JBI at Apache which are very popular too
 
	Camel is designed from the ground up around Enterprise Integration Patterns - having a EIP pattern language implemented in Java, Spring XML, Scala and Groovy as well as EIP Visualisations
	Camel is designed to work with pretty much all kinds of transport as well as working with any Data Format. When we first looked at Synapse it was based around Axis 2 and WS-* though apparently thats no longer the case.













Powered by
Atlassian Confluence
(Version: 2.2.9 Build:#527 Sep 07, 2006)
-
Bug/feature request

Unsubscribe or edit your notifications preferences








[CONF] Apache Camel: How does Camel compare to Synapse (page edited)

2009-04-02 Thread confluence










Page Edited :
CAMEL :
How does Camel compare to Synapse



 
How does Camel compare to Synapse
has been edited by James Strachan
(Apr 02, 2009).
 

 
 (View changes)
 

Content:
How does Camel compare to Synapse?

We are Camel developers so take what you read here with a pinch of salt. If you want to read a less biased comparison try reading this review which has a slight Synapse bias since the author mostly uses Synapse 

However we think the main differences are:


	the Camel community is way more active according to the nabble statistics (Synapse is inside the Apache Web Services bar) or by comparing Camel and Synapse on markmail
 .
	Camel is the default routing engine included in Apache ActiveMQ for Message Orientated middleware with EIP and Apache ServiceMix the ESB based around OSGi and JBI at Apache which are very popular too
 
	Camel is designed from the ground up around Enterprise Integration Patterns - having a EIP pattern language implemented in Java, Spring XML, Scala and Groovy as well as EIP Visualisations
	Camel is designed to work with pretty much all kinds of transport as well as working with any Data Format. When we first looked at Synapse it was based around Axis 2 and WS-* though apparently thats no longer the case.













Powered by
Atlassian Confluence
(Version: 2.2.9 Build:#527 Sep 07, 2006)
-
Bug/feature request

Unsubscribe or edit your notifications preferences








[CONF] Apache Camel: How does Camel compare to Synapse (page edited)

2009-04-02 Thread confluence










Page Edited :
CAMEL :
How does Camel compare to Synapse



 
How does Camel compare to Synapse
has been edited by James Strachan
(Apr 02, 2009).
 

 
 (View changes)
 

Content:
How does Camel compare to Synapse?

We are Camel developers so take what you read here with a pinch of salt. If you want to read a less biased comparison try reading this review which has a slight Synapse bias since the author mostly uses Synapse 

However we think the main differences are:


	the Camel community is way more active according to the nabble statistics (Synapse is inside the Apache Web Services bar) or by comparing Camel and Synapse on markmail.
	Camel is the default routing engine included in Apache ActiveMQ for Message Orientated middleware with EIP and Apache ServiceMix the ESB based around OSGi and JBI at Apache - both of which are very popular too
	Camel is designed from the ground up around Enterprise Integration Patterns - having a EIP pattern language implemented in Java, Spring XML, Scala and Groovy as well as EIP Visualisations
	Camel is designed to work with pretty much all kinds of transport as well as working with any Data Format. When we first looked at Synapse it was based around Axis 2 and WS-* though apparently thats no longer the case.













Powered by
Atlassian Confluence
(Version: 2.2.9 Build:#527 Sep 07, 2006)
-
Bug/feature request

Unsubscribe or edit your notifications preferences








[CONF] Apache Camel: Spring Java Config Example (page created)

2009-04-02 Thread confluence










Page Created :
CAMEL :
Spring Java Config Example



 
Spring Java Config Example
has been created by willem jiang
(Apr 02, 2009).
 

Content:
Spring Java Config Example 

The spring java config example is a simple refactor of the spring example since Camel 2.0 to show how to use the Spring JavaConfig approach to working with Camel. In this example we just write RouteBuilder implementations, then Camel will find it through your configuration.

To run the example we use the Camel Maven Plugin. For example from the source or binary distribution the following should work


cd examples/camel-example-spring-javaconfig
mvn camel:run


You need to add camel-spring-javaconfig dependency into pom.xml and also set the configure class or base package in the camel plugin configuration. 

dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-spring/artifactId
/dependency

dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-spring-javaconfig/artifactId
/dependency


Here is the configuration for camel plugin.


plugins
  !-- Allows the routes to be run via 'mvn camel:run' --
  plugin
groupIdorg.apache.camel/groupId
artifactIdcamel-maven-plugin/artifactId
version${pom.version}/version
configuration
duration5s/duration
configClassesorg.apache.camel.example.spring.javaconfig.MyRouteConfig/configClasses
!--You could set the base package directory and let spring to find the config classes for you 
basedPackagesorg.apache.camel.example.spring.javaconfig/basedPackages 
 --
/configuration
  /plugin
/plugins


What this does is boot up the Spring ApplicationContext defined in the file MyRouteConfig class on the classpath. This is a regular Java file which has the Spring JavaConfig annotation to configure a CamelContext.


/**
 * A simple example router from a file system to an ActiveMQ queue and then to a file system
 *
 * @version $Revision$
 */
@Configuration
public class MyRouteConfig extends SingleRouteCamelConfiguration {
/**
 * Allow this route to be run as an application
 *
 * @param args
 */
public static void main(String[] args) {
new Main().run(args);
}

@Override
// setup the ActiveMQ component and regist it into the camel context
public void setupCamelContext(CamelContext camelContext) throws Exception {
JmsComponent answer = new JmsComponent();
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL("vm://localhost?broker.persistent=falsebroker.useJmx=false");
answer.setConnectionFactory(connectionFactory);
camelContext.addComponent("jms", answer);
}


public static class SomeBean {

public void someMethod(String body) {
System.out.println("Received: " + body);
}
}

@Bean
@Override
// you can confige the route rule with Java DSL here
public RouteBuilder route() {
return new RouteBuilder() {
public void configure() {
// populate the message queue with some messages
from("file:src/data?noop=true").
to("jms:test.MyQueue");

from("jms:test.MyQueue").
to("file://target/test?noop=true");

// set up a listener on the file component
from("file://target/test?noop=true").
bean(new SomeBean());
}
};
}
}


In the method of setupCamelContext(CamelContext camelContext), we setup the JMS component's connection factory and register the component into the camelcontext. You can override this method if you want to setup the another connection factory or start up a JMS broker here.

You can write the route rule with Java DSL in the route() method.

This approach, of using Java code to write the routes in the DSL and Spring will help your configure the Camel context as the Spring Java Config Example shows. 












Powered by
Atlassian Confluence
(Version: 2.2.9 Build:#527 Sep 07, 2006)
-
Bug/feature request

Unsubscribe or edit your notifications preferences