[CONF] Apache Camel Walk through an Example

2012-09-08 Thread confluence







Walk through an Example
Page edited by Christian Mueller


Comment:
Removed the deprecated Camel 1.x documentations


 Changes (1)
 




...
 If you have the time then use 5 more minutes to [Walk through another example] that demonstrates the Spring DSL (XML based) routing. 
 {note:title=Camel 1.4.0 change} In Camel 1.4.0, CamelTemplate has been marked as @deprecated. ProducerTemplate should be used instead and its created from the CamelContext itself. {code} ProducerTemplate template = context.createProducerTemplate(); {code} {note} 


Full Content

Walk through an Example Code

This mini-guide takes you through the source code of a simple example.

Camel can be configured either by using Spring or directly in Java - which this example does.

This example is available in the examples\camel-example-jms-file directory of the Camel distribution.

We start with creating a CamelContext - which is a container for Components, Routes etc:


CamelContext context = new DefaultCamelContext();



There is more than one way of adding a Component to the CamelContext. You can add components implicitly - when we set up the routing - as we do here for the FileComponent:


context.addRoutes(new RouteBuilder() {
public void configure() {
from("test-jms:queue:test.queue").to("file://test");
}
});




or explicitly - as we do here when we add the JMS Component:


ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
// Note we can explicit name the component
context.addComponent("test-jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));



The above works with any JMS provider. If we know we are using ActiveMQ we can use an even simpler form using the activeMQComponent() method while specifying the brokerURL used to connect to ActiveMQ 


camelContext.addComponent("activemq", activeMQComponent("vm://localhost?broker.persistent=false"));



In normal use, an external system would be firing messages or events directly into Camel through one if its Components  but we are going to use the ProducerTemplate which is a really easy way for testing your configuration:


ProducerTemplate template = context.createProducerTemplate();



Next you must start the camel context. If you are using Spring to configure the camel context this is automatically done for you; though if you are using a pure Java approach then you just need to call the start() method



camelContext.start();



This will start all of the configured routing rules.

So after starting the CamelContext, we can fire some objects into camel:


for (int i = 0; i  10; i++) {
template.sendBody("test-jms:queue:test.queue", "Test Message: " + i);
}




What happens?

From the ProducerTemplate - we send objects (in this case text) into the CamelContext to the Component test-jms:queue:test.queue. These text objects will be converted automatically into JMS Messages and posted to a JMS Queue named test.queue. When we set up the Route, we configured the FileComponent to listen of the test.queue. 

The File FileComponent will take messages off the Queue, and save them to a directory named test. Every message will be saved in a file that corresponds to its destination and message id.

Finally, we configured our own listener in the Route - to take notifications from the FileComponent and print them out as text.

That's it!

If you have the time then use 5 more minutes to Walk through another example that demonstrates the Spring DSL (XML based) routing.



Change Notification Preferences

View Online
|
View Changes
|
Add Comment









[CONF] Apache Camel Parameter Binding Annotations

2012-09-08 Thread confluence







Parameter Binding Annotations
Page edited by Christian Mueller


Comment:
Removed the deprecated Camel 1.x documentations


 Changes (4)
 




...
|| Annotation || Meaning || Parameter || | [@Body|http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Body.html] | To bind to an inbound message body | | 
| [@ExchangeException|http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/ExchangeException.html] | To bind to an Exception set on the exchange (*Camel 2.0*) | | 
| [@Header|http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Header.html] | To bind to an inbound message header | String name of the header | | [@Headers|http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Headers.html] | To bind to the Map of the inbound message headers | | 
...
| [@Property|http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Property.html] | To bind to a named property on the exchange | String name of the property | | [@Properties|http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Properties.html] | To bind to the property map on the exchange | | 
| [@Handler|http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Handler.html] | *Camel 2.0:* Not part as a type parameter but stated in this table anyway to spread the good word that we have this annotation in Camel now. See more at [Bean Binding]. | | 
 
The follow annotations {{@Headers}}, {{@OutHeaders}} and {{@Properties}} binds to the backing {{java.util.Map}} so you can alter the content of these maps directly, for instance using the {{put}} method to add a new entry. See the OrderService class at [Exception Clause] for such an example. You can use {{@Header(myHeader)}} and {{@Property(myProperty)}} to access the backing {{java.util.Map}}. 
 
Since *Camel 2.0*, you can use {{@Header(myHeader)}} and {{@Property(myProperty)}} instead of {{@Header(name=myHeader)}} and {{@Property(name=myProperty)}} as *Camel 1.x* does.  
h3. Example In this example below we have a @Consume consumer (like message driven) that consumes JMS messages from the activemq queue. We use the @Header and @Body parameter binding annotations to bind from the JMSMessage to the method parameters. 
...


Full Content

Parameter Binding Annotations

camel-coreThe annotations below are all part of camel-core and thus does not require camel-spring or Spring. These annotations can be used with the Bean component or when invoking beans in the DSL

Annotations can be used to define an _expression_ or to extract various headers, properties or payloads from a Message when invoking a bean method (see Bean Integration for more detail of how to invoke bean methods) together with being useful to help disambiguate which method to invoke.

If no annotations are used then Camel assumes that a single parameter is the body of the message. Camel will then use the Type Converter mechanism to convert from the _expression_ value to the actual type of the parameter.

The core annotations are as follows




 Annotation 
 Meaning 
 Parameter 


 @Body 
 To bind to an inbound message body 



 @ExchangeException 
 To bind to an Exception set on the exchange 



 @Header 
 To bind to an inbound message header 
 String name of the header 


 @Headers 
 To bind to the Map of the inbound message headers 



 @OutHeaders 
 To bind to the Map of the outbound message headers 



 @Property 
 To bind to a named property on the exchange 
 String name of the property 


 @Properties 
 To bind to the property map on the exchange 



 @Handler 
 Not part as a type parameter but stated in this table anyway to spread the good word that we have this annotation in Camel now. See more at Bean Binding. 






The follow annotations @Headers, @OutHeaders and @Properties binds to the backing java.util.Map so you can alter the content of these maps directly, for instance using the put method to add a new entry. See the OrderService class at Exception Clause for such an example. You can use @Header("myHeader") and @Property("myProperty") to access the backing java.util.Map.

Example
In this example below we have a @Consume consumer (like message driven) that consumes JMS messages from the activemq queue. We use the @Header and @Body parameter binding annotations to bind from the JMSMessage to the method parameters.



public class Foo {
	
@Consume(uri = "activemq:my.queue")
public void doSomething(@Header("JMSCorrelationID") String correlationID, @Body String body) {
		// process the inbound message here
}

}



In the 

[CONF] Apache Camel RecipientList Annotation

2012-09-08 Thread confluence







RecipientList Annotation
Page edited by Christian Mueller


Comment:
Removed the deprecated Camel 1.x documentations


 Changes (4)
 




h2. @RecipientList Annotation  
As of 1.5.0 we now We support the use of @RecipientList on a bean method to easily create a dynamic [Recipient List] using a Java method. 
 h3. Simple Example using @Consume and @RecipientList 
...
   xmlns:xsi=http://www.w3.org/2001/XMLSchema-instancexsi:schemaLocation= 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/beans/spring-beans.xsd 
   http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd 
   http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd 
  
...


Full Content

@RecipientList Annotation

We support the use of @RecipientList on a bean method to easily create a dynamic Recipient List using a Java method.

Simple Example using @Consume and @RecipientList



package com.acme.foo;

public class RouterBean {

@Consume(uri = "activemq:foo")
@RecipientList
public String[] route(String body) {
return new String[]{"activemq:bar", "activemq:whatnot"};
}
}



For example if the above bean is configured in Spring when using a camelContext element as follows



?xml version="1.0" encoding="UTF-8"?
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.xsd
   http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
"

  camelContext xmlns="http://activemq.apache.org/camel/schema/spring"/

  bean id="myRecipientList" class="com.acme.foo.RouterBean"/

/beans



then a route will be created consuming from the foo queue on the ActiveMQ component which when a message is received the message will be forwarded to the endpoints defined by the result of this method call - namely the bar and whatnot queues.

How it works

The return value of the @RecipientList method is  converted to either a java.util.Collection / java.util.Iterator or array of objects where each element is converted to an Endpoint or a String, or if you are only going to route to a single endpoint then just return either an Endpoint object or an object that can be converted to a String. So the following methods are all valid 



@RecipientList 
public String[] route(String body) { ... }

@RecipientList 
public ListString route(String body) { ... }

@RecipientList 
public Endpoint route(String body) { ... }

@RecipientList 
public Endpoint[] route(String body) { ... }

@RecipientList 
public CollectionEndpoint route(String body) { ... }

@RecipientList 
public URI route(String body) { ... }

@RecipientList 
public URI[] route(String body) { ... }



Then for each endpoint or URI the message is forwarded a separate copy to that endpoint. 

You can then use whatever Java code you wish to figure out what endpoints to route to; for example you can use the Bean Binding annotations to inject parts of the message body or headers or use _expression_ values on the message.

More Complex Example Using DSL

In this example we will use more complex Bean Binding, plus we will use a separate route to invoke the Recipient List



public class RouterBean2 {

@RecipientList
public String route(@Header("customerID") String custID String body) {
	if (custID == null)  return null;
return "activemq:Customers.Orders." + custID;
}
}

public class MyRouteBuilder extends RouteBuilder {
protected void configure() {
from("activemq:Orders.Incoming").recipientList(bean("myRouterBean", "route"));
}
}




Notice how we are injecting some headers or expressions and using them to determine the recipients using Recipient List EIP.
See the Bean Integration for more details.




Change Notification Preferences

View Online
|
View Changes
|
Add Comment









[CONF] Apache Camel Camel Test

2012-09-08 Thread confluence







Camel Test
Page edited by Christian Mueller


 Changes (1)
 




h2. Camel Test  
As a simple alternative to using [Spring Testing] or [Guice] the *camel-test* module was introduced into the Camel 2.0 trunk so you can perform powerful [Testing] of your [Enterprise Integration Patterns] easily. 
 {info:tile=JUnit or TestNG} 
...


Full Content

Camel Test

As a simple alternative to using Spring Testing or Guice the camel-test module was introduced so you can perform powerful Testing of your Enterprise Integration Patterns easily.

The camel-test JAR is using JUnit. There is an alternative camel-testng JAR (Camel 2.8 onwards) using the TestNG test framework.

Adding to your pom.xml

To get started using Camel Test you will need to add an entry to your pom.xml

JUnit


dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-test/artifactId
  version${camel-version}/version
  scopetest/scope
/dependency



TestNG

Available as of Camel 2.8


dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-testng/artifactId
  version${camel-version}/version
  scopetest/scope
/dependency



You might also want to add slf4j and log4j to ensure nice logging messages (and maybe adding a log4j.properties file into your src/test/resources directory).



dependency
  groupIdorg.slf4j/groupId
  artifactIdslf4j-log4j12/artifactId
  scopetest/scope
/dependency
dependency
  groupIdlog4j/groupId
  artifactIdlog4j/artifactId
  scopetest/scope
/dependency



Writing your test

You firstly need to derive from the class CamelTestSupport(org.apache.camel.test.CamelTestSupport, org.apache.camel.test.junit4.CamelTestSupport, or org.apache.camel.testng.CamelTestSupport for JUnit 3.x, JUnit 4.x, and TestNG, respectively)and typically you will need to override the createRouteBuilder() orcreateRouteBuilders()method to create routes to be tested.

Here is an example.


public class FilterTest extends CamelTestSupport {

@EndpointInject(uri = "mock:result")
protected MockEndpoint resultEndpoint;

@Produce(uri = "direct:start")
protected ProducerTemplate template;

@Test
public void testSendMatchingMessage() throws Exception {
String expectedBody = "matched/";

resultEndpoint.expectedBodiesReceived(expectedBody);

template.sendBodyAndHeader(expectedBody, "foo", "bar");

resultEndpoint.assertIsSatisfied();
}

@Test
public void testSendNotMatchingMessage() throws Exception {
resultEndpoint.expectedMessageCount(0);

template.sendBodyAndHeader("notMatched/", "foo", "notMatchedHeaderValue");

resultEndpoint.assertIsSatisfied();
}

@Override
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
}
};
}
}



