Re: Camel 2.9.0 integration with CXF2.5.1 Help

2012-01-19 Thread Willem Jiang
Although CXF 2.5.1 is built with JDK 1.5, as the Camel 2.9 is moved to 
JDK 1.6.

You'd better use JDK 1.6 to run your application.

On Thu Jan 19 11:27:54 2012, Claus Ibsen wrote:

Hi

You got both some CXF 2.4 and 2.5 files on the classpath.
And it seems like a JDK 5 and 6 issues as well. Make sure you run on JDK6.


On Thu, Jan 19, 2012 at 4:08 AM, sramsra...@hotmail.com  wrote:

I was successful integrating CXF2.4.1-Camel2.8.0, however when I moved to the
newer version of CXF2.5.1 and Camel 2.9.0, I see issues related to
CamelTransportFactory. UnsupportedClassVersionError. These dependency jars
work with older version. Am i missing any?

Dependency Jars included in my project:
Manifest-Version: 1.0
Class-Path: lib/spring-3.0.5/aopalliance-1.0.jar
  lib/jakarta-commons/commons-collections-3.2.1.jar
  lib/jakarta-commons/commons-lang-2.6.jar
  lib/jakarta-commons/commons-logging-1.1.1.jar
  lib/jax-ws-2.1/geronimo-jaxws_2.2_spec-1.0.jar
  lib/jax-ws-2.1/geronimo-ws-metadata_2.0_spec-1.1.3.jar
  lib/jax-ws-2.1/saaj-api-1.3.jar
  lib/jax-ws-2.1/saaj-impl-1.3.2.jar
  lib/jaxb-2.2.1/jaxb-api-2.2.1.jar
  lib/jaxb-2.2.1/jaxb-impl-2.2.1.1.jar
  lib/jaxb-2.2.1/jaxb-xjc-2.2.1.1.jar
  lib/ws-security-1.1/bcprov-jdk15-140.jar
  lib/ws-security-1.1/serializer-2.7.1.jar
  lib/ws-security-1.1/wss4j-1.6.0.jar
  lib/ws-security-1.1/xalan-2.7.1.jar
  lib/ws-security-1.1/xmlsec-1.4.4.jar
  lib/jakarta-commons/commons-httpclient-3.1.jar
  lib/log4j-1.2.15.jar
  lib/jakarta-commons/commons-jxpath-1.3.jar
  lib/jakarta-commons/commons-pool-1.5.7.jar
  lib/spring-3.0.5/cglib-nodep-2.1_3.jar
  lib/trunk_09012012/javaEwbCommon.jar
  lib/cxf-2.4.0/jsr311-api-1.1.1.jar
  lib/cxf-2.4.0/wsdl4j-1.6.2.jar
  lib/cxf-2.4.0/wstx-asl-3.2.6.jar
  lib/cxf-2.4.0/xml-resolver-1.2.jar
  lib/cxf-2.4.0/xmlschema-core-2.0.jar
  lib/jakarta-commons/commons-codec-1.4.jar
  lib/cxf-2.5.x/camel-core-2.9.0.jar
  lib/cxf-2.5.x/camel-cxf-2.9.0.jar
  lib/cxf-2.5.x/camel-http-2.9.0.jar
  lib/cxf-2.5.x/camel-spring-2.9.0.jar
  lib/cxf-2.5.x/cxf-2.5.1.jar
  lib/cxf-2.5.x/spring-aop-3.0.6.RELEASE.jar
  lib/cxf-2.5.x/spring-beans-3.0.6.RELEASE.jar
  lib/cxf-2.5.x/spring-context-3.0.6.RELEASE.jar
  lib/cxf-2.5.x/spring-core-3.0.6.RELEASE.jar
  lib/cxf-2.5.x/spring-expression-3.0.6.RELEASE.jar
  lib/cxf-2.5.x/spring-web-3.0.6.RELEASE.jar
  lib/cxf-2.5.1/neethi-3.0.1.jar
  lib/cxf-2.5.1/cxf-rt-core-2.5.1.jar
  lib/cxf-2.5.1/geronimo-activation_1.1_spec-1.1.jar
  lib/cxf-2.5.1/geronimo-annotation_1.0_spec-1.1.1.jar
  lib/cxf-2.5.1/geronimo-stax-api_1.0_spec-1.0.1.jar
  lib/cxf-2.5.1/jsr311-api-1.1.1.jar
  lib/cxf-2.5.1/xmlschema-core-2.0.jar
  lib/cxf-2.5.x/cxf-api-2.5.1.jar
  lib/cxf-2.5.x/cxf-rt-bindings-soap-2.5.1.jar
  lib/cxf-2.5.x/cxf-rt-core-2.5.1.jar
  lib/cxf-2.5.x/camel-cxf-transport-2.9.0.jar
  lib/cxf-2.5.x/slf4j-api-1.6.2.jar
  lib/cxf-2.5.x/spring-asm-3.0.6.RELEASE.jar
  lib/cxf-2.5.x/stax2-api-3.1.1.jar
  lib/cxf-2.5.x/woodstox-core-asl-4.1.1.jar


Error when starting the server,

[1/18/12 21:58:59:398 EST] 00ee ContextLoader E
org.springframework.web.context.ContextLoader initWebApplicationContext
Context initialization failed

org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'cxf' defined in class path resource [META-INF/cxf/cxf.xml]:
Instantiation of bean failed; nested exception is
org.springframework.beans.BeanInstantiationException: Could not instantiate
bean class [org.apache.cxf.bus.spring.SpringBus]: Constructor threw
exception; nested exception is java.lang.UnsupportedClassVersionError:
(org/apache/camel/component/cxf/transport/CamelTransportFactory) bad major
version at offset=6
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:965)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at

Testing headers in multiple messages

2012-01-19 Thread developpef
I recently saw the jira CAMEL-4159 but it is not what I expected : this issue
is intended to let a test expect for multiple headers in ONE message.
What I needed is the following : I know that a given endpoint will receive 3
messages in any order, and I need to test ONE header in each of these
messages.

I wrote :
getMockEndpoint(mock:zipSHP).expectedHeaderReceived(zippedFile,
001.zip);
getMockEndpoint(mock:zipSHP).expectedHeaderReceived(zippedFile,
002.zip);
getMockEndpoint(mock:zipSHP).expectedHeaderReceived(zippedFile,
003.zip);

for the route :
for(file://filesToBeZipped/).to(bean:my.bean.ZipperBean).log(Zipped :
...);

The endpoint effectively received the three messages (the results of three
ZIP operations) but the test failed saying that the first message header was
003.zip and not the expected 001.zip.

Is there a way to test this kind of action?


--
View this message in context: 
http://camel.465427.n5.nabble.com/Testing-headers-in-multiple-messages-tp5157167p5157167.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Single request with multiple replies over TCP

2012-01-19 Thread jonv
If you cant wait for the new mina component you will have to write your own
camel component to do this - at least that is what I ended up doing!
Im new to camel so what I did cannot have the best implementation strategy,
so I will probably replace with the mentioned mina2 component. However a
brief explanation of what I did is below that may be of some help to you:

An example config is below:

camelContext xmlns=http://camel.apache.org/schema/spring; trace=false
route id=Client2Server
  from
uri=myTCPComp://localhost:1?respEp=respPathOutamp;bufferSize=8192/
  log message=Msg from Client to
Server /
  to
uri=myTCPComp://localhost:2?respEp=vm:respPathInamp;bufferSize=8192/
/route

route id=Server2Client
  from uri=vm:respPathIn/
  log message=Msg from Server to Client
 /
  to uri=vm:respPathOut/
/route
  /camelContext

The 'myTCPComp' consumer creates a TCP Server on localhost:1. This also
creates another consumer for the responses - here respPathOut. Any messages
received by vm:respPathOut is returned to the TCP client.
The 'myTCPComp' producer creates a TCP client connecting on localhost:2.
Any responses will be written to vm:respPathIn.