Notice how you can use the various Camel binding and injection annotations to inject individual Endpoint objects - particularly the Mock endpoints which are very useful for Testing. Also you can inject producer objects such as ProducerTemplate or some application code interface for sending messages or invoking services.

Features Provided by CamelTestSupport

The various CamelTestSupport classes provide a standard set of behaviors relating to the CamelContext used to host the route(s) under test. The classes provide a number of methods that allow a test to alter the configuration of the CamelContext used. The following table describes the available customization methods and the default behavior of tests that are built from aCamelTestSupport class.



 Method Name 
 Description 
 Default Behavior 


 boolean isUseRouteBuilder() 
 If the route builders from returned fromcreateRouteBuilder() or createRouteBuilders() should be added to the CamelContext used in the test should be started. 
 Returns true. createRouteBuilder()orcreateRouteBuilders() are invoked and the CamelContext is started automatically. 


 boolean isUseAdviceWith()  
 If the CamelContext use in the test should be automatically started before test methods are invoked. 
Override when using advice withand return true. This helps in knowing the adviceWith is to be used, and theCamelContextwill not be started beforethe advice with takes place. This delay helps by ensuring the advice with has been property setup before theCamelContextis started.
Its important to start the CamelContext manually from the unit test after you are done doing all the advice with.
 
 Returns false. the CamelContext is started automatically before test methods are invoked. 


 boolean isCreateCamelContextPerClass()  
 SeeSetup CamelContext once per class, or per every test 

[CONF] Apache Camel Guice

2012-09-08 Thread confluence







Guice
Page edited by Christian Mueller


Comment:
Removed the deprecated Camel 1.x documentations


 Changes (1)
 