Also if no manipulation is required for the return messages, and I dont set
the respEp parameter on the uri my code uses a default endpoint for the
responses (so the endpoint vm:default is created by the camel consumer and
messages sent to it from the camel producer. Giving just...

camelContext xmlns=http://camel.apache.org/schema/spring; trace=false
route id=Client2Server
  from uri=myTCPComp://localhost:1/
  log message=Msg from Client to
Server /
  to uri=myTCPComp://localhost:2/
/route
/camelContext

Which will do the same as the first example without the response log message
being written.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Single-request-with-multiple-replies-over-TCP-tp5022206p5157169.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Missing schema file in a cookbook article

2012-01-19 Thread Andreas Feldmann
Thanks a lot. My eclipse complained about the missing schema.

I added your suggested jar by:

dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-cxf-transport/artifactId
version${camel-version}/version
/dependency

--
View this message in context: 
http://camel.465427.n5.nabble.com/Missing-schema-file-in-a-cookbook-article-tp5128466p5157243.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Testing headers in multiple messages

2012-01-19 Thread Claus Ibsen
Hi

So you mock endpoint receives 3 messages in any order.
And you just want to test that those 3 messages has all together those
3 different headers?

We got that on the body, where you can say expectedBodiesReceivedInAnyOrder

We may consider a similar for the headers.


You can configure the file endpoint to sort the files before hand, so
from(file://filesToBeZipped/?sortBy=file:name)...

Then the headers should be in order.

Fell free to create a JIRA ticket about the expectedHeadersReceivedInAnyOrder
Link to JIRA from here
http://camel.apache.org/support


On Thu, Jan 19, 2012 at 10:10 AM, developpef src...@orange.fr wrote:
 I recently saw the jira CAMEL-4159 but it is not what I expected : this issue
 is intended to let a test expect for multiple headers in ONE message.
 What I needed is the following : I know that a given endpoint will receive 3
 messages in any order, and I need to test ONE header in each of these
 messages.

 I wrote :
 getMockEndpoint(mock:zipSHP).expectedHeaderReceived(zippedFile,
 001.zip);
 getMockEndpoint(mock:zipSHP).expectedHeaderReceived(zippedFile,
 002.zip);
 getMockEndpoint(mock:zipSHP).expectedHeaderReceived(zippedFile,
 003.zip);

 for the route :
 for(file://filesToBeZipped/).to(bean:my.bean.ZipperBean).log(Zipped :
 ...);

 The endpoint effectively received the three messages (the results of three
 ZIP operations) but the test failed saying that the first message header was
 003.zip and not the expected 001.zip.

 Is there a way to test this kind of action?


 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Testing-headers-in-multiple-messages-tp5157167p5157167.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/


spagic and Camel

2012-01-19 Thread jmh
Hello, 

simple quesiton : is it possible to use Spagic to monitor Camel components ?

Regards
J-M

--
View this message in context: 
http://camel.465427.n5.nabble.com/spagic-and-Camel-tp5157280p5157280.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Testing headers in multiple messages

2012-01-19 Thread developpef
Thank you for this hint. I will open a JIRA for this.

Yes I think that this point might be comparable to
expectedBodiesReceivedInAnyOrder.
I will try your solution, but I would prefer not to modify the prodution
ready route, even if it's not an important change.

-
http://developpef.blogspot.com
--
View this message in context: 
http://camel.465427.n5.nabble.com/Testing-headers-in-multiple-messages-tp5157167p5157279.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Testing headers in multiple messages

2012-01-19 Thread developpef
FYI, I opened CAMEL-4919

-
http://developpef.blogspot.com
--
View this message in context: 
http://camel.465427.n5.nabble.com/Testing-headers-in-multiple-messages-tp5157167p5157294.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Testing: MockEndpoint has sometimes a Message and sometimes not

2012-01-19 Thread Andreas Feldmann
Hallo everbody,

currently I am using JUnit-tests for testing purposes.

In my project I have a route with a software-proxy (Jetty) and then some
webservices. That part is working very well. The software-proxy/webservices
respond with the according messages, when I use SOAP-UI.

Now I tried to construct a test-route in a JUnit-test.

It looks like that:

from(SEDA_TEST).
setHeader(CamelHttpMethod, constant(POST)).
to(https4://localhost:8090/services/MYSERVICE?q=ssl).
to(seda:mock);

from(seda:mock).
streamCaching().
convertBodyTo(String.class, UTF-8).
to(MOCK_ENDPOINT);

I have constructed several tests where I send a message with:

template.sendBody(SEDA_TEST, testFileAsString);

And then I check the MOCK_ENDPOINT via expectedMessagesMatches, if my
expected response is available.

This works fine with some tests. But some tests fail very often, because the
response is empty. The problem confuses me even more, because the
production-route logs every time a message with the correct response as a
file.

So why do I get a empty message back from
to(https4://localhost:8090/services/MYSERVICE?q=ssl).?

I also have to mention, that sometimes there is message and sometimes the
message is empty.

What do you think?

Thanks for any suggestions!

Best regards,

Andreas Feldmann



--
View this message in context: 
http://camel.465427.n5.nabble.com/Testing-MockEndpoint-has-sometimes-a-Message-and-sometimes-not-tp5157327p5157327.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Howto use maxMessagesPerPoll and sortBy for file-consumer

2012-01-19 Thread Hartmut Lang
Hi,

what i see from https://issues.apache.org/jira/browse/CAMEL-2899 is that 
maxMessagesPerPoll and sortBy option do not work well together for a 
FileConsumer endpoint.

In our use-case we have several thousand files in a from(file:...) route. And 
every minute we want to process one file sorted by name.
So we use the options: delay=6maxMessagesPerPoll=1sortBy=file:name

But the way it seems to be implemented is:
- read one file from fileystem
- sort this file by name (so nothing happens here)
- process this file

The sortBy does not have any effect here, right?

Can someone propose another solution where we can have the files processed 
sorted by-name and also control how fast they are processed?

Thanks,
Hartmut



Re: Howto use maxMessagesPerPoll and sortBy for file-consumer

2012-01-19 Thread Claus Ibsen
On Thu, Jan 19, 2012 at 11:57 AM, Hartmut Lang
hartmut.l...@ericsson.com wrote:
 Hi,

 what i see from https://issues.apache.org/jira/browse/CAMEL-2899 is that 
 maxMessagesPerPoll and sortBy option do not work well together for a 
 FileConsumer endpoint.

 In our use-case we have several thousand files in a from(file:...) route. 
 And every minute we want to process one file sorted by name.
 So we use the options: delay=6maxMessagesPerPoll=1sortBy=file:name

 But the way it seems to be implemented is:
 - read one file from fileystem
 - sort this file by name (so nothing happens here)
 - process this file

 The sortBy does not have any effect here, right?


Yes it used to sort before limiting. But then we had people with
100's of files, which took to long time to sort, as the sorting
was in-memory. And the FTP component re-uses the logic, and the ftp
file entries eat up more memory, so that was even slower.

So the file component will limit first, then sort afterwards.


 Can someone propose another solution where we can have the files processed 
 sorted by-name and also control how fast they are processed?

 Thanks,
 Hartmut




-- 
Claus Ibsen
-
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/


RE: Howto use maxMessagesPerPoll and sortBy for file-consumer

2012-01-19 Thread Hartmut Lang
Ok,

maybe it's a good idea to add this to the documentation for file2, Sorting 
using sortBy section.  

Thanks,
Hartmut Lang

-Original Message-
From: Claus Ibsen [mailto:claus.ib...@gmail.com] 
Sent: Donnerstag, 19. Januar 2012 12:02
To: users@camel.apache.org
Subject: Re: Howto use maxMessagesPerPoll and sortBy for file-consumer

On Thu, Jan 19, 2012 at 11:57 AM, Hartmut Lang hartmut.l...@ericsson.com 
wrote:
 Hi,

 what i see from https://issues.apache.org/jira/browse/CAMEL-2899 is that 
 maxMessagesPerPoll and sortBy option do not work well together for a 
 FileConsumer endpoint.

 In our use-case we have several thousand files in a from(file:...) route. 
 And every minute we want to process one file sorted by name.
 So we use the options: 
 delay=6maxMessagesPerPoll=1sortBy=file:name

 But the way it seems to be implemented is:
 - read one file from fileystem
 - sort this file by name (so nothing happens here)
 - process this file

 The sortBy does not have any effect here, right?


Yes it used to sort before limiting. But then we had people with 100's of 
files, which took to long time to sort, as the sorting was in-memory. And the 
FTP component re-uses the logic, and the ftp file entries eat up more memory, 
so that was even slower.

So the file component will limit first, then sort afterwards.


 Can someone propose another solution where we can have the files processed 
 sorted by-name and also control how fast they are processed?

 Thanks,
 Hartmut




--
Claus Ibsen
-
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/


Re: Howto use maxMessagesPerPoll and sortBy for file-consumer

2012-01-19 Thread Claus Ibsen
On Thu, Jan 19, 2012 at 12:07 PM, Hartmut Lang
hartmut.l...@ericsson.com wrote:
 Ok,

 maybe it's a good idea to add this to the documentation for file2, Sorting 
 using sortBy section.


Added a note to the maxMessagesPorPoll option, as its the one which
causes this limitation.


 Thanks,
 Hartmut Lang

 -Original Message-
 From: Claus Ibsen [mailto:claus.ib...@gmail.com]
 Sent: Donnerstag, 19. Januar 2012 12:02
 To: users@camel.apache.org
 Subject: Re: Howto use maxMessagesPerPoll and sortBy for file-consumer

 On Thu, Jan 19, 2012 at 11:57 AM, Hartmut Lang hartmut.l...@ericsson.com 
 wrote:
 Hi,

 what i see from https://issues.apache.org/jira/browse/CAMEL-2899 is that 
 maxMessagesPerPoll and sortBy option do not work well together for a 
 FileConsumer endpoint.

 In our use-case we have several thousand files in a from(file:...) route. 
 And every minute we want to process one file sorted by name.
 So we use the options:
 delay=6maxMessagesPerPoll=1sortBy=file:name

 But the way it seems to be implemented is:
 - read one file from fileystem
 - sort this file by name (so nothing happens here)
 - process this file

 The sortBy does not have any effect here, right?


 Yes it used to sort before limiting. But then we had people with 100's of 
 files, which took to long time to sort, as the sorting was in-memory. And the 
 FTP component re-uses the logic, and the ftp file entries eat up more memory, 
 so that was even slower.

 So the file component will limit first, then sort afterwards.


 Can someone propose another solution where we can have the files processed 
 sorted by-name and also control how fast they are processed?

 Thanks,
 Hartmut




 --
 Claus Ibsen
 -
 FuseSource
 Email: cib...@fusesource.com
 Web: http://fusesource.com
 Twitter: davsclaus, fusenews
 Blog: http://davsclaus.blogspot.com/
 Author of Camel in Action: http://www.manning.com/ibsen/



-- 
Claus Ibsen
-
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/


Re: Camel sftp endpoint and exception handling.

2012-01-19 Thread Raul
I have a similar problem. (.GenericFileOnCompletion)

[ad #0 - ftp://localhost/origen] GenericFileOnCompletionERROR Caused
by: [org.apache.camel.component.file.GenericFileOperationFailedException -
File operation failed:  Software caused connection abort: socket write
error. Code: 250]

In my case, I use a ftp URI with the parametrer move=.done

The route is something like that from(ftp...).to(bean)

In the ftp server there are 5 files. I am testing the route. During the
test, I permit that the first file finishes ok. but when the route is
processing the second file, I let  the file to be received completly and
when the bean is processing y shutdown the ftp server. In this moment the
exception appears because the route can not move the file in the server.

I am using a  DefaultPollingConsumerPollStrategy with ftp. The poll of the
route finishes with COMMIT, instead with a Rollback. I was expecting that
Rollback was executed and then I could catch the exception.

¿Is it posible to control this exception with
DefaultPollingConsumerPollStrategy?

Thank  you.


--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-sftp-endpoint-and-exception-handling-tp5114385p5157565.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Sending a ArrayListObject takes so long ?

2012-01-19 Thread ricardofaccioli
Hello,

When I send one ArrayListObjects with a size about 150  in :

exchange.getOut().setBody();

My app(client) stuck and  don`t receive the message:

Producer producer = endpoint.createProducer();
producer.start();
producer.process(exchange);
producer.stop();
ListResourceProperties response = new
ArrayListResourceProperties();
response = (ListResourceProperties) exchange.getOut().getBody();


if I send only one object I receive without a problem.


Tks


--
View this message in context: 
http://camel.465427.n5.nabble.com/Sending-a-ArrayList-Object-takes-so-long-tp5157568p5157568.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Keep the routes created dynamically after restarting

2012-01-19 Thread Nicolas Gapaillard
Hi all,

Is is something in camel that permits to persist the routes created
dynamically in bdd or an xml file ?

Because for now, I have an application that permits to instanciate new
routes inside camel via the RoutesBuilder. It works very well. But if camel
is restarted, I lose all my already defined routes.

I searched inside the documentation and I didn't see anything about that.

For info, I use the 2.9.0 version of apache camel.

If someone has an idea.

Thank you.



-- 
Nicolas Gapaillard
nicolas.gapaill...@gmail.com


Re: Sending a ArrayListObject takes so long ?

2012-01-19 Thread Babak Vahdat
Hi,

Could you be please more precise about the problem you're facing? Is the
line:

exchange.getOut().setBody(); 

part of your *own* implemented Producer logic? If not which Camel component
do you make use of?

And along the 2 lines:

ListResourceProperties response = new ArrayListResourceProperties();
response = (ListResourceProperties) exchange.getOut().getBody();

Why do you assign the response reference to an ArrayList object if you
assign it right afterwards on the second line to be the Body content of the
Out Message?

Babak

--
View this message in context: 
http://camel.465427.n5.nabble.com/Sending-a-ArrayList-Object-takes-so-long-tp5157568p5157593.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Sending a ArrayListObject takes so long ?

2012-01-19 Thread ricardofaccioli
Hello:

My Broker receive a message and generate a list of Objects:

 from(seda:analisarColeta?concurrentConsumers= +
execucoesSimultaneas).process(new Processor() {
public void process(Exchange exchange) throws Exception {
AnalisarColetaReq req = (AnalisarColetaReq)
exchange.getIn().getBody();
Executer exec = new Executer();
exchange.getOut().setBody(exec.analisarColeta(req));
}
});


The problem is my client:



Endpoint endpoint =
com.vpidata.ibope.broker.stuffs.CamelStart.camelContext.getEndpoint(activemq:analisarColeta
+ campanha.servidor.id + :analisarColeta);
Exchange exchange = endpoint.createExchange(ExchangePattern.InOut);
exchange.getIn().setBody(req);
Producer producer = endpoint.createProducer();
producer.start();

 // In this part my app stuck, Broker receive the message, process but I
can't get de out.
producer.process(exchange);
producer.stop();
ListResourceProperties response = new
ArrayListResourceProperties();
response = (ListResourceProperties) exchange.getOut().getBody();

I think this happens because it`s a heavy array list sended 

--
View this message in context: 
http://camel.465427.n5.nabble.com/Sending-a-ArrayList-Object-takes-so-long-tp5157568p5157612.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Keep the routes created dynamically after restarting

2012-01-19 Thread Claus Ibsen
Hi

Yeah can export the routes as XML, and then load them upon restart.

A little example to load the routes
http://camel.apache.org/loading-routes-from-xml-files.html

Then to save them is also fairly easy.



On Thu, Jan 19, 2012 at 1:55 PM, Nicolas Gapaillard
nicolas.gapaill...@gmail.com wrote:
 Hi all,

 Is is something in camel that permits to persist the routes created
 dynamically in bdd or an xml file ?

 Because for now, I have an application that permits to instanciate new
 routes inside camel via the RoutesBuilder. It works very well. But if camel
 is restarted, I lose all my already defined routes.

 I searched inside the documentation and I didn't see anything about that.

 For info, I use the 2.9.0 version of apache camel.

 If someone has an idea.

 Thank you.



 --
 Nicolas Gapaillard
 nicolas.gapaill...@gmail.com



-- 
Claus Ibsen
-
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/


Re: Asynchronous Netty Server And CAMEL

2012-01-19 Thread rbucker
Did you get a response to this? The example you propose is so commonplace
when doing system integration without HTTP; just raw sockets... That I
cannot imagine that it's going to be this hard to get a sample.

--
View this message in context: 
http://camel.465427.n5.nabble.com/Asynchronous-Netty-Server-And-CAMEL-tp3302581p5157761.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Sending a ArrayListObject takes so long ?

2012-01-19 Thread ricardofaccioli
Babak,

Yes my broker have a active mq:


from(activemq:analisarColeta1:analisarColeta).to(seda:analisarColeta?concurrentConsumers=
+ execucoesSimultaneas);


I finally fix the problem!
The class ResourceProperties in client side, I forgot the implements
Serializable. =[
When I done this the problem gone.
Tks for your attention.


--
View this message in context: 
http://camel.465427.n5.nabble.com/Sending-a-ArrayList-Object-takes-so-long-tp5157568p5157802.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel under OSGi without Spring et al.

2012-01-19 Thread metatech
Hi,

My previous conclusion was not correct.
The Camel initialization happens indeed in the addingBundle method, but is
called from a SynchronousBundleListener, in the same thread that activates
the bundle, and there is only one thread (FelixStartlevel) that activates
all feature bundles, so it should it should fully initialized.

However, when the problem happens, the following error is logged : 
2012-01-19 09:35:41,655 | INFO  | ExtenderThread-5 |  |
CamelNamespaceHandler| OSGi environment not detected.

This can happen if the OSGi activator of the bundle camel-spring was not
executed before the Camel context is starting.  In SMX 4.4, camel-spring is
at start-level 50, and applications are at start-level 60, so the activator
is meant to be completed before applications are starting.

However, during the first start-up, or when the bundle cache is cleaned up,
the bundles delivered as Karaf features are installed in parallel with the
deployment of applications in the deploy directory.  This can explain that
the camel-spring (not yet installed at level 50) is executed after some
applications are starting.

The only solution I can think of is that the bundle cache should be built in
a first phase, then the bundle are started in a second phase.

Regards,

metatech




metatech wrote
 
 However, the Camel initialization is not finished yet, it is performed in
 the addingBundle method, which registers Camel components, languages,
 type converters, ...
 


--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-under-OSGi-without-Spring-et-al-tp4507473p5157820.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel under OSGi without Spring et al.

2012-01-19 Thread Donald Whytock
It may be a matter of personal taste, but I disagree with reliance on
start levels.  It should be more reliable to use a BundleListener to
track whether a particular bundle has loaded, or a ServiceTracker with
the bundle being watched for launching a here I am service when
initialization is complete.

Don

On Thu, Jan 19, 2012 at 9:39 AM, metatech metatec...@gmail.com wrote:
 Hi,

 My previous conclusion was not correct.
 The Camel initialization happens indeed in the addingBundle method, but is
 called from a SynchronousBundleListener, in the same thread that activates
 the bundle, and there is only one thread (FelixStartlevel) that activates
 all feature bundles, so it should it should fully initialized.

 However, when the problem happens, the following error is logged :
 2012-01-19 09:35:41,655 | INFO  | ExtenderThread-5 |  |
 CamelNamespaceHandler            | OSGi environment not detected.

 This can happen if the OSGi activator of the bundle camel-spring was not
 executed before the Camel context is starting.  In SMX 4.4, camel-spring is
 at start-level 50, and applications are at start-level 60, so the activator
 is meant to be completed before applications are starting.

 However, during the first start-up, or when the bundle cache is cleaned up,
 the bundles delivered as Karaf features are installed in parallel with the
 deployment of applications in the deploy directory.  This can explain that
 the camel-spring (not yet installed at level 50) is executed after some
 applications are starting.

 The only solution I can think of is that the bundle cache should be built in
 a first phase, then the bundle are started in a second phase.

 Regards,

 metatech




 metatech wrote

 However, the Camel initialization is not finished yet, it is performed in
 the addingBundle method, which registers Camel components, languages,
 type converters, ...



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Camel-under-OSGi-without-Spring-et-al-tp4507473p5157820.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


Re: using values from a properties-file in setHeader-method

2012-01-19 Thread ebinsingh
Hi All,

I am trying to set few header's, but does not seem to work. 
I guess I am missing something but not able to find that out.
The below logs age not printted in the log file.

route
  from ref=acquireltel2 /
setHeader
headerName=pathNamesimple${file:path}/simple/setHeader
  log message=set header pathName to ${file:path}
loggingLevel=INFO/
setHeader
headerName=fileNamesimple${file:name}/simple/setHeader
  log message=set header fileName to ${file:name}
loggingLevel=INFO/
setHeader headerName=fileTypeconstantltel2/constant/setHeader
  log message=set header fileType to ltel2 loggingLevel=INFO/
  to ref=producerQueue/
/route

Appriciate your help.

Ebe

--
View this message in context: 
http://camel.465427.n5.nabble.com/using-values-from-a-properties-file-in-setHeader-method-tp5154287p5157868.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Keep the routes created dynamically after restarting

2012-01-19 Thread Claus Ibsen
Hi

Just marshal the routes to XML *before* you add new routes dynamic.


On Thu, Jan 19, 2012 at 3:59 PM, Nicolas Gapaillard
nicolas.gapaill...@gmail.com wrote:
 Hi,

 Thank you for your answer,

 I'm not sure it is really adapted to my problem.

 Because I need to export automatically, not manually. I want that my camel
 server has always the last routes. For example, if my camel server crashes,
 I want to keep all the routes created before the crashe.

 Or maybe I can use your solution plugged on a new implementation of a camel
 lifecycleStrategy:

 - Export for each route creation/deletion using my own camel
 LifecycleStrategy implementation.
 - And load all routes during the camel context startup.

 It means that performance will be slower = it is necessary to marshall the
 xml for each route creation/deletion (ok it is not so critical in my case I
 think).

  But it seems to me a complex solution for a problem that looks simple.

 If someone has an other way to investigate or say me that there isn't
 another solution, don't hesitate.

 Thank you.











 2012/1/19 Claus Ibsen claus.ib...@gmail.com

 Hi

 Yeah can export the routes as XML, and then load them upon restart.

 A little example to load the routes
 http://camel.apache.org/loading-routes-from-xml-files.html

 Then to save them is also fairly easy.



 On Thu, Jan 19, 2012 at 1:55 PM, Nicolas Gapaillard
 nicolas.gapaill...@gmail.com wrote:
  Hi all,
 
  Is is something in camel that permits to persist the routes created
  dynamically in bdd or an xml file ?
 
  Because for now, I have an application that permits to instanciate new
  routes inside camel via the RoutesBuilder. It works very well. But if
 camel
  is restarted, I lose all my already defined routes.
 
  I searched inside the documentation and I didn't see anything about that.
 
  For info, I use the 2.9.0 version of apache camel.
 
  If someone has an idea.
 
  Thank you.
 
 
 
  --
  Nicolas Gapaillard
  nicolas.gapaill...@gmail.com



 --
 Claus Ibsen
 -
 FuseSource
 Email: cib...@fusesource.com
 Web: http://fusesource.com
 Twitter: davsclaus, fusenews
 Blog: http://davsclaus.blogspot.com/
 Author of Camel in Action: http://www.manning.com/ibsen/




 --
 Nicolas Gapaillard
 nicolas.gapaill...@gmail.com



-- 
Claus Ibsen
-
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/


Re: using values from a properties-file in setHeader-method

2012-01-19 Thread ebinsingh
I see something strange here.
If I have the below to routes, the logginf works perfectly.
route
from ref=acquireltel2 /
setHeader 
headerName=pathNamesimple${file:path}/simple/setHeader
log message=set header pathName to ${file:path} 
loggingLevel=INFO/
setHeader 
headerName=fileNamesimple${file:name}/simple/setHeader
log message=set header fileName to ${file:name} 
loggingLevel=INFO/
setHeader 
headerName=fileTypeconstantltel2/constant/setHeader
log message=set header fileType to ltel2 
loggingLevel=INFO/
to ref=producerQueue/
/route
route
from ref=producerQueue/
log message=Processing messege out of producerQueue 
${file:name}  
${file:path} loggingLevel=INFO/
to uri=jms:queue:test_request_2/
/route

But *NOT* if I have the second route as below. Do not know what difference
it makes in the flow.
I am not seeing any of the logs.


route
from ref=producerQueue/
log message=Processing messege out of producerQueue
loggingLevel=INFO/
choice
when
simple${header.fileType} == ltel2/simple
log message=processing ltel2 file type 
loggingLevel=INFO /
threads executorServiceRef=ltel2threadpool1
bean ref=ltel2Consumer 
method=doConsume /
/threads
/when
/choice
/route


Also please adive if the above Choice evaluation is correct. 

--
View this message in context: 
http://camel.465427.n5.nabble.com/using-values-from-a-properties-file-in-setHeader-method-tp5154287p5157928.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Testing: MockEndpoint has sometimes a Message and sometimes not

2012-01-19 Thread Claus Ibsen
I suggest to convert the result of http4 to a String before sending to
the seda queue.

For example if processing the messages happens much later, and the
http connection has been closed, and the input stream is closed and
returns no data.


On Thu, Jan 19, 2012 at 11:38 AM, Andreas Feldmann
andi.feldm...@gmail.com wrote:
 Hallo everbody,

 currently I am using JUnit-tests for testing purposes.

 In my project I have a route with a software-proxy (Jetty) and then some
 webservices. That part is working very well. The software-proxy/webservices
 respond with the according messages, when I use SOAP-UI.

 Now I tried to construct a test-route in a JUnit-test.

 It looks like that:

 from(SEDA_TEST).
 setHeader(CamelHttpMethod, constant(POST)).
 to(https4://localhost:8090/services/MYSERVICE?q=ssl).
 to(seda:mock);

 from(seda:mock).
 streamCaching().
 convertBodyTo(String.class, UTF-8).
 to(MOCK_ENDPOINT);

 I have constructed several tests where I send a message with:

 template.sendBody(SEDA_TEST, testFileAsString);

 And then I check the MOCK_ENDPOINT via expectedMessagesMatches, if my
 expected response is available.

 This works fine with some tests. But some tests fail very often, because the
 response is empty. The problem confuses me even more, because the
 production-route logs every time a message with the correct response as a
 file.

 So why do I get a empty message back from
 to(https4://localhost:8090/services/MYSERVICE?q=ssl).?

 I also have to mention, that sometimes there is message and sometimes the
 message is empty.

 What do you think?

 Thanks for any suggestions!

 Best regards,

 Andreas Feldmann



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Testing-MockEndpoint-has-sometimes-a-Message-and-sometimes-not-tp5157327p5157327.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/


Re: Keep the routes created dynamically after restarting

2012-01-19 Thread Claus Ibsen
Hi

And yes you can also use a LifecycleStrategy to keep track of those
events when routes is being added/removed.
And then do your store to database / remove from data stuff.


On Thu, Jan 19, 2012 at 3:59 PM, Nicolas Gapaillard
nicolas.gapaill...@gmail.com wrote:
 Hi,

 Thank you for your answer,

 I'm not sure it is really adapted to my problem.

 Because I need to export automatically, not manually. I want that my camel
 server has always the last routes. For example, if my camel server crashes,
 I want to keep all the routes created before the crashe.

 Or maybe I can use your solution plugged on a new implementation of a camel
 lifecycleStrategy:

 - Export for each route creation/deletion using my own camel
 LifecycleStrategy implementation.
 - And load all routes during the camel context startup.

 It means that performance will be slower = it is necessary to marshall the
 xml for each route creation/deletion (ok it is not so critical in my case I
 think).

  But it seems to me a complex solution for a problem that looks simple.

 If someone has an other way to investigate or say me that there isn't
 another solution, don't hesitate.

 Thank you.











 2012/1/19 Claus Ibsen claus.ib...@gmail.com

 Hi

 Yeah can export the routes as XML, and then load them upon restart.

 A little example to load the routes
 http://camel.apache.org/loading-routes-from-xml-files.html

 Then to save them is also fairly easy.



 On Thu, Jan 19, 2012 at 1:55 PM, Nicolas Gapaillard
 nicolas.gapaill...@gmail.com wrote:
  Hi all,
 
  Is is something in camel that permits to persist the routes created
  dynamically in bdd or an xml file ?
 
  Because for now, I have an application that permits to instanciate new
  routes inside camel via the RoutesBuilder. It works very well. But if
 camel
  is restarted, I lose all my already defined routes.
 
  I searched inside the documentation and I didn't see anything about that.
 
  For info, I use the 2.9.0 version of apache camel.
 
  If someone has an idea.
 
  Thank you.
 
 
 
  --
  Nicolas Gapaillard
  nicolas.gapaill...@gmail.com



 --
 Claus Ibsen
 -
 FuseSource
 Email: cib...@fusesource.com
 Web: http://fusesource.com
 Twitter: davsclaus, fusenews
 Blog: http://davsclaus.blogspot.com/
 Author of Camel in Action: http://www.manning.com/ibsen/




 --
 Nicolas Gapaillard
 nicolas.gapaill...@gmail.com



-- 
Claus Ibsen
-
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/


camel-ftp scheduling and limit polling

2012-01-19 Thread roughrotter
Hello everyone, 
i need to configure an ftp route that allow me to:

schedule starting, then dowload all file present on ftp server, if no file
present polling only for a limited times eg. every 5 seconds for an hour,
than if no file downloaded stop polling, stop route and send an email of
report.

I had used the quartz component to start the route and i can stop the route
processing the destination endpoint, but i cannot stop the consumer when
polling...

Can anyone help me.

Regards.

Marcello.

--
View this message in context: 
http://camel.465427.n5.nabble.com/camel-ftp-scheduling-and-limit-polling-tp5158013p5158013.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: camel-ftp scheduling and limit polling

2012-01-19 Thread Babak Vahdat
Hi,

maybe digging into the unit-tests, like in [1], could give you an idea how
to do that.

[1]
https://svn.apache.org/repos/asf/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote

Babak

--
View this message in context: 
http://camel.465427.n5.nabble.com/camel-ftp-scheduling-and-limit-polling-tp5158013p5158152.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Converting message body after GroupedExchangeAggregationStrategy

2012-01-19 Thread suman
Hello All,
This is my route
from(direct:getstreaminfo).startupOrder(2)
 .recipientList().method(MessageRouter.class,
routeTo).parallelProcessing().aggregationStrategy(new
GroupedExchangeAggregationStrategy()).convertBodyTo(String.class)
 .process(eventStreamedProcessor).to(log:foo);

Iam trying to get the list of exchanges in processor using
ListExchange exchangeList =
exchange.getProperty(Exchange.GROUPED_EXCHANGE, List.class);
But my problem is within each of the exchanges,the body is of type
CachedOutputStream.WrappedInputStream which i cant access.
So all i want is within each of the exchange present in the list,i want to
body to be of type String.Is it possible?

Thanks
Suman

--
View this message in context: 
http://camel.465427.n5.nabble.com/Converting-message-body-after-GroupedExchangeAggregationStrategy-tp5158191p5158191.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Redelivery with multiple transacted routes

2012-01-19 Thread kafe
Hi,

I have some problem to have a correct redelivery policy in my environment.
I work with transacted routes and i'd like to have 3 redelivery attempts if
any exception is raised.

I have the following routes :

route id=routeA
   from uri=activemq:queue:traiterReponse /
   onException useOriginalMessage=true
  exceptionjava.lang.Exception/exception
  redeliveryPolicy maximumRedeliveries=3 redeliveryDelay=5000 /
  handled
 constanttrue/constant
  /handled
  to uri=activemq:queue:pendingMessage /
   /onException
   *transacted /*
   bean ref=processor1 /
   to uri=direct:traiterReponse /
/route

route id=routeB
   from uri=direct:traiterReponse /
   bean ref=processor2 /
   to uri=log:output /
/route

If an exception is raised by the processor1, it works as expected, there are
3 attempts to redeliver the message and if it fails, the message is then
redirected to the 'pendingMessage' queue.

But the problem is if an exception is raised in processor2, then the message
is directly redirected in the 'ActiveMQ.DLQ' queue, there is no redelivery
attempt at all.

I expected the exception to be catched by the 'onException' clause of
routeA (if i'm right the 2 routes share the same transaction).

What is the problem ?

--
View this message in context: 
http://camel.465427.n5.nabble.com/Redelivery-with-multiple-transacted-routes-tp5158209p5158209.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel under OSGi without Spring et al.

2012-01-19 Thread Guillaume Nodet
Start-level can't really be trusted, especially if you use blueprint
for example, which does actually start the blueprint stuff
asynchronously.

On Thu, Jan 19, 2012 at 15:49, Donald Whytock dwhyt...@gmail.com wrote:
 It may be a matter of personal taste, but I disagree with reliance on
 start levels.  It should be more reliable to use a BundleListener to
 track whether a particular bundle has loaded, or a ServiceTracker with
 the bundle being watched for launching a here I am service when
 initialization is complete.

 Don

 On Thu, Jan 19, 2012 at 9:39 AM, metatech metatec...@gmail.com wrote:
 Hi,

 My previous conclusion was not correct.
 The Camel initialization happens indeed in the addingBundle method, but is
 called from a SynchronousBundleListener, in the same thread that activates
 the bundle, and there is only one thread (FelixStartlevel) that activates
 all feature bundles, so it should it should fully initialized.

 However, when the problem happens, the following error is logged :
 2012-01-19 09:35:41,655 | INFO  | ExtenderThread-5 |  |
 CamelNamespaceHandler            | OSGi environment not detected.

 This can happen if the OSGi activator of the bundle camel-spring was not
 executed before the Camel context is starting.  In SMX 4.4, camel-spring is
 at start-level 50, and applications are at start-level 60, so the activator
 is meant to be completed before applications are starting.

 However, during the first start-up, or when the bundle cache is cleaned up,
 the bundles delivered as Karaf features are installed in parallel with the
 deployment of applications in the deploy directory.  This can explain that
 the camel-spring (not yet installed at level 50) is executed after some
 applications are starting.

 The only solution I can think of is that the bundle cache should be built in
 a first phase, then the bundle are started in a second phase.

 Regards,

 metatech




 metatech wrote

 However, the Camel initialization is not finished yet, it is performed in
 the addingBundle method, which registers Camel components, languages,
 type converters, ...



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Camel-under-OSGi-without-Spring-et-al-tp4507473p5157820.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



-- 

Guillaume Nodet

Blog: http://gnodet.blogspot.com/

FuseSource, Integration everywhere
http://fusesource.com


Re: Issue with loading TypeConverter in Camel 2.8.2 on JBOSS 7.2

2012-01-19 Thread lavanya
Hi Babak,

Really appreciate your immediate response, due to licensing issues, we will
have to switch to JBoss 5.0, in which case, the camel-jboss would suffice. I
will give a try and update the forum.

Thanks once again.

--
View this message in context: 
http://camel.465427.n5.nabble.com/Issue-with-loading-TypeConverter-in-Camel-2-8-2-on-JBOSS-7-2-tp5155618p5158238.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Redelivery with multiple transacted routes

2012-01-19 Thread Babak Vahdat
Hi

sharing the same transaction boundary doesn't necessarily mean sharing the
same onException clause by two different routes.

In this case defining the onException clause at the global scope should
help. Check also [1] for the global  route specific scope definitions.

[1] http://camel.apache.org/exception-clause.html

Babak

--
View this message in context: 
http://camel.465427.n5.nabble.com/Redelivery-with-multiple-transacted-routes-tp5158209p5158253.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Redelivery with multiple transacted routes

2012-01-19 Thread kafe
The problem is that if i put an onException clause on the second route, when
there is a redelivery (after an exception raised by 'processor2'), it
directly starts at the point the exception was raised not at the beginning
of routeA.

--
View this message in context: 
http://camel.465427.n5.nabble.com/Redelivery-with-multiple-transacted-routes-tp5158209p5158284.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: camel-ftp scheduling and limit polling

2012-01-19 Thread roughrotter
i try to find how to limit polling but i can't find nothing about...

--
View this message in context: 
http://camel.465427.n5.nabble.com/camel-ftp-scheduling-and-limit-polling-tp5158013p5158303.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Redelivery with multiple transacted routes

2012-01-19 Thread kafe
Hum... actually this seems to be a normal behaviour :

Point of entry for redelivery attempts

All redelivery attempts start at the point of the failure. So the route:

.onException(ConnectException.class)
.from(direct:start)
 .process(processor1)
 .process(processor2) // --- throws a ConnectException
.to(mock:theEnd)

*Will retry from processor2 - not the complete route.* 

(http://camel.apache.org/exception-clause.html)

Thank you for your help.

--
View this message in context: 
http://camel.465427.n5.nabble.com/Redelivery-with-multiple-transacted-routes-tp5158209p5158304.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Redelivery with multiple transacted routes

2012-01-19 Thread Babak Vahdat
I didn't mean to put an onException() on the second route *but* on the global
scope, so something like:

onException useOriginalMessage=true
   exceptionjava.lang.Exception/exception
   redeliveryPolicy maximumRedeliveries=3 redeliveryDelay=5000 /
   handled
 constanttrue/constant
   /handled
   to uri=activemq:queue:pendingMessage /
/onException


route id=routeA
   from uri=activemq:queue:traiterReponse /
   transacted /
   bean ref=processor1 /
   to uri=direct:traiterReponse /
/route

route id=routeB
   from uri=direct:traiterReponse /
   bean ref=processor2 /
   to uri=log:output /
/route



--
View this message in context: 
http://camel.465427.n5.nabble.com/Redelivery-with-multiple-transacted-routes-tp5158209p5158309.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: camel-ftp scheduling and limit polling

2012-01-19 Thread roughrotter
i found the property sendEmptyMessageWhenIdle that can allow me to check in
process if no more file are present and stop route by it self.

But in that way i have to develop a custom pollingStrategy?





--
View this message in context: 
http://camel.465427.n5.nabble.com/camel-ftp-scheduling-and-limit-polling-tp5158013p5158344.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Redelivery with multiple transacted routes

2012-01-19 Thread Babak Vahdat
Yeah exactly, all redelivery attempts start at the point of the failure...

BTW this behaviour seems to me in synergy with the plain java where you
catch an Exception some where in your code and then you continue with the
logic right *after* the catch block and not necessarily from the first line
of your Main method :-)

Babak 

--
View this message in context: 
http://camel.465427.n5.nabble.com/Redelivery-with-multiple-transacted-routes-tp5158209p5158368.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Redelivery with multiple transacted routes

2012-01-19 Thread kafe
The remaining problem is that the thread that makes the redeliveries is
blocked until all redeliveries have been done.

Potentially, if the redeliveryPolicy is configured to redeliver undefinitely
(which will probably be my case in the future) and lot of messages arrive in
my initial ActiveMQ queue, the system could be down !?

Isn't it possible to have a redelivery policy in a transacted mode without
having the thread (ie an activeMQ consumer) blocked ?

--
View this message in context: 
http://camel.465427.n5.nabble.com/Redelivery-with-multiple-transacted-routes-tp5158209p5158388.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Keep the routes created dynamically after restarting

2012-01-19 Thread Nicolas Gapaillard
Hi,



Finally, I used my own LifecycleStrategy implementation to persist the
routes in xml files (onRoutesAdd,onRoutesRemove,onContextStart) .

For the route loading in the context I follow the link.
And for the marshalling i took example inside the
ModelHelper.dumpModelAsXml for the jaxb marshalling. And now it works like
a charm.

I'm just a little bit affraid by the deprecated methods:
CamelContext.loadRoutesDefinition and CamelContext.addRouteDefinitions.

:)

Thank you for the help.



2012/1/19 Claus Ibsen claus.ib...@gmail.com

 Hi

 Just marshal the routes to XML *before* you add new routes dynamic.


 On Thu, Jan 19, 2012 at 3:59 PM, Nicolas Gapaillard
 nicolas.gapaill...@gmail.com wrote:
  Hi,
 
  Thank you for your answer,
 
  I'm not sure it is really adapted to my problem.
 
  Because I need to export automatically, not manually. I want that my
 camel
  server has always the last routes. For example, if my camel server
 crashes,
  I want to keep all the routes created before the crashe.
 
  Or maybe I can use your solution plugged on a new implementation of a
 camel
  lifecycleStrategy:
 
  - Export for each route creation/deletion using my own camel
  LifecycleStrategy implementation.
  - And load all routes during the camel context startup.
 
  It means that performance will be slower = it is necessary to marshall
 the
  xml for each route creation/deletion (ok it is not so critical in my
 case I
  think).
 
   But it seems to me a complex solution for a problem that looks simple.
 
  If someone has an other way to investigate or say me that there isn't
  another solution, don't hesitate.
 
  Thank you.
 
 
 
 
 
 
 
 
 
 
 
  2012/1/19 Claus Ibsen claus.ib...@gmail.com
 
  Hi
 
  Yeah can export the routes as XML, and then load them upon restart.
 
  A little example to load the routes
  http://camel.apache.org/loading-routes-from-xml-files.html
 
  Then to save them is also fairly easy.
 
 
 
  On Thu, Jan 19, 2012 at 1:55 PM, Nicolas Gapaillard
  nicolas.gapaill...@gmail.com wrote:
   Hi all,
  
   Is is something in camel that permits to persist the routes created
   dynamically in bdd or an xml file ?
  
   Because for now, I have an application that permits to instanciate new
   routes inside camel via the RoutesBuilder. It works very well. But if
  camel
   is restarted, I lose all my already defined routes.
  
   I searched inside the documentation and I didn't see anything about
 that.
  
   For info, I use the 2.9.0 version of apache camel.
  
   If someone has an idea.
  
   Thank you.
  
  
  
   --
   Nicolas Gapaillard
   nicolas.gapaill...@gmail.com
 
 
 
  --
  Claus Ibsen
  -
  FuseSource
  Email: cib...@fusesource.com
  Web: http://fusesource.com
  Twitter: davsclaus, fusenews
  Blog: http://davsclaus.blogspot.com/
  Author of Camel in Action: http://www.manning.com/ibsen/
 
 
 
 
  --
  Nicolas Gapaillard
  nicolas.gapaill...@gmail.com



 --
 Claus Ibsen
 -
 FuseSource
 Email: cib...@fusesource.com
 Web: http://fusesource.com
 Twitter: davsclaus, fusenews
 Blog: http://davsclaus.blogspot.com/
 Author of Camel in Action: http://www.manning.com/ibsen/




-- 
Nicolas Gapaillard
nicolas.gapaill...@gmail.com


Re: unmarshalling but not marshalling?

2012-01-19 Thread david_good
Sure



--
View this message in context: 
http://camel.465427.n5.nabble.com/unmarshalling-but-not-marshalling-tp5152663p5158434.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Redelivery with multiple transacted routes

2012-01-19 Thread Babak Vahdat
Hi,

I just copypaste what the documentation says about this second question of
yours:

From Camel 2.4 onwards Camel has a feature to not block while waiting for a
delayed redelivery to occur. However if you use transacted routes then Camel
will block as its mandated by the transaction manager to execute all the
work in the same thread context. You can enable the non blocking
asynchronous behavior by the asyncDelayedRedelivery option. This option can
be set on the errorHandler, onException or the redelivery policies.
By default the error handler will create and use a scheduled thread pool to
trigger redelivery in the future. From Camel 2.8 onwards you can configure
the executorServiceRef on the Error Handler to indicate a reference to
either a shared thread pool you can enlist in the registry, or a thread pool
profile in case you want to be able to control pool settings.

Babak


--
View this message in context: 
http://camel.465427.n5.nabble.com/Redelivery-with-multiple-transacted-routes-tp5158209p5158521.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Issue with logging

2012-01-19 Thread ebinsingh
Hi All,

For some reason I am not able to see any of the logs defined in the below
route.
Appreciate your help in solving this.

Noticed that if I removed the choice from the second route, all the logging
appears in my log file.
I need to find out which choice loop is executed.


endpoint id=acquireltel2
uri=file:C:/camelProject/data/inbox?move=C:/camelProject/data/inbox/bkp /
endpoint id=producerQueue uri=direct:producerQueue/
endpoint id=dispatchltel2 uri=direct:dispatchltel2 /

route
from ref=acquireltel2 /
setHeader headerName=pathName
simple${file:path}/simple
/setHeader
setHeader headerName=fileName
simple${file:name}/simple
/setHeader
setHeader headerName=fileType
constantltel2/constant
/setHeader
log message=set header pathName to ${file:path} 
loggingLevel=INFO/
log message=set header fileName to ${file:name} 
loggingLevel=INFO/
log message=set header fileType to ltel2 ${header.fileType}
loggingLevel=INFO/
to ref=producerQueue/
/route

route
from ref=producerQueue/
log message=set header fileType to ltel2 ${header.fileType}
loggingLevel=INFO/
choice
when
simple${header.fileType} == ltel2/simple
log message=processing ltel2 file type 
loggingLevel=INFO /
threads executorServiceRef=ltel2threadpool1
bean ref=ltel2Consumer method=doConsume /
/threads
/when
when
simple${header.fileType} == ltel3/simple
log message=processing ltel3 file type 
loggingLevel=INFO /
/when
/choice
/route

Thanks  regards,
Ebe

--
View this message in context: 
http://camel.465427.n5.nabble.com/Issue-with-logging-tp5158558p5158558.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: What does 'Exchange ending ' mean

2012-01-19 Thread anand sridhar
Thank you Claus.
I will use the book to know more.

-Anand

On Wed, Jan 18, 2012 at 8:54 AM, Claus Ibsen claus.ib...@gmail.com wrote:

 Hi

 On Wed, Jan 18, 2012 at 12:03 AM, anand sridhar anand.for...@gmail.com
 wrote:
  I was hoping the community could help me understand the exact meaning of
  'Exchange ending' as mentioned in Camel Docs about
  DefaultErrorHandlerhttp://camel.apache.org/defaulterrorhandler.html
 

 The error handling documentation at Apache is a bit .. well not so
 well structured.

 ends means that the message will not continue being routed. So the
 routing breaks where the exception occurred, and the exception is
 propagated back to the consumer/caller.


 .
 
  For example, my route is as below -
 
  from(ftp://x.x.x.x.?consumer.delay=3;).
  .unmarshall().csv()
  .to(endpoint1)
  .to(endpoint2)
  .to(endpoint3)
  .end();
 
  The above route polls a FTP location for files every 30 seconds.  If at a
  certain instant , one of the stages of the route throws exception, will
  polling continue further. ?
  If not, could  some one advise the best strategy to continue polling. ?
 

 The FTP consumer is also a batch consumer
 http://camel.apache.org/batch-consumer.html

 Which means it pickup X inputs in a batch (eg a FTP consumer detects X
 number of files to download).
 And then it processes each file one by one, from the batch.

 So if one file fails to process and an exception is thrown. Then by
 default the FTP consumer will continue with the next file and so on.


 Error handling is a hard topic to get right. And there is no one-shoe
 size that fits all. So there is many knobs you can customize with
 Camel.

 Camel in Action book, chapter 5, has 34 pages all about error handling.




  Thanks,
  Anand



 --
 Claus Ibsen
 -
 FuseSource
 Email: cib...@fusesource.com
 Web: http://fusesource.com
 Twitter: davsclaus, fusenews
 Blog: http://davsclaus.blogspot.com/
 Author of Camel in Action: http://www.manning.com/ibsen/



Re: Issue with logging

2012-01-19 Thread Claus Ibsen
Hi

You have 2 when in the choice, which means if both when is false, then
it will pick otherwise. But you do not have that. So you will not see
anything.

Add an otherwise to have a log in case any of the when fails.

And the simple expression in Camel 2.8.x or earlier you must be a bit
more exact when using operators.
Camel 2.9 has a better syntax validator
http://davsclaus.blogspot.com/2011/09/camel-29-much-improved-simple-language.html







On Thu, Jan 19, 2012 at 7:44 PM, ebinsingh
ebenezer.si...@verizonwireless.com wrote:
 Hi All,

 For some reason I am not able to see any of the logs defined in the below
 route.
 Appreciate your help in solving this.

 Noticed that if I removed the choice from the second route, all the logging
 appears in my log file.
 I need to find out which choice loop is executed.


 endpoint id=acquireltel2
 uri=file:C:/camelProject/data/inbox?move=C:/camelProject/data/inbox/bkp /
 endpoint id=producerQueue uri=direct:producerQueue/
 endpoint id=dispatchltel2 uri=direct:dispatchltel2 /

 route
        from ref=acquireltel2 /
                setHeader headerName=pathName
                        simple${file:path}/simple
                /setHeader
                setHeader headerName=fileName
                        simple${file:name}/simple
                /setHeader
                setHeader headerName=fileType
                        constantltel2/constant
                /setHeader
                log message=set header pathName to ${file:path} 
 loggingLevel=INFO/
                log message=set header fileName to ${file:name} 
 loggingLevel=INFO/
                log message=set header fileType to ltel2 ${header.fileType}
 loggingLevel=INFO/
        to ref=producerQueue/
 /route

 route
        from ref=producerQueue/
        log message=set header fileType to ltel2 ${header.fileType}
 loggingLevel=INFO/
        choice
                when
                        simple${header.fileType} == ltel2/simple
                        log message=processing ltel2 file type 
 loggingLevel=INFO /
                        threads executorServiceRef=ltel2threadpool1
                                bean ref=ltel2Consumer method=doConsume /
                        /threads
                /when
                when
                        simple${header.fileType} == ltel3/simple
                        log message=processing ltel3 file type 
 loggingLevel=INFO /
                /when
        /choice
 /route

 Thanks  regards,
 Ebe

 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Issue-with-logging-tp5158558p5158558.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/


Re: camel-ftp scheduling and limit polling

2012-01-19 Thread Babak Vahdat
Hi,

the Leader-Rider has already answered this question of yours [1] by another
thread.

[1]
http://camel.465427.n5.nabble.com/What-s-best-practice-for-running-Camel-2-9-0-in-JBOSS-5-X-tp5138775p5145054.html

Babak

--
View this message in context: 
http://camel.465427.n5.nabble.com/camel-ftp-scheduling-and-limit-polling-tp5158013p5158651.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Redelivery with multiple transacted routes

2012-01-19 Thread Raul Kripalani
If you are using JMS transactions, how about rolling back the
transaction when an exception occurs, and letting AMQ do the
redelivery for you? That way the message will again enter the route at
the beginning (from endpoint).

You do this by configuring a redelivery policy on the connection
factory. Check out: http://activemq.apache.org/redelivery-policy.html.

On 19 Jan 2012, at 18:27, Babak Vahdat babak.vah...@swissonline.ch wrote:

 Hi,

 I just copypaste what the documentation says about this second question of
 yours:

 From Camel 2.4 onwards Camel has a feature to not block while waiting for a
 delayed redelivery to occur. However if you use transacted routes then Camel
 will block as its mandated by the transaction manager to execute all the
 work in the same thread context. You can enable the non blocking
 asynchronous behavior by the asyncDelayedRedelivery option. This option can
 be set on the errorHandler, onException or the redelivery policies.
 By default the error handler will create and use a scheduled thread pool to
 trigger redelivery in the future. From Camel 2.8 onwards you can configure
 the executorServiceRef on the Error Handler to indicate a reference to
 either a shared thread pool you can enlist in the registry, or a thread pool
 profile in case you want to be able to control pool settings.

 Babak


 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Redelivery-with-multiple-transacted-routes-tp5158209p5158521.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


Re: spagic and Camel

2012-01-19 Thread Christian Müller
I don't know Spagic. Which capabillities Spagic offers?

Best,
Christian

On Thu, Jan 19, 2012 at 11:15 AM, jmh jeanmarc.her...@nrb.be wrote:

 Hello,

 simple quesiton : is it possible to use Spagic to monitor Camel components
 ?

 Regards
 J-M

 --
 View this message in context:
 http://camel.465427.n5.nabble.com/spagic-and-Camel-tp5157280p5157280.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



Re: Redelivery with multiple transacted routes

2012-01-19 Thread kafe
@Babak : it seems that the asyncDelayedRedelivery option does not apply to
transacted routes (However if you use transacted routes then Camel will
block as its mandated by the transaction manager to execute all the work in
the same thread context). But i'll try that to be sure.

@Raul : actually, that could be the solution to my problem, but i did not
succeed in having ActiveMQ perform a correct redelivery. I'll post my jms
configuration tomorrow, which probably has some errors.

Thank you for your help.

--
View this message in context: 
http://camel.465427.n5.nabble.com/Redelivery-with-multiple-transacted-routes-tp5158209p5158863.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Redelivery with multiple transacted routes

2012-01-19 Thread Babak Vahdat
Hi Kafe,

that was exactly my intention to make it clear to you that this will NOT be
possible as long as your routing logic is transacted. For instance different
implementations of Spring's PlatformTransactionManager keep the state of the
currently running transaction into a ThreadLocal so that one cannot simply
spawn another thread to continue routing in another thread for the SAME
transaction.

BTW, Raul's suggestion sounds good to me.

Babak

--
View this message in context: 
http://camel.465427.n5.nabble.com/Redelivery-with-multiple-transacted-routes-tp5158209p5158895.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Redelivery with multiple transacted routes

2012-01-19 Thread kafe
Thank you for these precisions.
I'll have to make native activemq redelivery work tomorow then !

--
View this message in context: 
http://camel.465427.n5.nabble.com/Redelivery-with-multiple-transacted-routes-tp5158209p5158921.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Redelivery with multiple transacted routes

2012-01-19 Thread kafe
I'm reading again and again the several documentations about transaction and
error handling, and i have one more question: 
when working with the transactionErrorHandler
(http://camel.apache.org/transactionerrorhandler.html), and especially when
configuring redelivery (maximumRedeliveries(6)...), is it Camel or ActiveMQ
that performs the redelivery ?

--
View this message in context: 
http://camel.465427.n5.nabble.com/Redelivery-with-multiple-transacted-routes-tp5158209p5158983.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Redelivery with multiple transacted routes

2012-01-19 Thread Babak Vahdat
Digging into Camel code is the best way to find it out.

It's Camel doing the redelivery, as the redelivery facility should generally
work for all other kinds of components as well and not just ActiveMQ.

Babak

--
View this message in context: 
http://camel.465427.n5.nabble.com/Redelivery-with-multiple-transacted-routes-tp5158209p5159003.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel 2.9.0 integration with CXF2.5.1 Help

2012-01-19 Thread sram
Our application server is still dependent on Java5. The reason for me to move
to Camel 2.9.0 is to address status code 500 error thrown when my route
endpoint throws an exception. I believe this was addressed in 2.8.3 and
above. Am i correct? If so, Is Camel 2.8.3 compliant with Java 5, and should
I stay on CXF 2.4.x or move to CXF 2.5.x?

If Camel 2.8.3, has dependency to Java 6, what is the workaround to
propagate routing exceptions to client w/out falling into status code 500
trap within my current setup.

--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-2-9-0-integration-with-CXF2-5-1-Help-tp5156667p5159243.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel 2.9.0 integration with CXF2.5.1 Help

2012-01-19 Thread sram
I'm using JAX-WS, and to step back I'm on CXF2.4.1+Camel 2.4.0 (My bad on
version typo). My use case is to receive client PAYLOAD, process SOAP header
and route to external service for it to process the body and return
response. The issue is, when this external service throws an
Exception/Fault; it does not propagate into my camelcontext, instead I get
HTTP operation failed while invoking my external service URL (attached
exception)

camelContext xmlns=http://camel.apache.org/schema/spring;
route
from uri=cxf:bean:praService /
setExchangePattern pattern=InOut/   
to uri=bean:pnraDelegate / 
to uri=log:input?showHeaders=true /
to
uri=http://d026ats002268:19080/testServiceClientsWAR/services/PRAServiceRouterPort?bridgeEndpoint=true/
 
to uri=log:output/
to uri=bean:threadCleaner/
/route
/camelContext


= Exception thrown =
[1/19/12 20:56:44:472 EST] 093f DefaultErrorH E
org.apache.camel.processor.Logger log Failed delivery for exchangeId:
ad7d475d-052f-40ce-ba56-b4f16e41b645. Exhausted after delivery attempt: 1
caught: org.apache.camel.component.http.HttpOperationFailedException: HTTP
operation failed invoking
http://d026ats002268:19080/testServiceClientsWAR/services/PRAServiceRouterPort
with statusCode: 500

org.apache.camel.component.http.HttpOperationFailedException: HTTP operation
failed invoking
http://d026ats002268:19080/testServiceClientsWAR/services/PRAServiceRouterPort
with statusCode: 500
at
org.apache.camel.component.http.HttpProducer.populateHttpOperationFailedException(HttpProducer.java:157)
at
org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:99)
at
org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:50)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)
at
org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:104)
at
org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:272)
at 
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:98)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:70)
at
org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)


--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-2-9-0-integration-with-CXF2-5-1-Help-tp5156667p5159431.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Async processing and number of inflight exchanges issue

2012-01-19 Thread Zhemzhitsky Sergey
Hi gurus,

I have the  following issue. I need to send requests to webservice from camel 
on timer events.
As timer consumer uses synchronous event firing , only one request can be sent 
at the same time. What I’d like is use to threads DSL to process multiple timer 
events at the same time.

Here is an example:

from(timer:start?period=100delay=100repeatCount=0)
.threads(1, 
5).maxQueueSize(5).rejectedPolicy(ThreadPoolRejectedPolicy.DiscardOldest)
.to(bean:wscall);

However, usage of threads DSL with original timer consumer does not make sense 
because of synchronicity of timer consumer, so I tried to develop asynchronous 
timer component that uses asynchronous API to fire events.

Everything works fine except that there is a lot of inflight exchanges when 
stopping the route.

Could you please suggest how to avoid such an issue?

=

Below is the unit test that allows to reproduce this unexpected behavior.


package foo.bar;

import org.apache.camel.AsyncCallback;
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.LoggingLevel;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.Service;
import org.apache.camel.ThreadPoolRejectedPolicy;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultComponent;
import org.apache.camel.impl.DefaultConsumer;
import org.apache.camel.impl.DefaultEndpoint;
import org.apache.camel.impl.JndiRegistry;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.camel.util.AsyncProcessorHelper;
import org.junit.Test;

import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;

public class CamelRoutingTest extends CamelTestSupport {

@Test
public void route() throws Exception {
Endpoint endpoint = 
context().getRoute(timer).getConsumer().getEndpoint();

// make timer fire for several times
TimeUnit.SECONDS.sleep(5);

context().stopRoute(timer, 10, TimeUnit.SECONDS);

int inflightExchanges = 
context().getInflightRepository().size(endpoint);
assertTrue(inflightExchanges:  + inflightExchanges, inflightExchanges 
== 0);
}

@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry registry = super.createRegistry();
registry.bind(atimer, new AsyncTimerComponent());
return registry;
}

@Override
protected int getShutdownTimeout() {
return 1;
}

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {

from(atimer:start?period=100delay=100repeatCount=0).id(timer)
.threads(1, 
5).maxQueueSize(5).rejectedPolicy(ThreadPoolRejectedPolicy.DiscardOldest)
.log(LoggingLevel.INFO, org.apache.camel.LOGGER,
 START: ${header. + Exchange.BREADCRUMB_ID + 
})
.delay(1000)
.log(LoggingLevel.INFO, org.apache.camel.LOGGER,
 COMPLETE: ${header. + Exchange.BREADCRUMB_ID 
+ })
.to(mock:result);
}
};
}

public static class AsyncTimerComponent extends DefaultComponent {
private final MapString, Timer timers = new HashMapString, Timer();
public Timer getTimer(AsyncTimerEndpoint endpoint) {
String key = endpoint.getTimerName();
if (!endpoint.isDaemon()) {
key = nonDaemon: + key;
}

Timer answer;
synchronized (timers) {
answer = timers.get(key);
if (answer == null) {
answer = new Timer(endpoint.getTimerName(), 
endpoint.isDaemon());
timers.put(key, answer);
}
}
return answer;
}

@Override
protected AsyncTimerEndpoint createEndpoint(String uri, String 
remaining, MapString, Object parameters) throws Exception {
AsyncTimerEndpoint answer = new AsyncTimerEndpoint(uri, this, 
remaining);
setProperties(answer, parameters);
return answer;
}

@Override
protected void doStop() throws Exception {
CollectionTimer collection = timers.values();
for (Timer timer : collection) {
timer.cancel();
}
timers.clear();
}
}

public static class AsyncTimerEndpoint