h2. Camel Guice  
As of 1.5 we now We have support for [Google Guice|http://code.google.com/p/google-guice/] as a dependency injection framework. To use it just be dependent on *camel-guice.jar* which also depends on [the following jars|http://activemq.apache.org/camel/maven/camel-guice/dependencies.html]. 
 h3. Dependency Injecting Camel with Guice 
...


Full Content

Camel Guice

We have support for Google Guice as a dependency injection framework. To use it just be dependent on camel-guice.jar which also depends on the following jars.

Dependency Injecting Camel with Guice

The GuiceCamelContext is designed to work nicely inside Guice. You then need to bind it using some Guice Module.

The camel-guice library comes with a number of reusable Guice Modules you can use if you wish - or you can bind the GuiceCamelContext yourself in your own module.


	CamelModule is the base module which binds the GuiceCamelContext but leaves it up you to bind the RouteBuilder instances
	CamelModuleWithRouteTypes extends CamelModule so that in the constructor of the module you specify the RouteBuilder classes or instances to use
	CamelModuleWithMatchingRoutes extends CamelModule so that all bound RouteBuilder instances will be injected into the CamelContext or you can supply an optional Matcher to find RouteBuilder instances matching some kind of predicate.



So you can specify the exact RouteBuilder instances you want



Injector injector = Guice.createInjector(new CamelModuleWithRouteTypes(MyRouteBuilder.class, AnotherRouteBuilder.class));
// if required you can lookup the CamelContext
CamelContext camelContext = injector.getInstance(CamelContext.class);



Or inject them all



Injector injector = Guice.createInjector(new CamelModuleWithRouteTypes());
// if required you can lookup the CamelContext
CamelContext camelContext = injector.getInstance(CamelContext.class);



You can then use Guice in the usual way to inject the route instances or any other dependent objects.

Bootstrapping with JNDI

A common pattern used in J2EE is to bootstrap your application or root objects by looking them up in JNDI. This has long been the approach when working with JMS for example - looking up the JMS ConnectionFactory in JNDI for example.

You can follow a similar pattern with Guice using the GuiceyFruit JNDI Provider which lets you bootstrap Guice from a jndi.properties file which can include the Guice Modules to create along with environment specific properties you can inject into your modules and objects.

If the jndi.properties is conflict with other component, you can specify the jndi properties file name in the Guice Main with option -j or -jndiProperties with the properties file location to let Guice Main to load right jndi properties file.

Configuring Component, Endpoint or RouteBuilder instances

You can use Guice to dependency inject whatever objects you need to create, be it an Endpoint, Component, RouteBuilder or arbitrary bean used within a route. 

The easiest way to do this is to create your own Guice Module class which extends one of the above module classes and add a provider method for each object you wish to create. A provider method is annotated with @Provides as follows



public class MyModule extends CamelModuleWithMatchingRoutes {

@Provides
@JndiBind("jms")
JmsComponent jms(@Named("activemq.brokerURL") String brokerUrl) {
return JmsComponent.jmsComponent(new ActiveMQConnectionFactory(brokerUrl));
}
}



You can optionally annotate the method with @JndiBind to bind the object to JNDI at some name if the object is a component, endpoint or bean you wish to refer to by name in your routes.

You can inject any environment specific properties (such as URLs, machine names, usernames/passwords and so forth) from the jndi.properties file easily using the @Named annotation as shown above. This allows most of your configuration to be in Java code which is typesafe and easily refactorable - then leaving some properties to be environment specific (the jndi.properties file) which you can then change based on development, testing, production etc.


Creating multiple RouteBuilder instances per type

It is sometimes useful to create multiple instances of a particular RouteBuilder with different configurations.

To do this just create multiple provider methods for each configuration; or create a single provider method that returns a collection of RouteBuilder instances.

For example



import org.apache.camel.guice.CamelModuleWithMatchingRoutes;
import com.google.common.collect.Lists;

public class MyModule extends 

[CONF] Apache Camel Asynchronous Processing

2012-09-08 Thread confluence







Asynchronous Processing
Page edited by Christian Mueller


Comment:
Removed the deprecated Camel 1.x documentations


 Changes (1)
 




...
 {info:title=Supported versions} 
The information on this page applies for the Camel 1.x and Camel 2.4 onwards. In Before Camel 1.x 2.4 the asynchronous processing is only implemented for [JBI] where as in Camel 2.4 onwards we have implemented it in many other areas. See more at [Asynchronous Routing Engine]. 
{info}  
...


Full Content

Asynchronous Processing

Overview

Supported versionsThe information on this page applies for Camel 2.4 onwards. Before Camel 2.4 the asynchronous processing is only implemented for JBI where as in Camel 2.4 onwards we have implemented it in many other areas. See more at Asynchronous Routing Engine.

Camel supports a more complex asynchronous processing model.  The asynchronous processors implement the AsyncProcessor interface which is derived from the more synchronous Processor interface.  There are advantages and disadvantages when using asynchronous processing when compared to using the standard synchronous processing model.

Advantages:

	Processing routes that are composed fully of asynchronous processors do not use up threads waiting for processors to complete on blocking calls.  This can increase the scalability of your system by reducing the number of threads needed to process the same workload.
	Processing routes can be broken up into SEDA processing stages where different thread pools can process the different stages.  This means that your routes can be processed concurrently.



Disadvantages:

	Implementing asynchronous processors is more complex than implementing the synchronous versions.



When to Use

We recommend that processors and components be implemented the more simple synchronous APIs unless you identify a performance of scalability requirement that dictates otherwise.  A Processor whose process() method blocks for a long time would be good candidates for being converted into an asynchronous processor.

Interface Details



public interface AsyncProcessor extends Processor {
   boolean process(Exchange exchange, AsyncCallback callback);
}



The AsyncProcessor defines a single process() method which is very similar to it's synchronous Processor.process() brethren.  Here are the differences:

	A non-null AsyncCallback MUST be supplied which will be notified when the exchange processing is completed.
	It MUST not throw any exceptions that occurred while processing the exchange.  Any such exceptions must be stored on the exchange's Exception property.
	It MUST know if it will complete the processing synchronously or asynchronously.  The method will return true if it does complete synchronously, otherwise it returns false.
	When the processor has completed processing the exchange, it must call the callback.done(boolean sync) method.  The sync parameter MUST match the value returned by the process() method.



Implementing Processors that Use the AsyncProcessor API

All processors, even synchronous processors that do not implement the AsyncProcessor interface, can be coerced to implement the AsyncProcessor interface.  This is usually done when you are implementing a Camel component consumer that supports asynchronous completion of the exchanges that it is pushing through the Camel routes.  Consumers are provided a Processor object when created.  All Processor object can be coerced to a AsyncProcessor using the following API:



Processor processor = ...
AsyncProcessor asyncProcessor = AsyncProcessorTypeConverter.convert(processor);



For a route to be fully asynchronous and reap the benefits to lower Thread usage, it must start with the consumer implementation making use of the asynchronous processing API.  If it called the synchronous process() method instead, the consumer's thread would be forced to be blocked and in use for the duration that it takes to process the exchange.

It is important to take note that just because you call the asynchronous API, it does not mean that the processing will take place asynchronously.  It only allows the possibility that it can be done without tying up the caller's thread.  If the processing happens asynchronously is dependent on the configuration of the Camel route.

Normally, the the process call is passed in an inline inner AsyncCallback class instance which can reference the exchange object that was declared final.  This allows it  to finish up any post processing that is needed when the called processor is done processing the exchange.  See below for an example.



final Exchange exchange = ...
AsyncProcessor asyncProcessor = ...
asyncProcessor.process(exchange, new AsyncCallback() {

[CONF] Apache Camel Castor

2012-09-08 Thread confluence







Castor
Page edited by Christian Mueller


 Changes (1)
 




...
  groupIdorg.apache.camel/groupId   artifactIdcamel-castor/artifactId 
version2.1.0/version versionx.x.x/version 
/dependency {code} 


Full Content

Castor
Available as of Camel 2.1

Castor is a Data Format which uses the Castor XML library to unmarshal an XML payload into Java objects or to marshal Java objects into an XML payload.

As usually you can use either Java DSL or Spring XML to work with Castor Data Format. 

Using the Java DSL


from("direct:order").
  marshal().castor().
  to("activemq:queue:order");



For example the following uses a named DataFormat of Castor which uses default Castor data binding features.



CastorDataFormat castor = new CastorDataFormat ();

from("activemq:My.Queue").
  unmarshal(castor).
  to("mqseries:Another.Queue");





If you prefer to use a named reference to a data format which can then be defined in your Registry such as via your Spring XML file. e.g.



from("activemq:My.Queue").
  unmarshal("mycastorType").
  to("mqseries:Another.Queue");





If you want to override default mapping schema by providing a mapping file you can set it as follows.



CastorDataFormat castor = new CastorDataFormat ();
castor.setMappingFile("mapping.xml");




Also if you want to have more control on Castor Marshaller and Unmarshaller you can access them as below.



castor.getMarshaller();
castor.getUnmarshaller();





Using Spring XML
The following example shows how to use Castor to unmarshal using Spring configuring the castor data type



camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"
  route
from uri="direct:start"/
unmarshal
  castor validation="true" /
/unmarshal
to uri="mock:result"/
  /route
/camelContext



This example shows how to configure the data type just once and reuse it on multiple routes. You have to set the castor element directly in camelContext.



camelContext
camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"
  dataFormats
castor id="myCastor"/
  /dataFormats

  route
from uri="direct:start"/
marshal ref="myCastor"/
to uri="direct:marshalled"/
  /route
  route
from uri="direct:marshalled"/
unmarshal ref="myCastor"/
to uri="mock:result"/
  /route

/camelContext




Options
Castor supports the following options




 Option 
 Type 
 Default 
 Description 


 encoding 
 String 
 UTF-8 
 Encoding to use when marshalling an Object to XML 


 validation 
 Boolean 
 false 
 Whether validation is turned on or off. 


 mappingFile 
 String 
 null 
 Path to a Castor mapping file to load from the classpath. 


 packages 
 String[] 
 null 
 Add additional packages to Castor XmlContext 


 classNames 
 String[] 
 null 
 Add additional class names to Castor XmlContext 





Dependencies

To use Castor in your camel routes you need to add the a dependency on camel-castor which implements this data format. 

If you use maven you could just add the following to your pom.xml, substituting the version number for the latest  greatest release (see the download page for the latest versions).



dependency
  groupIdorg.apache.camel/groupId
  artifactIdcamel-castor/artifactId
  versionx.x.x/version
/dependency





Change Notification Preferences

View Online
|
View Changes
|
Add Comment









[CONF] Apache Camel Flatpack

2012-09-08 Thread confluence







Flatpack
Page edited by Christian Mueller


Comment:
Removed the deprecated Camel 1.x documentations


 Changes (1)
 




...
 h3. Header and Trailer records 
In Camel 1.5 onwards the The header and trailer notions in Flatpack are supported. However, you *must* use fixed record IDs: 
* {{header}} for the header record (must be lowercase) * {{trailer}} for the trailer record (must be lowercase) 
...


Full Content

Flatpack Component

The Flatpack component supports fixed width and delimited file parsing via the FlatPack library.
Notice: This component only supports consuming from flatpack files to Object model. You can not (yet) write from Object model to flatpack format.

Maven users will need to add the following dependency to their pom.xml for this component:


dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-flatpack/artifactId
versionx.x.x/version
!-- use the same version as your Camel core version --
/dependency



URI format



flatpack:[delim|fixed]:flatPackConfig.pzmap.xml[?options]



Or for a delimited file handler with no configuration file just use



flatpack:someName[?options]



You can append query options to the URI in the following format, ?option=valueoption=value...

URI Options



 Name 
 Default Value 
 Description 


 delimiter 
 , 
 The default character delimiter for delimited files.


 textQualifier 
 " 
 The text qualifier for delimited files.


 ignoreFirstRecord 
 true 
 Whether the first line is ignored for delimited files (for the column headers).


 splitRows 
 true 
 The component can either process each row one by one or the entire content at once. 


 allowShortLines 
 false 
 Camel 2.9.3: Allows for lines to be shorter than expected and ignores the extra characters. 


 ignoreExtraColumns 
 false 
 Camel 2.9.3: Allows for lines to be longer than expected and ignores the extra characters. 





Examples


	flatpack:fixed:foo.pzmap.xml creates a fixed-width endpoint using the foo.pzmap.xml file configuration.
	flatpack:delim:bar.pzmap.xml creates a delimited endpoint using the bar.pzmap.xml file configuration.
	flatpack:foo creates a delimited endpoint called foo with no file configuration.



Message Headers
Camel will store the following headers on the IN message:



 Header 
 Description 


 camelFlatpackCounter 
 The current row index. For splitRows=false the counter is the total number of rows. 





Message Body
The component delivers the data in the IN message as a org.apache.camel.component.flatpack.DataSetList object that has converters for java.util.Map or java.util.List.
Usually you want the Map if you process one row at a time (splitRows=true). Use List for the entire content (splitRows=false), where each element in the list is a Map.
Each Map contains the key for the column name and its corresponding value.

For example to get the firstname from the sample below:


  Map row = exchange.getIn().getBody(Map.class);
  String firstName = row.get("FIRSTNAME");



However, you can also always get it as a List (even for splitRows=true). The same example:


  List data = ""
  Map row = (Map)data.get(0);
  String firstName = row.get("FIRSTNAME");



Header and Trailer records
The header and trailer notions in Flatpack are supported. However, you must use fixed record IDs:

	header for the header record (must be lowercase)
	trailer for the trailer record (must be lowercase)



The example below illustrates this fact that we have a header and a trailer. You can omit one or both of them if not needed. 


RECORD id="header" startPosition="1" endPosition="3" indicator="HBT"
COLUMN name="INDICATOR" length="3"/
COLUMN name="DATE" length="8"/
/RECORD

COLUMN name="FIRSTNAME" length="35" /
COLUMN name="LASTNAME" length="35" /
COLUMN name="ADDRESS" length="100" /
COLUMN name="CITY" length="100" /
COLUMN name="STATE" length="2" /
COLUMN name="ZIP" length="5" /

RECORD id="trailer" startPosition="1" endPosition="3" indicator="FBT"
COLUMN name="INDICATOR" length="3"/
COLUMN name="STATUS" length="7"/
/RECORD




Using the endpoint

A common use case is sending a file to this endpoint for further processing in a separate route. For example:



  camelContext xmlns="http://activemq.apache.org/camel/schema/spring"
route
  from uri="file://someDirectory"/
  to uri="flatpack:foo"/
/route

route
  from uri="flatpack:foo"/
  ...
/route
  /camelContext



You can also convert the payload of each message created to a Map for easy Bean Integration

Flatpack DataFormat
The Flatpack component ships with the Flatpack data format that can be used to format between fixed width or 

[CONF] Apache Camel JDBC

2012-09-08 Thread confluence







JDBC
Page edited by Christian Mueller


Comment:
Removed the deprecated Camel 1.x documentations


 Changes (2)
 




...
 || Name || Default Value || Description || 
| {{readSize}} | {{0}} / {{2000}} | The default maximum number of rows that can be read by a polling query. The default value is 2000 for Camel 1.5.0 or older. In newer releases the default value is 0. | 
| {{readSize}} | {{0}} | The default maximum number of rows that can be read by a polling query. The default value is 0. | 
| {{statement.xxx}} | {{null}} | *Camel 2.1:* Sets additional options on the {{java.sql.Statement}} that is used behind the scenes to execute the queries. For instance, {{statement.maxRows=10}}. For detailed documentation, see the [{{java.sql.Statement}} javadoc|http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Statement.html] documentation. | | {{useJDBC4ColumnNameAndLabelSemantics}} | {{true}} | *Camel 2.2:* Sets whether to use JDBC 4/3 column label/name semantics. You can use this option to turn it {{false}} in case you have issues with your JDBC driver to select data. This only applies when using {{SQL SELECT}} using aliases (e.g. {{SQL SELECT id as identifier, name as given_name from persons}}). | 
...


Full Content

JDBC Component

The jdbc component enables you to access databases through JDBC, where SQL queries and operations are sent in the message body. This component uses the standard JDBC API, unlike the SQL Component component, which uses spring-jdbc.

Maven users will need to add the following dependency to their pom.xml for this component:


dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-jdbc/artifactId
versionx.x.x/version
!-- use the same version as your Camel core version --
/dependency



This component can only be used to define producer endpoints, which means that you cannot use the JDBC component in a from() statement.

This component can not be used as a Transactional Client. If you need transaction support in your route, you should use the SQL component instead.

URI format



jdbc:dataSourceName[?options]



This component only supports producer endpoints.

You can append query options to the URI in the following format, ?option=valueoption=value...

Options




 Name 
 Default Value 
 Description 


 readSize 
 0 
 The default maximum number of rows that can be read by a polling query. The default value is 0. 


 statement.xxx 
 null 
 Camel 2.1: Sets additional options on the java.sql.Statement that is used behind the scenes to execute the queries. For instance, statement.maxRows=10. For detailed documentation, see the java.sql.Statement javadoc documentation. 


 useJDBC4ColumnNameAndLabelSemantics 
 true 
 Camel 2.2: Sets whether to use JDBC 4/3 column label/name semantics. You can use this option to turn it false in case you have issues with your JDBC driver to select data. This only applies when using SQL SELECT using aliases (e.g. SQL SELECT id as identifier, name as given_name from persons). 


 resetAutoCommit 
 true 
 Camel 2.9: Camel will set the autoCommit on the JDBC connection to be false, commit the change after executed the statement and reset the autoCommit flag of the connection at the end, if the resetAutoCommit is true. If the JDBC connection doesn't support to reset the autoCommit flag, you can set the resetAutoCommit flag to be false, and Camel will not try to reset the autoCommit flag.





Result
The result is returned in the OUT body as an ArrayListHashMapString, Object. The List object contains the list of rows and the Map objects contain each row with the String key as the column name.

Note: This component fetches ResultSetMetaData to be able to return the column name as the key in the Map.

Message Headers



 Header 
 Description 


 CamelJdbcRowCount 
 If the query is a SELECT, query the row count is returned in this OUT header. 


 CamelJdbcUpdateCount 
 If the query is an UPDATE, query the update count is returned in this OUT header. 


 CamelGeneratedKeysRows 
 Camel 2.10: Rows that contains the generated kets. 


 CamelGeneratedKeysRowCount 
 Camel 2.10: The number of rows in the header that contains generated keys. 





Generated keys
Available as of Camel 2.10

If you insert data using SQL INSERT, then the RDBMS may support auto generated keys. You can instruct the JDBC producer to return the generated keys in headers.
To do that set the header CamelRetrieveGeneratedKeys=true. Then the generated keys will be provided as headers with the keys listed in the table above.

You can see more details in this unit test.


Samples

In the following example, we fetch the rows from the customer table.

First we register our datasource in the Camel 

[CONF] Apache Camel NMR

2012-09-08 Thread confluence







NMR
Page edited by Christian Mueller


Comment:
Removed the deprecated Camel 1.x documentations


 Changes (2)
 




...
{code}  
From *Camel 1.5* onwards, the The stream caching is default enabled, so it is not necessary to set the {{streamCaching()}} option. 
In *Camel 2.0* we We store big input streams (by default, over 64K) in a {{temp}} file using {{CachedOutputStream}}. When you close the input stream, the temp file will be deleted. 
 h4. Testing 
...


Full Content

NMR Component

The nmr component is an adapter to the Normalized Message Router (NMR) in ServiceMix, which is intended for use by Camel applications deployed directly into the OSGi container. You can exchange objects with NMR and not only XML like this is the case with the JBI specification. The interest of this component is that you can interconnect camel routes deployed in different OSGI bundles. 

By contrast, the JBI component is intended for use by Camel applications deployed into the ServiceMix JBI container.

Installing

The NMR component is provided with Apache ServiceMix. It is not distributed with Camel. To install the NMR component in ServiceMix, enter the following command in the ServiceMix console window:



features install nmr



You also need to instantiate the NMR component. You can do this by editing your Spring configuration file, META-INF/spring/*.xml, and adding the following bean instance:



beans xmlns:osgi="http://www.springframework.org/schema/osgi" ... 
...
bean id="nmr" class="org.apache.servicemix.camel.nmr.ServiceMixComponent"
property name="nmr"
osgi:reference interface="org.apache.servicemix.nmr.api.NMR" /
/property
/bean
...
/beans



NMR consumer and producer endpoints

The following code:



from("nmr:MyServiceEndpoint")



Automatically exposes a new endpoint to the bus with endpoint name MyServiceEndpoint (see URIformat).

When an NMR endpoint appears at the end of a route, for example:



to("nmr:MyServiceEndpoint")



The messages sent by this producer endpoint are sent to the already deployed NMR endpoint.


URI format



nmr:endpointName



URI Options



 Option 
 Default Value 
 Description 


 runAsSubject 
 false 
 Apache ServiceMix 4.4: When this is set to true on a consumer endpoint, the endpoint will be invoked on behalf of the Subject that is set on the Exchange (i.e. the call to Subject.getSubject(AccessControlContext) will return the Subject instance) 


 synchronous 
 false 
 When this is set to true on a consumer endpoint, an incoming, synchronous NMR Exchange will be handled on the sender's thread instead of being handled on a new thread of the NMR endpoint's thread pool 


 timeout 
 0 
 Apache ServiceMix 4.4: When this is set to a value greater than 0, the producer endpoint will timeout if it doesn't receive a response from the NMR within the given timeout period (in milliseconds).  Configuring a timeout value will switch to using synchronous interactions with the NMR instead of the usual asynchronous messaging. 





Examples

Consumer


from("nmr:MyServiceEndpoint") // consume nmr exchanges asynchronously
from("nmr:MyServiceEndpoint?synchronous=true").to() // consume nmr exchanges synchronously and use the same thread as defined by NMR ThreadPool



Producer


from()...to("nmr:MyServiceEndpoint") // produce nmr exchanges asynchronously
from()...to("nmr:MyServiceEndpoint?timeout=1") // produce nmr exchanges synchronously and wait till 10s to receive response



Using Stream bodies
If you are using a stream type as the message body, you should be aware that a stream is only capable of being read once. So if you enable DEBUG logging, the body is usually logged and thus read. To deal with this, Camel has a streamCaching option that can cache the stream, enabling you to read it multiple times.



from("nmr:MyEndpoint").streamCaching().to("xslt:transform.xsl", "bean:doSomething");



The stream caching is default enabled, so it is not necessary to set the streamCaching() option.
We store big input streams (by default, over 64K) in a temp file using CachedOutputStream. When you close the input stream, the temp file will be deleted.

Testing
NMR camel routes can be tested using the camel unit test approach even if they will be deployed next in different bundles on an OSGI runtime. With this aim in view, you will extend the ServiceMixNMR Mock class org.apache.servicemix.camel.nmr.AbstractComponentTest which will create a NMR bus, register the Camel NMR Component and the endpoints defined into the Camel routes.



public class ExchangeUsingNMRTest extends AbstractComponentTest {

@Test
public void testProcessing() throws InterruptedException 

[CONF] Apache Camel SQL Component

2012-09-08 Thread confluence







SQL Component
Page edited by Christian Mueller


Comment:
Removed the deprecated Camel 1.x documentations


 Changes (1)
 




...
 || Header || Description || 
| {{SqlProducer.UPDATE_COUNT}} | *Camel 1.x*: The number of rows updated for {{update}} operations, returned as an {{Integer}} object. | 
| {{CamelSqlUpdateCount}} | The number of rows updated for {{update}} operations, returned as an {{Integer}} object. | | {{CamelSqlRowCount}} | The number of rows returned for {{select}} operations, returned as an {{Integer}} object. | 
...


Full Content

SQL Component

The sql: component allows you to work with databases using JDBC queries. The difference between this component and JDBC component is that in case of SQL the query is a property of the endpoint and it uses message payload as parameters passed to the query.

This component uses spring-jdbc behind the scenes for the actual SQL handling.

Maven users will need to add the following dependency to their pom.xml for this component:


dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-sql/artifactId
versionx.x.x/version
!-- use the same version as your Camel core version --
/dependency



The SQL component also supports:

	a JDBC based repository for the Idempotent Consumer EIP pattern. See further below.
	a JDBC based repository for the Aggregator EIP pattern. See further below.



URI format

The SQL component can only be used to define producer endpoints. In other words, you cannot define an SQL endpoint in a from() statement.

This component can be used as a Transactional Client.

The SQL component uses the following endpoint URI notation:



sql:select * from table where id=# order by name[?options]



Notice that the standard ? symbol that denotes the parameters to an SQL query is substituted with the # symbol, because the ? symbol is used to specify options for the endpoint. The ? symbol replacement can be configured on endpoint basis.

You can append query options to the URI in the following format, ?option=valueoption=value...

Options




 Option 
 Type 
 Default 
 Description 


 batch 
 boolean 
 false 
 Camel 2.7.5, 2.8.4 and 2.9: Execute SQL batch update statements. See notes below on how the treatment of the inbound message body changes if this is set to true. 


 dataSourceRef 
 String 
 null 
 Reference to a DataSource to look up in the registry. 


 placeholder 
 String 
 # 
 Camel 2.4: Specifies a character that will be replaced to ? in SQL query. Notice, that it is simple String.replaceAll() operation and no SQL parsing is involved (quoted strings will also change) 


 template.xxx 

 null 
 Sets additional options on the Spring JdbcTemplate that is used behind the scenes to execute the queries. For instance, template.maxRows=10. For detailed documentation, see the JdbcTemplate javadoc documentation. 





Treatment of the message body

The SQL component tries to convert the message body to an object of java.util.Iterator type and then uses this iterator to fill the query parameters (where each query parameter is represented by a # symbol (or configured placeholder) in the endpoint URI). If the message body is not an array or collection, the conversion results in an iterator that iterates over only one object, which is the body itself.

For example, if the message body is an instance of java.util.List, the first item in the list is substituted into the first occurrence of # in the SQL query, the second item in the list is substituted into the second occurrence of #, and so on.

If batch is set to true, then the interpretation of the inbound message body changes slightly – instead of an iterator of parameters, the component expects an iterator that contains the parameter iterators; the size of the outer iterator determines the batch size.

Result of the query

For select operations, the result is an instance of ListMapString, Object type, as returned by the JdbcTemplate.queryForList() method. For update operations, the result is the number of updated rows, returned as an Integer.

Header values

When performing update operations, the SQL Component stores the update count in the following message headers:




 Header 
 Description 


 CamelSqlUpdateCount 
 The number of rows updated for update operations, returned as an Integer object. 


 CamelSqlRowCount 
 The number of rows returned for select operations, returned as an Integer object. 


 CamelSqlQuery 
 Camel 2.8: Query to execute. This query takes precedence over the query specified in the endpoint URI. Note that query parameters in the header are represented by a ? instead of a # symbol 





Configuration
You can now set a reference to a DataSource in the URI directly:




[CONF] Apache Camel VM

2012-09-08 Thread confluence







VM
Page edited by Christian Mueller


Comment:
Removed the deprecated Camel 1.x documentations


 Changes (1)
 




...
You can append query options to the URI in the following format: {{?option=valueoption=value...}}  
{info:title=Before Camel 1.x to 2.3 - Same URI must be used for both producer and consumer} 
An exactly identical [VM] endpoint URI *must* be used for both the producer and the consumer endpoint. Otherwise, Camel will create a second [VM] endpoint despite that the {{queueName}} portion of the URI is identical. For example: {code:java} 
...


Full Content

VM Component

The vm: component provides asynchronous SEDA behavior, exchanging messages on a BlockingQueue and invoking consumers in a separate thread pool.

This component differs from the SEDA component in that VM supports communication across CamelContext instances - so you can use this mechanism to communicate across web applications (provided that camel-core.jar is on the system/boot classpath).

VM is an extension to the SEDA component.

URI format



vm:queueName[?options]



Where queueName can be any string to uniquely identify the endpoint within the JVM (or at least within the classloader that loaded camel-core.jar)

You can append query options to the URI in the following format: ?option=valueoption=value...

Before Camel 2.3 - Same URI must be used for both producer and consumerAn exactly identical VM endpoint URI must be used for both the producer and the consumer endpoint. Otherwise, Camel will create a second VM endpoint despite that the queueName portion of the URI is identical. For example:


from("direct:foo").to("vm:bar?concurrentConsumers=5");

from("vm:bar?concurrentConsumers=5").to("file://output");


Notice that we have to use the full URI, including options in both the producer and consumer.

In Camel 2.4 this has been fixed so that only the queue name must match.  Using the queue name bar, we could rewrite the previous exmple as follows: 


from("direct:foo").to("vm:bar");

from("vm:bar?concurrentConsumers=5").to("file://output");



Options

See the SEDA component for options and other important usage details as the same rules apply to the VM component.

Samples
In the route below we send exchanges across CamelContext instances to a VM queue named order.email:



from("direct:in").bean(MyOrderBean.class).to("vm:order.email");



And then we receive exchanges in some other Camel context (such as deployed in another .war application):


from("vm:order.email").bean(MyOrderEmailSender.class);



See Also

	Configuring Camel
	Component
	Endpoint
	Getting Started



	SEDA





Change Notification Preferences

View Online
|
View Changes
|
Add Comment









svn commit: r1382279 - /camel/trunk/parent/pom.xml

2012-09-08 Thread davsclaus
Author: davsclaus
Date: Sat Sep  8 11:28:55 2012
New Revision: 1382279

URL: http://svn.apache.org/viewvc?rev=1382279view=rev
Log:
Upgraded to Netty 3.5.7

Modified:
camel/trunk/parent/pom.xml

Modified: camel/trunk/parent/pom.xml
URL: 
http://svn.apache.org/viewvc/camel/trunk/parent/pom.xml?rev=1382279r1=1382278r2=1382279view=diff
==
--- camel/trunk/parent/pom.xml (original)
+++ camel/trunk/parent/pom.xml Sat Sep  8 11:28:55 2012
@@ -215,7 +215,7 @@
 neethi-bundle-version3.0.1/neethi-bundle-version
 !-- transitive dependency from avro, to use older netty bundle --
 netty-bundle-version3.2.7.Final_1/netty-bundle-version
-netty-version3.5.5.Final/netty-version
+netty-version3.5.7.Final/netty-version
 ode-version1.3.4/ode-version
 openjpa-version2.2.0/openjpa-version
 !-- should be in-sync with deltaspike --




svn commit: r1382280 - /camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExecutorServiceManager.java

2012-09-08 Thread davsclaus
Author: davsclaus
Date: Sat Sep  8 11:29:12 2012
New Revision: 1382280

URL: http://svn.apache.org/viewvc?rev=1382280view=rev
Log:
Polished

Modified:

camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExecutorServiceManager.java

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExecutorServiceManager.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExecutorServiceManager.java?rev=1382280r1=1382279r2=1382280view=diff
==
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExecutorServiceManager.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/spi/ExecutorServiceManager.java
 Sat Sep  8 11:29:12 2012
@@ -331,7 +331,7 @@ public interface ExecutorServiceManager 
  * Awaits the termination of the thread pool.
  * p/
  * This implementation will log every 2nd second at INFO level that we are 
waiting, so the end user
- * can see we are not hanging in case it takes longer time to shutdown the 
pool.
+ * can see we are not hanging in case it takes longer time to terminate 
the pool.
  *
  * @param executorServicethe thread pool
  * @param shutdownAwaitTermination   time in millis to use as timeout




svn commit: r1382286 - in /camel/trunk/components/camel-quickfix/src: main/java/org/apache/camel/component/quickfixj/ test/java/org/apache/camel/component/quickfixj/

2012-09-08 Thread bvahdat
Author: bvahdat
Date: Sat Sep  8 11:47:37 2012
New Revision: 1382286

URL: http://svn.apache.org/viewvc?rev=1382286view=rev
Log:
CAMEL-5584: Remove QuickfixjEngine's forcedShutdown field.

Modified:

camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java

camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEngine.java

camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjConvertersTest.java

camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/QuickfixjEngineTest.java

camel/trunk/components/camel-quickfix/src/test/java/org/apache/camel/component/quickfixj/TestSupport.java

Modified: 
camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java?rev=1382286r1=1382285r2=1382286view=diff
==
--- 
camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
 (original)
+++ 
camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjComponent.java
 Sat Sep  8 11:47:37 2012
@@ -41,7 +41,6 @@ public class QuickfixjComponent extends 
 private MessageStoreFactory messageStoreFactory;
 private LogFactory logFactory;
 private MessageFactory messageFactory;
-private boolean forcedShutdown;
 private MapString, QuickfixjConfiguration configurations = new 
HashMapString, QuickfixjConfiguration();
 
 @Override
@@ -57,9 +56,9 @@ public class QuickfixjComponent extends 
 QuickfixjConfiguration configuration = 
configurations.get(remaining);
 if (configuration != null) {
 SessionSettings settings = 
configuration.createSessionSettings();
-engine = new QuickfixjEngine(uri, settings, 
forcedShutdown, messageStoreFactory, logFactory, messageFactory);
+engine = new QuickfixjEngine(uri, settings, 
messageStoreFactory, logFactory, messageFactory);
 } else {
-engine = new QuickfixjEngine(uri, remaining, 
forcedShutdown, messageStoreFactory, logFactory, messageFactory);
+engine = new QuickfixjEngine(uri, remaining, 
messageStoreFactory, logFactory, messageFactory);
 }
 engines.put(remaining, engine);
 
@@ -126,8 +125,11 @@ public class QuickfixjComponent extends 
 this.messageStoreFactory = messageStoreFactory;
 }
 
+/**
+ * @deprecated As it had/has no effect.
+ */
+@Deprecated
 public void setForcedShutdown(boolean forcedShutdown) {
-this.forcedShutdown = forcedShutdown;
 }
 
 public MapString, QuickfixjConfiguration getConfigurations() {

Modified: 
camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEngine.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEngine.java?rev=1382286r1=1382285r2=1382286view=diff
==
--- 
camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEngine.java
 (original)
+++ 
camel/trunk/components/camel-quickfix/src/main/java/org/apache/camel/component/quickfixj/QuickfixjEngine.java
 Sat Sep  8 11:47:37 2012
@@ -89,7 +89,6 @@ public class QuickfixjEngine extends Ser
 private final Acceptor acceptor;
 private final Initiator initiator;
 private final JmxExporter jmxExporter;
-private final boolean forcedShutdown;
 private final MessageStoreFactory messageStoreFactory;
 private final LogFactory sessionLogFactory;
 private final MessageFactory messageFactory;
@@ -101,12 +100,28 @@ public class QuickfixjEngine extends Ser
 ThreadPerConnector, ThreadPerSession;
 }
 
+/**
+ * @deprecated Better make use of the
+ * {@link #QuickfixjEngine(String, String)} constructor as
+ * ttforcedShutdown/tt had/has no effect.
+ */
+@Deprecated
 public QuickfixjEngine(String uri, String settingsResourceName, boolean 
forcedShutdown)
 throws ConfigError, FieldConvertError, IOException, JMException {
 
 this(uri, settingsResourceName, forcedShutdown, null, null, null);
 }
 
+public QuickfixjEngine(String uri, String settingsResourceName) throws 
ConfigError, FieldConvertError, IOException, JMException {
+this(uri, settingsResourceName, null, null, null);
+}
+
+/**
+ * @deprecated Better make use of 

svn commit: r831383 - in /websites/production/camel/content: cache/main.pageCache camel-2110-release.html

2012-09-08 Thread buildbot
Author: buildbot
Date: Sat Sep  8 12:17:35 2012
New Revision: 831383

Log:
Production update by buildbot for camel

Modified:
websites/production/camel/content/cache/main.pageCache
websites/production/camel/content/camel-2110-release.html

Modified: websites/production/camel/content/cache/main.pageCache
==
Binary files - no diff available.

Modified: websites/production/camel/content/camel-2110-release.html
==
--- websites/production/camel/content/camel-2110-release.html (original)
+++ websites/production/camel/content/camel-2110-release.html Sat Sep  8 
12:17:35 2012
@@ -139,7 +139,7 @@
 
 h2a shape=rect 
name=Camel2.11.0Release-DependencyUpgrades/aDependency Upgrades/h2
 
-ulliAsync Http Client 1.7.5 to 1.7.6/liliAxiom 1.2.10 to 
1.2.12/liliBeanIO 2.0.0 to 2.0.1/liliCommons Exec 1.0.1 to 
1.1/liliConcurrentLinkedHashMap 1.2 to 1.3.1/liliEhcache bundle 2.5.1_1 
to 2.5.2_1/liliGroovy 1.8.6 to 2.0.1/liliGSon 2.1 to 
2.2.2/liliHazelcast 2.0.2 to 2.3/liliHTTP Client 4.1.3 to 
4.2.1/liliIcu4j 4.0.1 to 4.8.1.1/liliJackson 1.9.7 to 
1.9.9/liliJaxen 1.1.3 to 1.1.4/liliJettison 1.3.1 to 
1.3.2/liliJRuby 1.6.7 to 1.6.7.2/liliKrati 0.4.5 to 
0.4.6/liliLucene 3.6.0 to 3.6.1/liliNetty 3.5.1 to 3.5.5/liliOgnl 
bundle 3.0.4_1 to 3.0.5_1/liliPax Logging 1.5.3 to 1.6.10/liliQPid 0.16 
to 0.18/liliQuartz 1.8.5 to 1.8.6/liliRestlet 2.0.14 to 
2.0.15/liliSaxon 9.3.0.11 to 9.4.0.1/liliShiro 1.2.0 to 
1.2.1/liliSolr 3.6.0 to 3.6.1/liliSpring Framework 3.1.1 to 
3.1.2/liliSpring Integration 2.1.2 to 2.1.3/liliSSHD 0.6.0 to 
0.7.0/liliTestNG 6.0.1 to 6.7/liliW
 oodstox 4.1.2 to 4.1.3/liliXStream 1.4.2 to 1.4.3/li/ul
+ulliAsync Http Client 1.7.5 to 1.7.6/liliAxiom 1.2.10 to 
1.2.12/liliBeanIO 2.0.0 to 2.0.1/liliCommons Exec 1.0.1 to 
1.1/liliConcurrentLinkedHashMap 1.2 to 1.3.1/liliEhcache bundle 2.5.1_1 
to 2.5.2_1/liliGroovy 1.8.6 to 2.0.1/liliGSon 2.1 to 
2.2.2/liliHazelcast 2.0.2 to 2.3/liliHTTP Client 4.1.3 to 
4.2.1/liliIcu4j 4.0.1 to 4.8.1.1/liliJackson 1.9.7 to 
1.9.9/liliJaxen 1.1.3 to 1.1.4/liliJettison 1.3.1 to 
1.3.2/liliJRuby 1.6.7 to 1.6.7.2/liliKrati 0.4.5 to 
0.4.6/liliLucene 3.6.0 to 3.6.1/liliNetty 3.5.1 to 3.5.7/liliOgnl 
bundle 3.0.4_1 to 3.0.5_1/liliPax Logging 1.5.3 to 1.6.10/liliQPid 0.16 
to 0.18/liliQuartz 1.8.5 to 1.8.6/liliRestlet 2.0.14 to 
2.0.15/liliSaxon 9.3.0.11 to 9.4.0.1/liliShiro 1.2.0 to 
1.2.1/liliSolr 3.6.0 to 3.6.1/liliSpring Framework 3.1.1 to 
3.1.2/liliSpring Integration 2.1.2 to 2.1.3/liliSSHD 0.6.0 to 
0.7.0/liliTestNG 6.0.1 to 6.7/liliW
 oodstox 4.1.2 to 4.1.3/liliXStream 1.4.2 to 1.4.3/li/ul
 
 
 h2a shape=rect 
name=Camel2.11.0Release-Importantchangestoconsiderwhenupgrading/aImportant 
changes to consider when upgrading/h2




svn commit: r1382308 - /camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java

2012-09-08 Thread davsclaus
Author: davsclaus
Date: Sat Sep  8 14:15:03 2012
New Revision: 1382308

URL: http://svn.apache.org/viewvc?rev=1382308view=rev
Log:
Polished

Modified:

camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java

Modified: 
camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java?rev=1382308r1=1382307r2=1382308view=diff
==
--- 
camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
 (original)
+++ 
camel/trunk/components/camel-test-spring/src/main/java/org/apache/camel/test/spring/CamelSpringTestContextLoader.java
 Sat Sep  8 14:15:03 2012
@@ -422,7 +422,7 @@ public class CamelSpringTestContextLoade
 }
 
 /**
- * Handles auto-intercepting of endpoints with mocks based on {@link 
MockEndpoints} and skipping the
+ * Handles auto-intercepting of endpoints with mocks based on {@link 
MockEndpointsAndSkip} and skipping the
  * original endpoint.
  *
  * @param context the initialized Spring context




[CONF] Apache Camel Timer

2012-09-08 Thread confluence







Timer
Page edited by Claus Ibsen


 Changes (1)
 




...
| {{period}} | {{1000}} | If greater than 0, generate periodic events every {{period}} milliseconds. | | {{delay}} | {{0}} / {{1000}} | The number of milliseconds to wait before the first event is generated. Should not be used in conjunction with the {{time}} option. The default value has bee n changed to {{1000}} from *Camel 2.11* onwards. In older releases the default value is {{0}}. |  
| {{initialDelay}} | {{1000}} | *Camel 2.10.2:* The number of milliseconds to wait before the first event is generated. Should not be used in conjunction with the {{time}} option. | 
| {{fixedRate}} | {{false}} | Events take place at approximately regular intervals, separated by the specified period. |  | {{daemon}} | {{true}} | Specifies whether or not the thread associated with the timer endpoint runs as a daemon. |  
...


Full Content

Timer Component

The timer: component is used to generate message exchanges when a timer fires You can only consume events from this endpoint.  

URI format



timer:name[?options]

 

Where name is the name of the Timer object, which is created and shared across endpoints. So if you use the same name for all your timer endpoints, only one Timer object and thread will be used.

You can append query options to the URI in the following format, ?option=valueoption=value...

Note: The IN body of the generated exchange is null. So exchange.getIn().getBody() returns null.

Advanced SchedulerSee also the Quartz component that supports much more advanced scheduling.

Specify time in human friendly formatIn Camel 2.3 onwards you can specify the time in human friendly syntax.

Options



 Name 
 Default Value 
 Description 


 time 
 null 
 A java.util.Date the first event should be generated. If using the URI, the pattern expected is: -MM-dd HH:mm:ss or -MM-dd'T'HH:mm:ss. 


 pattern 
 null 
 Allows you to specify a custom Date pattern to use for setting the time option using URI syntax. 


 period 
 1000 
 If greater than 0, generate periodic events every period milliseconds. 


 delay 
 0 / 1000 
 The number of milliseconds to wait before the first event is generated. Should not be used in conjunction with the time option. The default value has bee n changed to 1000 from Camel 2.11 onwards. In older releases the default value is 0. 


 fixedRate 
 false 
 Events take place at approximately regular intervals, separated by the specified period. 


 daemon 
 true 
 Specifies whether or not the thread associated with the timer endpoint runs as a daemon. 


 repeatCount 
 0 
 Camel 2.8: Specifies a maximum limit of number of fires. So if you set it to 1, the timer will only fire once. If you set it to 5, it will only fire five times. A value of zero or negative means fire forever. 





Exchange Properties
When the timer is fired, it adds the following information as properties to the Exchange:



 Name 
 Type 
 Description 


 Exchange.TIMER_NAME 
 String 
 The value of the name option. 


 Exchange.TIMER_TIME 
 Date 
 The value of the time option. 


 Exchange.TIMER_PERIOD 
 long 
 The value of the period option. 


 Exchange.TIMER_FIRED_TIME 
 Date 
 The time when the consumer fired. 


 Exchange.TIMER_COUNTER 
 Long 
 Camel 2.8: The current fire counter. Starts from 1. 





Message Headers
When the timer is fired, it adds the following information as headers to the IN message



 Name 
 Type 
 Description 


 Exchange.TIMER_FIRED_TIME 
 java.util.Date 
 The time when the consumer fired 





Sample

To set up a route that generates an event every 60 seconds:



   from("timer://foo?fixedRate=trueperiod=6").to("bean:myBean?method=someMethodName");



Instead of 6 you can use period=60s which is more friendly to read.

The above route will generate an event and then invoke the someMethodName method on the bean called myBean in the Registry such as JNDI or Spring.

And the route in Spring DSL:


  route
from uri="timer://foo?fixedRate=trueamp;period=6"/
to uri="bean:myBean?method=someMethodName"/
  /route



Firing only once
Available as of Camel 2.8

You may want to fire a message in a Camel route only once, such as when starting the route. To do that you use the repeatCount option as shown:


  route
from uri="timer://foo?repeatCount=1"/
to uri="bean:myBean?method=someMethodName"/
  /route




See Also

	Configuring Camel
	Component
	Endpoint
	Getting Started



	Quartz





Change Notification Preferences

View Online
|
View Changes
|
Add Comment









svn commit: r1382312 - /camel/branches/camel-2.10.x/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcAnotherRouteTest.java

2012-09-08 Thread cmueller
Author: cmueller
Date: Sat Sep  8 15:02:57 2012
New Revision: 1382312

URL: http://svn.apache.org/viewvc?rev=1382312view=rev
Log:
fixed a unit test which fails randomly

Modified:

camel/branches/camel-2.10.x/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcAnotherRouteTest.java

Modified: 
camel/branches/camel-2.10.x/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcAnotherRouteTest.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcAnotherRouteTest.java?rev=1382312r1=1382311r2=1382312view=diff
==
--- 
camel/branches/camel-2.10.x/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcAnotherRouteTest.java
 (original)
+++ 
camel/branches/camel-2.10.x/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcAnotherRouteTest.java
 Sat Sep  8 15:02:57 2012
@@ -40,7 +40,9 @@ public class JdbcAnotherRouteTest extend
 protected RouteBuilder createRouteBuilder() throws Exception {
 return new RouteBuilder() {
 public void configure() throws Exception {
-from(timer://kickoff?period=1).
+getContext().setTracing(true);
+
+from(timer://kickoff?delay=100period=1).
 setBody(constant(select * from customer)).
 to(jdbc:testdb).
 to(mock:result);




svn commit: r1382313 - /camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorTimerAndTracerTest.java

2012-09-08 Thread cmueller
Author: cmueller
Date: Sat Sep  8 15:07:05 2012
New Revision: 1382313

URL: http://svn.apache.org/viewvc?rev=1382313view=rev
Log:
fixed a unit test which fails randomly

Modified:

camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorTimerAndTracerTest.java

Modified: 
camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorTimerAndTracerTest.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorTimerAndTracerTest.java?rev=1382313r1=1382312r2=1382313view=diff
==
--- 
camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorTimerAndTracerTest.java
 (original)
+++ 
camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorTimerAndTracerTest.java
 Sat Sep  8 15:07:05 2012
@@ -44,7 +44,7 @@ public class AggregatorTimerAndTracerTes
 to(mock:foo).
 to(mock:result);
 
-from(timer://kickoff?period=91).
+from(timer://kickoff?delay=100period=91).
 setHeader(id).constant(foo).setBody().constant(a b 
c).
 split(body().tokenize( )).to(seda:splitted);
 }




svn commit: r1382316 - /camel/branches/camel-2.10.x/components/camel-jdbc/src/test/resources/org/apache/camel/component/jdbc/camelContext.xml

2012-09-08 Thread cmueller
Author: cmueller
Date: Sat Sep  8 15:13:55 2012
New Revision: 1382316

URL: http://svn.apache.org/viewvc?rev=1382316view=rev
Log:
fixed a unit test which fails randomly

Modified:

camel/branches/camel-2.10.x/components/camel-jdbc/src/test/resources/org/apache/camel/component/jdbc/camelContext.xml

Modified: 
camel/branches/camel-2.10.x/components/camel-jdbc/src/test/resources/org/apache/camel/component/jdbc/camelContext.xml
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-jdbc/src/test/resources/org/apache/camel/component/jdbc/camelContext.xml?rev=1382316r1=1382315r2=1382316view=diff
==
--- 
camel/branches/camel-2.10.x/components/camel-jdbc/src/test/resources/org/apache/camel/component/jdbc/camelContext.xml
 (original)
+++ 
camel/branches/camel-2.10.x/components/camel-jdbc/src/test/resources/org/apache/camel/component/jdbc/camelContext.xml
 Sat Sep  8 15:13:55 2012
@@ -27,7 +27,7 @@
   !-- START SNIPPET: example --  
   camelContext id=camel xmlns=http://camel.apache.org/schema/spring;
 route
-   from uri=timer://kickoff?period=1/
+   from uri=timer://kickoff?delay=100amp;period=1/
setBody
  constantselect * from customer/constant
/setBody




svn commit: r831390 - in /websites/production/camel/content: book-component-appendix.html book-in-one-page.html cache/main.pageCache timer.html

2012-09-08 Thread buildbot
Author: buildbot
Date: Sat Sep  8 15:19:41 2012
New Revision: 831390

Log:
Production update by buildbot for camel

Modified:
websites/production/camel/content/book-component-appendix.html
websites/production/camel/content/book-in-one-page.html
websites/production/camel/content/cache/main.pageCache
websites/production/camel/content/timer.html

Modified: websites/production/camel/content/book-component-appendix.html
==
--- websites/production/camel/content/book-component-appendix.html (original)
+++ websites/production/camel/content/book-component-appendix.html Sat Sep  8 
15:19:41 2012
@@ -16330,7 +16330,7 @@ timer:name[?options]
 
 h3a shape=rect name=BookComponentAppendix-Options/aOptions/h3
 div class=confluenceTableSmalldiv class=table-wrap
-table class=confluenceTabletbodytrth colspan=1 rowspan=1 
class=confluenceTh Name /thth colspan=1 rowspan=1 
class=confluenceTh Default Value /thth colspan=1 rowspan=1 
class=confluenceTh Description /th/trtrtd colspan=1 rowspan=1 
class=confluenceTd tttime/tt /tdtd colspan=1 rowspan=1 
class=confluenceTd ttnull/tt /tdtd colspan=1 rowspan=1 
class=confluenceTd A ttjava.util.Date/tt the bfirst/b event should 
be generated. If using the URI, the pattern expected is: tt-MM-dd 
HH:mm:ss/tt or tt-MM-dd'T'HH:mm:ss/tt. /td/trtrtd colspan=1 
rowspan=1 class=confluenceTd ttpattern/tt /tdtd colspan=1 
rowspan=1 class=confluenceTd ttnull/tt /tdtd colspan=1 
rowspan=1 class=confluenceTd Allows you to specify a custom ttDate/tt 
pattern to use for setting the time option using URI syntax. /td/trtrtd 
colspan=1 rowspan=1 class=confluenceTd t
 tperiod/tt /tdtd colspan=1 rowspan=1 class=confluenceTd 
tt1000/tt /tdtd colspan=1 rowspan=1 class=confluenceTd If greater 
than 0, generate periodic events every ttperiod/tt milliseconds. 
/td/trtrtd colspan=1 rowspan=1 class=confluenceTd ttdelay/tt 
/tdtd colspan=1 rowspan=1 class=confluenceTd tt0/tt / 
tt1000/tt /tdtd colspan=1 rowspan=1 class=confluenceTd The number 
of milliseconds to wait before the first event is generated. Should not be used 
in conjunction with the tttime/tt option. The default value has bee n 
changed to tt1000/tt from bCamel 2.11/b onwards. In older releases the 
default value is tt0/tt. /td/trtrtd colspan=1 rowspan=1 
class=confluenceTd ttinitialDelay/tt /tdtd colspan=1 rowspan=1 
class=confluenceTd tt1000/tt /tdtd colspan=1 rowspan=1 
class=confluenceTd bCamel 2.10.2:/b The number of milliseconds to wait 
before the first
  event is generated. Should not be used in conjunction with the tttime/tt 
option. /td/trtrtd colspan=1 rowspan=1 class=confluenceTd 
ttfixedRate/tt /tdtd colspan=1 rowspan=1 class=confluenceTd 
ttfalse/tt /tdtd colspan=1 rowspan=1 class=confluenceTd Events 
take place at approximately regular intervals, separated by the specified 
period. /td/trtrtd colspan=1 rowspan=1 class=confluenceTd 
ttdaemon/tt /tdtd colspan=1 rowspan=1 class=confluenceTd 
tttrue/tt /tdtd colspan=1 rowspan=1 class=confluenceTd Specifies 
whether or not the thread associated with the timer endpoint runs as a daemon. 
/td/trtrtd colspan=1 rowspan=1 class=confluenceTd 
ttrepeatCount/tt /tdtd colspan=1 rowspan=1 class=confluenceTd 
tt0/tt /tdtd colspan=1 rowspan=1 class=confluenceTd bCamel 
2.8:/b Specifies a maximum limit of number of fires. So if you set it to 1, 
the timer will only 
 fire once. If you set it to 5, it will only fire five times. A value of zero 
or negative means fire forever. /td/tr/tbody/table
+table class=confluenceTabletbodytrth colspan=1 rowspan=1 
class=confluenceTh Name /thth colspan=1 rowspan=1 
class=confluenceTh Default Value /thth colspan=1 rowspan=1 
class=confluenceTh Description /th/trtrtd colspan=1 rowspan=1 
class=confluenceTd tttime/tt /tdtd colspan=1 rowspan=1 
class=confluenceTd ttnull/tt /tdtd colspan=1 rowspan=1 
class=confluenceTd A ttjava.util.Date/tt the bfirst/b event should 
be generated. If using the URI, the pattern expected is: tt-MM-dd 
HH:mm:ss/tt or tt-MM-dd'T'HH:mm:ss/tt. /td/trtrtd colspan=1 
rowspan=1 class=confluenceTd ttpattern/tt /tdtd colspan=1 
rowspan=1 class=confluenceTd ttnull/tt /tdtd colspan=1 
rowspan=1 class=confluenceTd Allows you to specify a custom ttDate/tt 
pattern to use for setting the time option using URI syntax. /td/trtrtd 
colspan=1 rowspan=1 class=confluenceTd t
 tperiod/tt /tdtd colspan=1 rowspan=1 class=confluenceTd 
tt1000/tt /tdtd colspan=1 rowspan=1 class=confluenceTd If greater 
than 0, generate periodic events every ttperiod/tt milliseconds. 
/td/trtrtd colspan=1 rowspan=1 class=confluenceTd ttdelay/tt 
/tdtd colspan=1 rowspan=1 class=confluenceTd tt0/tt / 
tt1000/tt /tdtd colspan=1 rowspan=1 class=confluenceTd The number 
of milliseconds to wait before the first event is generated. Should not be used 
in conjunction with the tttime/tt option. The default value has bee n 
changed to tt1000/tt from bCamel 2.11/b onwards. In older 

[CONF] Apache Camel Timer

2012-09-08 Thread confluence







Timer
Page edited by Christian Mueller


 Changes (2)
 




...
| {{pattern}} | {{null}} | Allows you to specify a custom {{Date}} pattern to use for setting the time option using URI syntax. | | {{period}} | {{1000}} | If greater than 0, generate periodic events every {{period}} milliseconds. | 
| {{delay}} | {{0}} / {{1000}} | The number of milliseconds to wait before the first event is generated. Should not be used in conjunction with the {{time}} option. The default value has bee n changed to {{1000}} from *Camel 2.11* onwards. In older releases the default value is {{0}}. |  
| {{delay}} | {{0}} / {{1000}} | The number of milliseconds to wait before the first event is generated. Should not be used in conjunction with the {{time}} option. The default value has bee n changed to {{1000}} from *Camel 2.11* onwards. In older releases the default value is {{0}} what randomly cause the issue the timer is not executed the first time (it is executed the first time after {{period}} of time or never, if {{period}} is 0). This is by design of the {{java.util.TaskQueue}} we use under the cover. |  
| {{fixedRate}} | {{false}} | Events take place at approximately regular intervals, separated by the specified period. |  | {{daemon}} | {{true}} | Specifies whether or not the thread associated with the timer endpoint runs as a daemon. |  
...


Full Content

Timer Component

The timer: component is used to generate message exchanges when a timer fires You can only consume events from this endpoint.  

URI format



timer:name[?options]

 

Where name is the name of the Timer object, which is created and shared across endpoints. So if you use the same name for all your timer endpoints, only one Timer object and thread will be used.

You can append query options to the URI in the following format, ?option=valueoption=value...

Note: The IN body of the generated exchange is null. So exchange.getIn().getBody() returns null.

Advanced SchedulerSee also the Quartz component that supports much more advanced scheduling.

Specify time in human friendly formatIn Camel 2.3 onwards you can specify the time in human friendly syntax.

Options



 Name 
 Default Value 
 Description 


 time 
 null 
 A java.util.Date the first event should be generated. If using the URI, the pattern expected is: -MM-dd HH:mm:ss or -MM-dd'T'HH:mm:ss. 


 pattern 
 null 
 Allows you to specify a custom Date pattern to use for setting the time option using URI syntax. 


 period 
 1000 
 If greater than 0, generate periodic events every period milliseconds. 


 delay 
 0 / 1000 
 The number of milliseconds to wait before the first event is generated. Should not be used in conjunction with the time option. The default value has bee n changed to 1000 from Camel 2.11 onwards. In older releases the default value is 0 what randomly cause the issue the timer is not executed the first time (it is executed the first time after period of time or never, if period is 0). This is by design of the java.util.TaskQueue we use under the cover. 


 fixedRate 
 false 
 Events take place at approximately regular intervals, separated by the specified period. 


 daemon 
 true 
 Specifies whether or not the thread associated with the timer endpoint runs as a daemon. 


 repeatCount 
 0 
 Camel 2.8: Specifies a maximum limit of number of fires. So if you set it to 1, the timer will only fire once. If you set it to 5, it will only fire five times. A value of zero or negative means fire forever. 





Exchange Properties
When the timer is fired, it adds the following information as properties to the Exchange:



 Name 
 Type 
 Description 


 Exchange.TIMER_NAME 
 String 
 The value of the name option. 


 Exchange.TIMER_TIME 
 Date 
 The value of the time option. 


 Exchange.TIMER_PERIOD 
 long 
 The value of the period option. 


 Exchange.TIMER_FIRED_TIME 
 Date 
 The time when the consumer fired. 


 Exchange.TIMER_COUNTER 
 Long 
 Camel 2.8: The current fire counter. Starts from 1. 





Message Headers
When the timer is fired, it adds the following information as headers to the IN message



 Name 
 Type 
 Description 


 Exchange.TIMER_FIRED_TIME 
 java.util.Date 
 The time when the consumer fired 





Sample

To set up a route that generates an event every 60 seconds:



   from("timer://foo?fixedRate=trueperiod=6").to("bean:myBean?method=someMethodName");



Instead of 6 you can use period=60s which is more friendly to read.

The above route will generate an event and then invoke the someMethodName method on the bean called myBean in the Registry such as JNDI or Spring.

And the route in Spring DSL:


  route
from uri="timer://foo?fixedRate=trueamp;period=6"/
to 

svn commit: r1382318 - /camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorTimerAndTracerTest.java

2012-09-08 Thread cmueller
Author: cmueller
Date: Sat Sep  8 15:27:01 2012
New Revision: 1382318

URL: http://svn.apache.org/viewvc?rev=1382318view=rev
Log:
fixed a unit test which fails randomly

Modified:

camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorTimerAndTracerTest.java

Modified: 
camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorTimerAndTracerTest.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorTimerAndTracerTest.java?rev=1382318r1=1382317r2=1382318view=diff
==
--- 
camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorTimerAndTracerTest.java
 (original)
+++ 
camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregatorTimerAndTracerTest.java
 Sat Sep  8 15:27:01 2012
@@ -44,7 +44,7 @@ public class AggregatorTimerAndTracerTes
 to(mock:foo).
 to(mock:result);
 
-from(timer://kickoff?period=91).
+from(timer://kickoff?delay=100period=91).
 setHeader(id).constant(foo).setBody().constant(a b 
c).
 split(body().tokenize( )).to(seda:splitted);
 }




svn commit: r1382320 - /camel/branches/camel-2.9.x/components/camel-jdbc/src/test/resources/org/apache/camel/component/jdbc/camelContext.xml

2012-09-08 Thread cmueller
Author: cmueller
Date: Sat Sep  8 15:31:29 2012
New Revision: 1382320

URL: http://svn.apache.org/viewvc?rev=1382320view=rev
Log:
fixed a unit test which fails randomly

Modified:

camel/branches/camel-2.9.x/components/camel-jdbc/src/test/resources/org/apache/camel/component/jdbc/camelContext.xml

Modified: 
camel/branches/camel-2.9.x/components/camel-jdbc/src/test/resources/org/apache/camel/component/jdbc/camelContext.xml
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-jdbc/src/test/resources/org/apache/camel/component/jdbc/camelContext.xml?rev=1382320r1=1382319r2=1382320view=diff
==
--- 
camel/branches/camel-2.9.x/components/camel-jdbc/src/test/resources/org/apache/camel/component/jdbc/camelContext.xml
 (original)
+++ 
camel/branches/camel-2.9.x/components/camel-jdbc/src/test/resources/org/apache/camel/component/jdbc/camelContext.xml
 Sat Sep  8 15:31:29 2012
@@ -27,7 +27,7 @@
   !-- START SNIPPET: example --  
   camelContext id=camel xmlns=http://camel.apache.org/schema/spring;
 route
-   from uri=timer://kickoff?period=1/
+   from uri=timer://kickoff?delay=100amp;period=1/
setBody
  constantselect * from customer/constant
/setBody




svn commit: r831393 - in /websites/production/camel/content: book-component-appendix.html book-in-one-page.html cache/main.pageCache timer.html

2012-09-08 Thread buildbot
Author: buildbot
Date: Sat Sep  8 16:19:25 2012
New Revision: 831393

Log:
Production update by buildbot for camel

Modified:
websites/production/camel/content/book-component-appendix.html
websites/production/camel/content/book-in-one-page.html
websites/production/camel/content/cache/main.pageCache
websites/production/camel/content/timer.html

Modified: websites/production/camel/content/book-component-appendix.html
==
--- websites/production/camel/content/book-component-appendix.html (original)
+++ websites/production/camel/content/book-component-appendix.html Sat Sep  8 
16:19:25 2012
@@ -16330,7 +16330,7 @@ timer:name[?options]
 
 h3a shape=rect name=BookComponentAppendix-Options/aOptions/h3
 div class=confluenceTableSmalldiv class=table-wrap
-table class=confluenceTabletbodytrth colspan=1 rowspan=1 
class=confluenceTh Name /thth colspan=1 rowspan=1 
class=confluenceTh Default Value /thth colspan=1 rowspan=1 
class=confluenceTh Description /th/trtrtd colspan=1 rowspan=1 
class=confluenceTd tttime/tt /tdtd colspan=1 rowspan=1 
class=confluenceTd ttnull/tt /tdtd colspan=1 rowspan=1 
class=confluenceTd A ttjava.util.Date/tt the bfirst/b event should 
be generated. If using the URI, the pattern expected is: tt-MM-dd 
HH:mm:ss/tt or tt-MM-dd'T'HH:mm:ss/tt. /td/trtrtd colspan=1 
rowspan=1 class=confluenceTd ttpattern/tt /tdtd colspan=1 
rowspan=1 class=confluenceTd ttnull/tt /tdtd colspan=1 
rowspan=1 class=confluenceTd Allows you to specify a custom ttDate/tt 
pattern to use for setting the time option using URI syntax. /td/trtrtd 
colspan=1 rowspan=1 class=confluenceTd t
 tperiod/tt /tdtd colspan=1 rowspan=1 class=confluenceTd 
tt1000/tt /tdtd colspan=1 rowspan=1 class=confluenceTd If greater 
than 0, generate periodic events every ttperiod/tt milliseconds. 
/td/trtrtd colspan=1 rowspan=1 class=confluenceTd ttdelay/tt 
/tdtd colspan=1 rowspan=1 class=confluenceTd tt0/tt / 
tt1000/tt /tdtd colspan=1 rowspan=1 class=confluenceTd The number 
of milliseconds to wait before the first event is generated. Should not be used 
in conjunction with the tttime/tt option. The default value has bee n 
changed to tt1000/tt from bCamel 2.11/b onwards. In older releases the 
default value is tt0/tt. /td/trtrtd colspan=1 rowspan=1 
class=confluenceTd ttfixedRate/tt /tdtd colspan=1 rowspan=1 
class=confluenceTd ttfalse/tt /tdtd colspan=1 rowspan=1 
class=confluenceTd Events take place at approximately regular intervals, 
separated by the spe
 cified period. /td/trtrtd colspan=1 rowspan=1 class=confluenceTd 
ttdaemon/tt /tdtd colspan=1 rowspan=1 class=confluenceTd 
tttrue/tt /tdtd colspan=1 rowspan=1 class=confluenceTd Specifies 
whether or not the thread associated with the timer endpoint runs as a daemon. 
/td/trtrtd colspan=1 rowspan=1 class=confluenceTd 
ttrepeatCount/tt /tdtd colspan=1 rowspan=1 class=confluenceTd 
tt0/tt /tdtd colspan=1 rowspan=1 class=confluenceTd bCamel 
2.8:/b Specifies a maximum limit of number of fires. So if you set it to 1, 
the timer will only fire once. If you set it to 5, it will only fire five 
times. A value of zero or negative means fire forever. 
/td/tr/tbody/table
+table class=confluenceTabletbodytrth colspan=1 rowspan=1 
class=confluenceTh Name /thth colspan=1 rowspan=1 
class=confluenceTh Default Value /thth colspan=1 rowspan=1 
class=confluenceTh Description /th/trtrtd colspan=1 rowspan=1 
class=confluenceTd tttime/tt /tdtd colspan=1 rowspan=1 
class=confluenceTd ttnull/tt /tdtd colspan=1 rowspan=1 
class=confluenceTd A ttjava.util.Date/tt the bfirst/b event should 
be generated. If using the URI, the pattern expected is: tt-MM-dd 
HH:mm:ss/tt or tt-MM-dd'T'HH:mm:ss/tt. /td/trtrtd colspan=1 
rowspan=1 class=confluenceTd ttpattern/tt /tdtd colspan=1 
rowspan=1 class=confluenceTd ttnull/tt /tdtd colspan=1 
rowspan=1 class=confluenceTd Allows you to specify a custom ttDate/tt 
pattern to use for setting the time option using URI syntax. /td/trtrtd 
colspan=1 rowspan=1 class=confluenceTd t
 tperiod/tt /tdtd colspan=1 rowspan=1 class=confluenceTd 
tt1000/tt /tdtd colspan=1 rowspan=1 class=confluenceTd If greater 
than 0, generate periodic events every ttperiod/tt milliseconds. 
/td/trtrtd colspan=1 rowspan=1 class=confluenceTd ttdelay/tt 
/tdtd colspan=1 rowspan=1 class=confluenceTd tt0/tt / 
tt1000/tt /tdtd colspan=1 rowspan=1 class=confluenceTd The number 
of milliseconds to wait before the first event is generated. Should not be used 
in conjunction with the tttime/tt option. The default value has bee n 
changed to tt1000/tt from bCamel 2.11/b onwards. In older releases the 
default value is tt0/tt what randomly cause the issue the timer is not 
executed the first time (it is executed the first time after ttperiod/tt of 
time or never, if ttperiod/tt is 0). This is by design of the 
ttjava.util.TaskQueue/tt we use under the cover. /td/trtrtd 
colspan=1 rowspan
 =1 class=confluenceTd 

svn commit: r1382369 - /camel/trunk/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpSimpleProduceTest.java

2012-09-08 Thread cmueller
Author: cmueller
Date: Sat Sep  8 21:32:48 2012
New Revision: 1382369

URL: http://svn.apache.org/viewvc?rev=1382369view=rev
Log:
fixed test which randomly fail on slow CI server

Modified:

camel/trunk/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpSimpleProduceTest.java

Modified: 
camel/trunk/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpSimpleProduceTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpSimpleProduceTest.java?rev=1382369r1=1382368r2=1382369view=diff
==
--- 
camel/trunk/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpSimpleProduceTest.java
 (original)
+++ 
camel/trunk/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpSimpleProduceTest.java
 Sat Sep  8 21:32:48 2012
@@ -22,10 +22,8 @@ import org.apache.camel.Exchange;
 import org.junit.Assume;
 import org.junit.Test;
 
-/**
- * @version 
- */
 public class ScpSimpleProduceTest extends ScpServerTestSupport {
+
 @Override
 public boolean isUseRouteBuilder() {
 return false;
@@ -37,9 +35,10 @@ public class ScpSimpleProduceTest extend
 
 String uri = getScpUri() + 
?username=adminpassword=adminknownHostsFile= + getKnownHostsFile();
 template.sendBodyAndHeader(uri, Hello World, Exchange.FILE_NAME, 
hello.txt);
+Thread.sleep(100);
 
-File file = new File(getScpPath() + /hello.txt).getAbsoluteFile();
-assertTrue(File should exist:  + file, file.exists());
+File file = new File(getScpPath() + /hello.txt);
+assertFileExists(file.getAbsolutePath());
 assertEquals(Hello World, 
context.getTypeConverter().convertTo(String.class, file));
 }
 
@@ -49,9 +48,10 @@ public class ScpSimpleProduceTest extend
 
 String uri = getScpUri() + 
?username=adminpassword=adminknownHostsFile= + getKnownHostsFile();
 template.sendBodyAndHeader(uri, Bye World, Exchange.FILE_NAME, 
mysub/bye.txt);
+Thread.sleep(100);
 
-File file = new File(getScpPath() + 
/mysub/bye.txt).getAbsoluteFile();
-assertTrue(File should exist:  + file, file.exists());
+File file = new File(getScpPath() + /mysub/bye.txt);
+assertFileExists(file.getAbsolutePath());
 assertEquals(Bye World, 
context.getTypeConverter().convertTo(String.class, file));
 }
 
@@ -61,9 +61,10 @@ public class ScpSimpleProduceTest extend
 
 String uri = getScpUri() + 
?username=adminpassword=adminknownHostsFile= + getKnownHostsFile();
 template.sendBodyAndHeader(uri, Farewell World, Exchange.FILE_NAME, 
mysub/mysubsub/farewell.txt);
+Thread.sleep(100);
 
-File file = new File(getScpPath() + 
/mysub/mysubsub/farewell.txt).getAbsoluteFile();
-assertTrue(File should exist:  + file, file.exists());
+File file = new File(getScpPath() + /mysub/mysubsub/farewell.txt);
+assertFileExists(file.getAbsolutePath());
 assertEquals(Farewell World, 
context.getTypeConverter().convertTo(String.class, file));
 }
 
@@ -73,9 +74,10 @@ public class ScpSimpleProduceTest extend
 
 String uri = getScpUri() + 
?username=adminpassword=adminchmod=640knownHostsFile= + 
getKnownHostsFile();
 template.sendBodyAndHeader(uri, Bonjour Monde, Exchange.FILE_NAME, 
monde.txt);
+Thread.sleep(100);
 
-File file = new File(getScpPath() + /monde.txt).getAbsoluteFile();
-assertTrue(File should exist:  + file, file.exists());
+File file = new File(getScpPath() + /monde.txt);
+assertFileExists(file.getAbsolutePath());
 // Mina sshd we use for testing ignores file perms;
 // assertFalse(File should not have execute rights:  + file, 
file.canExecute());
 assertEquals(Bonjour Monde, 
context.getTypeConverter().convertTo(String.class, file));
@@ -87,9 +89,10 @@ public class ScpSimpleProduceTest extend
 
 String uri = getScpUri() + 
?username=adminprivateKeyFile=src/test/resources/camel-key.privprivateKeyFilePassphrase=passwordknownHostsFile=
 + getKnownHostsFile();
 template.sendBodyAndHeader(uri, Hallo Welt, Exchange.FILE_NAME, 
welt.txt);
+Thread.sleep(100);
 
-File file = new File(getScpPath() + /welt.txt).getAbsoluteFile();
-assertTrue(File should exist:  + file, file.exists());
+File file = new File(getScpPath() + /welt.txt);
+assertFileExists(file.getAbsolutePath());
 // Mina sshd we use for testing ignores file perms;
 // assertFalse(File should not have execute rights:  + file, 
file.canExecute());
 assertEquals(Hallo Welt, 
context.getTypeConverter().convertTo(String.class, file));




svn commit: r1382372 - /camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpShutdownCompleteCurrentTaskOnlyTest.java

2012-09-08 Thread cmueller
Author: cmueller
Date: Sat Sep  8 21:46:50 2012
New Revision: 1382372

URL: http://svn.apache.org/viewvc?rev=1382372view=rev
Log:
fixed test which randomly fail on slow CI server

Modified:

camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpShutdownCompleteCurrentTaskOnlyTest.java

Modified: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpShutdownCompleteCurrentTaskOnlyTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpShutdownCompleteCurrentTaskOnlyTest.java?rev=1382372r1=1382371r2=1382372view=diff
==
--- 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpShutdownCompleteCurrentTaskOnlyTest.java
 (original)
+++ 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpShutdownCompleteCurrentTaskOnlyTest.java
 Sat Sep  8 21:46:50 2012
@@ -56,6 +56,7 @@ public class FtpShutdownCompleteCurrentT
 
 MockEndpoint bar = getMockEndpoint(mock:bar);
 bar.expectedMinimumMessageCount(1);
+Thread.sleep(50);
 
 assertMockEndpointsSatisfied();