Re: (FTP) DefaultScheduledPollConsumer: Converts a polling consumer into an event-driven consumer instance.

2012-01-16 Thread Raul
I suppose that the event will be produced when the FTP Route receives every
file.

When I read that I can convert a polling consumer into a event-driven
consumer with DefaultScheduledPollConsumer I thought it's that I need. But I
didn't found any example.

I am begining to walk with Camel. I thought that this class,
DefaultScheduledPollConsumer, converts automatically the consumer. But
perhaps, it isn't automatically and I have to program the events. Is it?

Thank you.


--
View this message in context: 
http://camel.465427.n5.nabble.com/FTP-DefaultScheduledPollConsumer-Converts-a-polling-consumer-into-an-event-driven-consumer-instance-tp5134561p5148112.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Exception FTP Component

2012-01-16 Thread Niels
Hey everybody,

I'm using to ftp component to consume from a ftp server.
The little application seems to do the job but when investigating the log files 
this exception shows up:

Trying to recover by disconnecting from remote server forcing a re-connect at 
next poll: ftp://userl@server:21
 Error occurred while disconnecting from ftp://user@server:21 due: File 
operation failed: 421 Terminating connection.
 FTP response 421 received.  Server closed connection.. Code: 421. This 
exception will be ignored.
 Consumer 
FtpConsumer[ftp://server?delay=90delete=truepassword=**username=user]
 could not poll endpoint: Endpoint[ftp://server?de$
 FTP response 421 received.  Server closed connection.. Code: 421
 org.apache.camel.component.file.GenericFileOperationFailedException: File 
operation failed: 421 Timeout (120 seconds): closing control connection.
 FTP response 421 received.  Server closed connection.. Code: 421
at 
org.apache.camel.component.file.remote.FtpOperations.getCurrentDirectory(FtpOperations.java:569)
at 
org.apache.camel.component.file.remote.FtpConsumer.pollDirectory(FtpConsumer.java:45)
at 
org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:100)
at 
org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:140)
at 
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:92)
at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at 
java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)
at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.commons.net.ftp.FTPConnectionClosedException: FTP 
response 421 received.  Server closed connection.
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:347)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:495)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:537)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:586)
at org.apache.commons.net.ftp.FTP.pwd(FTP.java:1381)
at 
org.apache.commons.net.ftp.FTPClient.printWorkingDirectory(FTPClient.java:1990)
at 
org.apache.camel.component.file.remote.FtpOperations.getCurrentDirectory(FtpOperations.java:567)
... 13 more

This is the route I'm using to consume the service:

from(ftp://; + props.getProperty(FTP_URL) + ?username= + 
props.getProperty(FTP_USER) + password= + props.getProperty(FTP_PWD) + 
delete=truedelay= + props.getProperty(FTP_DELAY))
.filter(xmlPredicate)
.to(jms:xmlQueue).end()
.filter(imgPredicate)
.to(file:// + props.getProperty(ROOT_DIR) + 
/img).end()
.filter(pdfPredicate)
.to(file:// + props.getProperty(ROOT_DIR) + 
/pdf).end()
.to(file:// + props.getProperty(ROOT_DIR) + /junk);

Now I'm wondering if this could be an issue with camel? In my opinion I think 
it has something to do with the FTP server itself and not so much with camel.
Therefore I'm asking some experts opinion on my issue.

And please if you have any remarks on my code, I happy to here them I'm just a 
novice when it comes to camel.

Thanks!

Regards,

Niels




Re: (FTP) DefaultScheduledPollConsumer: Converts a polling consumer into an event-driven consumer instance.

2012-01-16 Thread Claus Ibsen
On Mon, Jan 16, 2012 at 9:21 AM, Raul ludala...@gmail.com wrote:
 I suppose that the event will be produced when the FTP Route receives every
 file.

 When I read that I can convert a polling consumer into a event-driven
 consumer with DefaultScheduledPollConsumer I thought it's that I need. But I
 didn't found any example.

 I am begining to walk with Camel. I thought that this class,
 DefaultScheduledPollConsumer, converts automatically the consumer. But
 perhaps, it isn't automatically and I have to program the events. Is it?


A scheduled poll consumer, is .. well scheduled. That means you
configured the consumer to trigger every X period.
By default that is every 500 milli seconds.

This kind of consumer is needed if you are not truly event based, but
may want to simulate as being event based.
An example is file based consumers. As they run periodically and scan
for new files. This is needed as the file API
does not have any event (yet) being triggered when new files / files
changes etc. Although JDK7 now have API for this,
but Camel is supporting JDK6+.

If you are truly event based, then just use the plain consumer, such
as DefaultConsumer.



 Thank you.


 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/FTP-DefaultScheduledPollConsumer-Converts-a-polling-consumer-into-an-event-driven-consumer-instance-tp5134561p5148112.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: Do Apache Camel needs a SAP integration?

2012-01-16 Thread Guillaume Yziquel
Le Saturday 14 Jan 2012 à 15:37:38 (+0100), Björn Bength a écrit :
 Hi
 
 At our client (a bank) in Sweden, we created a camel component that
 integrated their SAP server.
 It can only call BAPI functions right now but it uses JCo of course,
 and Hibersap which allows to annotate java beans just send it through
 to the camel endpoint. All this on ServiceMix where we made the
 camel-SAP (with jco) component OSGi firendly.
 
 It worked so well that those SAP guys we worked with told us that they
 never before had an integration project that actually worked on _the
 first_ test transaction.
 
 Unfortunatly hibersap is LGPL but it really (really) makes working
 with Jco sooo much easier.
 And just maybe hibersap can convert it's license, but from another
 thread (MongoDB) I got the feeling that all of you like to have a
 native camel component in all cases.
 
 My intention was to put this on GitHub though, but I never took time to do so.
 I could share the parts I wrote if someone is interested, and call it
 camel-hibersap.
 
 Regards
 Björn

I guess it would be quite nice to put such a Camel Component on Github.
Please feel free to do so and keep us updated.

-- 
Guillaume Yziquel


Multicast And Activemq

2012-01-16 Thread Hervé BARRAULT
Hi,
I have a question concerning camel camel-core (2.4.0.fuse-00-00) ,
activemq camel activemq-camel (5.4.0.fuse-00-00) and activemq
activemq-core (5.4.0.fuse-00-00).

I am trying to use multicast.

I had a route :

from(sourceUri_)
.errorHandler(noErrorHandler())
.policy(getTracePolicy())
.policy(getErrorReportingPolicy())
.process(myProcessor_)
.recipientList(header(TARGET_HEADER));

But when sending to n target queues, we noticed that the behavior is
sequential (normal).

Now we are trying to use multicast :
from(sourceUri_)
.errorHandler(noErrorHandler())
.policy(getTracePolicy())
.policy(getErrorReportingPolicy())
.process(myProcessor_)
.multicast()
.parallelProcessing()
.recipientList(header(TARGET_HEADER));


In this case the message is correctly send to the expected queues (in
my test 2) but only one queue is consumed.
For information the processor send itself a generated message in
another queue, and we are using one way.

Is the right method to use multicast ? Is there something else to do ?

Thanks for answers.

Regards
Hervé


Re: Multicast And Activemq

2012-01-16 Thread Claus Ibsen
Hi

You need to use the parallelProcessing option as documented on the
wiki pages for those EIPs.


On Mon, Jan 16, 2012 at 11:20 AM, Hervé BARRAULT
herve.barra...@gmail.com wrote:
 Hi,
 I have a question concerning camel camel-core (2.4.0.fuse-00-00) ,
 activemq camel activemq-camel (5.4.0.fuse-00-00) and activemq
 activemq-core (5.4.0.fuse-00-00).

 I am trying to use multicast.

 I had a route :

 from(sourceUri_)
            .errorHandler(noErrorHandler())
            .policy(getTracePolicy())
            .policy(getErrorReportingPolicy())
            .process(myProcessor_)
            .recipientList(header(TARGET_HEADER));

 But when sending to n target queues, we noticed that the behavior is
 sequential (normal).

 Now we are trying to use multicast :
 from(sourceUri_)
            .errorHandler(noErrorHandler())
            .policy(getTracePolicy())
            .policy(getErrorReportingPolicy())
            .process(myProcessor_)
            .multicast()
            .parallelProcessing()
            .recipientList(header(TARGET_HEADER));


 In this case the message is correctly send to the expected queues (in
 my test 2) but only one queue is consumed.
 For information the processor send itself a generated message in
 another queue, and we are using one way.

 Is the right method to use multicast ? Is there something else to do ?

 Thanks for answers.

 Regards
 Hervé



-- 
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: Multicast And Activemq

2012-01-16 Thread Hervé BARRAULT
Hi,
I used parallel processing like shown in
http://camel.apache.org/multicast.html without timeout.

[quote]
.process(myProcessor_)
.multicast()
.parallelProcessing()
.recipientList(header(TARGET_HEADER));
[/quote]

Regards

On 1/16/12, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 You need to use the parallelProcessing option as documented on the
 wiki pages for those EIPs.


 On Mon, Jan 16, 2012 at 11:20 AM, Hervé BARRAULT
 herve.barra...@gmail.com wrote:
 Hi,
 I have a question concerning camel camel-core (2.4.0.fuse-00-00) ,
 activemq camel activemq-camel (5.4.0.fuse-00-00) and activemq
 activemq-core (5.4.0.fuse-00-00).

 I am trying to use multicast.

 I had a route :

 from(sourceUri_)
            .errorHandler(noErrorHandler())
            .policy(getTracePolicy())
            .policy(getErrorReportingPolicy())
            .process(myProcessor_)
            .recipientList(header(TARGET_HEADER));

 But when sending to n target queues, we noticed that the behavior is
 sequential (normal).

 Now we are trying to use multicast :
 from(sourceUri_)
            .errorHandler(noErrorHandler())
            .policy(getTracePolicy())
            .policy(getErrorReportingPolicy())
            .process(myProcessor_)
            .multicast()
            .parallelProcessing()
            .recipientList(header(TARGET_HEADER));


 In this case the message is correctly send to the expected queues (in
 my test 2) but only one queue is consumed.
 For information the processor send itself a generated message in
 another queue, and we are using one way.

 Is the right method to use multicast ? Is there something else to do ?

 Thanks for answers.

 Regards
 Hervé



 --
 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: Multicast And Activemq

2012-01-16 Thread Claus Ibsen
Hi

You should not do both multicast + recipient list.
The recipient list also has the parallel processing. So just use that EIP only.


On Mon, Jan 16, 2012 at 11:32 AM, Hervé BARRAULT
herve.barra...@gmail.com wrote:
 Hi,
 I used parallel processing like shown in
 http://camel.apache.org/multicast.html without timeout.

 [quote]
 .process(myProcessor_)
 .multicast()
 .parallelProcessing()
 .recipientList(header(TARGET_HEADER));
 [/quote]

 Regards

 On 1/16/12, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 You need to use the parallelProcessing option as documented on the
 wiki pages for those EIPs.


 On Mon, Jan 16, 2012 at 11:20 AM, Hervé BARRAULT
 herve.barra...@gmail.com wrote:
 Hi,
 I have a question concerning camel camel-core (2.4.0.fuse-00-00) ,
 activemq camel activemq-camel (5.4.0.fuse-00-00) and activemq
 activemq-core (5.4.0.fuse-00-00).

 I am trying to use multicast.

 I had a route :

 from(sourceUri_)
            .errorHandler(noErrorHandler())
            .policy(getTracePolicy())
            .policy(getErrorReportingPolicy())
            .process(myProcessor_)
            .recipientList(header(TARGET_HEADER));

 But when sending to n target queues, we noticed that the behavior is
 sequential (normal).

 Now we are trying to use multicast :
 from(sourceUri_)
            .errorHandler(noErrorHandler())
            .policy(getTracePolicy())
            .policy(getErrorReportingPolicy())
            .process(myProcessor_)
            .multicast()
            .parallelProcessing()
            .recipientList(header(TARGET_HEADER));


 In this case the message is correctly send to the expected queues (in
 my test 2) but only one queue is consumed.
 For information the processor send itself a generated message in
 another queue, and we are using one way.

 Is the right method to use multicast ? Is there something else to do ?

 Thanks for answers.

 Regards
 Hervé



 --
 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: Exception FTP Component

2012-01-16 Thread Claus Ibsen
Hi

Just a note about your Java DSL route.

What you do looks much more like the Content Based Router (eg if ...
else if ... else if ... else).
http://camel.apache.org/content-based-router

So you may want to look into that instead of using the filter EIP if
you think the code is more readable.


And in terms of the FTP error. What version of Camel are you using? We
have fixed some pieces in recent times about detecting
broken connection and re-connection.

If you do not want to keep the connection alive, you can use the
disconnect=true option. Then you force Camel to re-login on each poll.
This could make sense if there is a long delay between polls.



On Mon, Jan 16, 2012 at 9:25 AM, Niels ni...@kabisa.nl wrote:
 Hey everybody,

 I'm using to ftp component to consume from a ftp server.
 The little application seems to do the job but when investigating the log 
 files this exception shows up:

 Trying to recover by disconnecting from remote server forcing a re-connect at 
 next poll: ftp://userl@server:21
  Error occurred while disconnecting from ftp://user@server:21 due: File 
 operation failed: 421 Terminating connection.
  FTP response 421 received.  Server closed connection.. Code: 421. This 
 exception will be ignored.
  Consumer 
 FtpConsumer[ftp://server?delay=90delete=truepassword=**username=user]
  could not poll endpoint: Endpoint[ftp://server?de$
  FTP response 421 received.  Server closed connection.. Code: 421
  org.apache.camel.component.file.GenericFileOperationFailedException: File 
 operation failed: 421 Timeout (120 seconds): closing control connection.
  FTP response 421 received.  Server closed connection.. Code: 421
        at 
 org.apache.camel.component.file.remote.FtpOperations.getCurrentDirectory(FtpOperations.java:569)
        at 
 org.apache.camel.component.file.remote.FtpConsumer.pollDirectory(FtpConsumer.java:45)
        at 
 org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:100)
        at 
 org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:140)
        at 
 org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:92)
        at 
 java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at 
 java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
        at 
 java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
        at 
 java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)
        at 
 java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
        at 
 java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at 
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:662)
 Caused by: org.apache.commons.net.ftp.FTPConnectionClosedException: FTP 
 response 421 received.  Server closed connection.
        at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:347)
        at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:495)
        at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:537)
        at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:586)
        at org.apache.commons.net.ftp.FTP.pwd(FTP.java:1381)
        at 
 org.apache.commons.net.ftp.FTPClient.printWorkingDirectory(FTPClient.java:1990)
                at 
 org.apache.camel.component.file.remote.FtpOperations.getCurrentDirectory(FtpOperations.java:567)
                ... 13 more

 This is the route I'm using to consume the service:

 from(ftp://; + props.getProperty(FTP_URL) + ?username= + 
 props.getProperty(FTP_USER) + password= + props.getProperty(FTP_PWD) + 
 delete=truedelay= + props.getProperty(FTP_DELAY))
                        .filter(xmlPredicate)
                                .to(jms:xmlQueue).end()
                        .filter(imgPredicate)
                                .to(file:// + props.getProperty(ROOT_DIR) + 
 /img).end()
                        .filter(pdfPredicate)
                                .to(file:// + props.getProperty(ROOT_DIR) + 
 /pdf).end()
                        .to(file:// + props.getProperty(ROOT_DIR) + /junk);

 Now I'm wondering if this could be an issue with camel? In my opinion I think 
 it has something to do with the FTP server itself and not so much with camel.
 Therefore I'm asking some experts opinion on my issue.

 And please if you have any remarks on my code, I happy to here them I'm just 
 a novice when it comes to camel.

 Thanks!

 Regards,

 Niels





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

Re: fork join pattern with Camel

2012-01-16 Thread Raul Kripalani
Hi,

You can use split/aggregate if you need a scatter/gather pattern, i.e. if
your original message is composed of several individual units and you want
to splice it up and process each one independently, waiting at the end to
collect all responses and then continue processing.

If you require a more traditional and flexible BPEL-like approach which
allows you to fork your processing into different branches (BPEL flow /)
without splitting up the original message, you can use Multicast with
parallelProcessing=true. See [1].

Beware that the latter by default will only keep the last reply as the
overall outgoing response, so if you want to aggregate all responses you
need to define your own strategyRef.

Hope that helps.

[1] http://camel.apache.org/multicast.html.

Regards,
Raúl.

On 15 January 2012 10:34, Christian Müller christian.muel...@gmail.comwrote:

 fork == split [1]
 join == aggregate [2]

 [1] http://camel.apache.org/splitter.html
 [2] http://camel.apache.org/aggregator2.html

 Best,
 Christian

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

  Hello,
 
  could you tell me what is the best way in Camel to implement the fork 
  join
  pattern (wait, and/or condition) ?
 
  I don't want to use BPEL since my workflow is implemented using pure Java
  code rather than declarative XML.
 
  Thanks for your help
 
  Regards
 
  --
  View this message in context:
 
 http://camel.465427.n5.nabble.com/fork-join-pattern-with-Camel-tp5146192p5146192.html
  Sent from the Camel - Users mailing list archive at Nabble.com.
 



Re: Multicast And Activemq

2012-01-16 Thread Hervé BARRAULT
Hi,
I have tested like described in
http://camel.apache.org/recipient-list.html#RecipientList-Sendingtomultiplerecipientsinparallel
and it is working.

I had a strange behavior because i had an error in the consumer configuration.

Thank you for the help.


On 1/16/12, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 You should not do both multicast + recipient list.
 The recipient list also has the parallel processing. So just use that EIP
 only.


 On Mon, Jan 16, 2012 at 11:32 AM, Hervé BARRAULT
 herve.barra...@gmail.com wrote:
 Hi,
 I used parallel processing like shown in
 http://camel.apache.org/multicast.html without timeout.

 [quote]
 .process(myProcessor_)
 .multicast()
 .parallelProcessing()
 .recipientList(header(TARGET_HEADER));
 [/quote]

 Regards

 On 1/16/12, Claus Ibsen claus.ib...@gmail.com wrote:
 Hi

 You need to use the parallelProcessing option as documented on the
 wiki pages for those EIPs.


 On Mon, Jan 16, 2012 at 11:20 AM, Hervé BARRAULT
 herve.barra...@gmail.com wrote:
 Hi,
 I have a question concerning camel camel-core (2.4.0.fuse-00-00) ,
 activemq camel activemq-camel (5.4.0.fuse-00-00) and activemq
 activemq-core (5.4.0.fuse-00-00).

 I am trying to use multicast.

 I had a route :

 from(sourceUri_)
            .errorHandler(noErrorHandler())
            .policy(getTracePolicy())
            .policy(getErrorReportingPolicy())
            .process(myProcessor_)
            .recipientList(header(TARGET_HEADER));

 But when sending to n target queues, we noticed that the behavior is
 sequential (normal).

 Now we are trying to use multicast :
 from(sourceUri_)
            .errorHandler(noErrorHandler())
            .policy(getTracePolicy())
            .policy(getErrorReportingPolicy())
            .process(myProcessor_)
            .multicast()
            .parallelProcessing()
            .recipientList(header(TARGET_HEADER));


 In this case the message is correctly send to the expected queues (in
 my test 2) but only one queue is consumed.
 For information the processor send itself a generated message in
 another queue, and we are using one way.

 Is the right method to use multicast ? Is there something else to do ?

 Thanks for answers.

 Regards
 Hervé



 --
 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: in netty.why sended 6bytes, but server recved 9bytes

2012-01-16 Thread xiangqiuzhao
Object decoder = appctx.getBean(mydecoder);
Object encoder = appctx.getBean(myencoder);

SimpleRegistry registry = new SimpleRegistry(); 

ListChannelDownstreamHandler encoders = new
ArrayListChannelDownstreamHandler();
encoders.add((ChannelDownstreamHandler)encoder);

registry.put(myDecoder, decoder);
registry.put(myEncoder, encoder);
registry.put(myEncoders, encoders);

CamelContext context = new DefaultCamelContext(registry);

context.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
from(direct:cpsp)
.process(new MyToProcessor())
   
.to(netty:tcp://localhost:6789?encoder=#myEncodersync=true)
.process(new MyFromProcessor());
}
});

why the to URI encoder=#myEncoder... exception like:

 Failed to create route route1 at: 
To[netty:tcp://localhost:6789?encoder=#myEncodersync=true]  in route:
Route[[From[direct:cpsp]] - [process[Wrap[com.sunyard.camel... because of
Failed to resolve endpoint:
netty://tcp://localhost:6789?encoder=%23myEncodersync=true due to: Could
not find a suitable setter for property: encoder as there isn't a setter
method with same type: java.lang.String nor type conversion possible: No
type converter available to convert from type: java.lang.String to the
required type: org.jboss.netty.channel.ChannelDownstreamHandler with value
#myEncoder

but that's ok if URI set to encoders=#myEncoders.

--
View this message in context: 
http://camel.465427.n5.nabble.com/in-netty-why-sended-6bytes-but-server-recved-9bytes-tp5131271p5148545.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Exception FTP Component

2012-01-16 Thread Niels
Thanks for the fast reply.

I already changed to content-based routing.
I'm using the latest version of camel 2.9.0.
It's better to use the disconnect=true option like you mentioned, because there 
is a 5 min interval between the polling.
Will update a soon as I can redeploy my application en re-encounter the same 
problem in the logs.

Regards,

Niels

On Jan 16, 2012, at 11:46 AM, Claus Ibsen wrote:

 Hi
 
 Just a note about your Java DSL route.
 
 What you do looks much more like the Content Based Router (eg if ...
 else if ... else if ... else).
 http://camel.apache.org/content-based-router
 
 So you may want to look into that instead of using the filter EIP if
 you think the code is more readable.
 
 
 And in terms of the FTP error. What version of Camel are you using? We
 have fixed some pieces in recent times about detecting
 broken connection and re-connection.
 
 If you do not want to keep the connection alive, you can use the
 disconnect=true option. Then you force Camel to re-login on each poll.
 This could make sense if there is a long delay between polls.
 
 
 
 On Mon, Jan 16, 2012 at 9:25 AM, Niels ni...@kabisa.nl wrote:
 Hey everybody,
 
 I'm using to ftp component to consume from a ftp server.
 The little application seems to do the job but when investigating the log 
 files this exception shows up:
 
 Trying to recover by disconnecting from remote server forcing a re-connect 
 at next poll: ftp://userl@server:21
  Error occurred while disconnecting from ftp://user@server:21 due: File 
 operation failed: 421 Terminating connection.
  FTP response 421 received.  Server closed connection.. Code: 421. This 
 exception will be ignored.
  Consumer 
 FtpConsumer[ftp://server?delay=90delete=truepassword=**username=user]
  could not poll endpoint: Endpoint[ftp://server?de$
  FTP response 421 received.  Server closed connection.. Code: 421
  org.apache.camel.component.file.GenericFileOperationFailedException: File 
 operation failed: 421 Timeout (120 seconds): closing control connection.
  FTP response 421 received.  Server closed connection.. Code: 421
at 
 org.apache.camel.component.file.remote.FtpOperations.getCurrentDirectory(FtpOperations.java:569)
at 
 org.apache.camel.component.file.remote.FtpConsumer.pollDirectory(FtpConsumer.java:45)
at 
 org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:100)
at 
 org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:140)
at 
 org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:92)
at 
 java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at 
 java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
at 
 java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
at 
 java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)
at 
 java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
at 
 java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at 
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
 Caused by: org.apache.commons.net.ftp.FTPConnectionClosedException: FTP 
 response 421 received.  Server closed connection.
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:347)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:495)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:537)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:586)
at org.apache.commons.net.ftp.FTP.pwd(FTP.java:1381)
at 
 org.apache.commons.net.ftp.FTPClient.printWorkingDirectory(FTPClient.java:1990)
at 
 org.apache.camel.component.file.remote.FtpOperations.getCurrentDirectory(FtpOperations.java:567)
... 13 more
 
 This is the route I'm using to consume the service:
 
 from(ftp://; + props.getProperty(FTP_URL) + ?username= + 
 props.getProperty(FTP_USER) + password= + props.getProperty(FTP_PWD) + 
 delete=truedelay= + props.getProperty(FTP_DELAY))
.filter(xmlPredicate)
.to(jms:xmlQueue).end()
.filter(imgPredicate)
.to(file:// + props.getProperty(ROOT_DIR) + 
 /img).end()
.filter(pdfPredicate)
.to(file:// + props.getProperty(ROOT_DIR) + 
 /pdf).end()
.to(file:// + props.getProperty(ROOT_DIR) + 
 /junk);
 
 Now I'm wondering if this could be an issue with camel? In my opinion I 
 think it has something to do with the FTP server itself 

Re: Adding a startup listener via spring

2012-01-16 Thread metatech
Hi Claus,

For the record, I used the following solution.
In my camel-config.xml : 

osgi:reference id=myapp-1 
filter=(camel.context.symbolicname=myapp-1)
interface=org.apache.camel.CamelContext timeout=60/
osgi:reference id=myapp-2 
filter=(camel.context.symbolicname=myapp-2)
interface=org.apache.camel.CamelContext timeout=60/

Note 1 : this solution does not require to use several values of
start-levels for each application, which would require to launch Karaf
command-line instructions for hot deployed applications (ie not features).

Note 2 : optional dependencies are not possible, all referenced camel
contexts must be installed and started.  For optional dependencies, it is
necessary to use the programmatic equivalent with
BundleContext.getServiceReferences.

Note 3 : the timeout attribute does not appear to be taken into account,
only the one specified in the bundle manifest header actually is, like this
:
Spring-Context: *;timeout:=60

with the following instruction in my pom.xml for maven-bundle-plugin :
_includesrc/main/resources/META-INF/MANIFEST-fragment.MF/_include

Hope this helps,
Regards,

metatech



On Mon, Jan 9, 2012 at 9:30 AM, metatech lt;metatechbe@gt; wrote:
 Hi Claus,

 I tried the depends-on solution but unfortunately the camel context is
 started asynchronously after the Spring context is initialized.
 The behaviour is implemented in class OsgiSpringCamelContext, method
 onApplicationEvent.
 Do you think of any other reliable way to define dependencies between
 camel
 contexts ?


spring-dm has a option AFAIR where you can tell it to start synchronously.
Its an option you need to set in your bundles MANIFEST.MF file. Its
documented somewhere in the spring-dm docs.

I found some stuff here
http://static.springsource.org/osgi/docs/1.2.1/reference/html/app-deploy.html#app-deploy:required-libraries

See the create-asynchronously option

 Thanks,

 metatech



 Claus Ibsen-2 wrote

 In Spring XML you should be able to use the depends-on attribute to
 say that your bean depends on Camel.

 camelContext id=myCamel ...

 bean id=foo depends-on=myCamel ...










--
View this message in context: 
http://camel.465427.n5.nabble.com/Adding-a-startup-listener-via-spring-tp4306163p5148621.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Camel documentation update

2012-01-16 Thread metatech
Hi,

After having successfully enabled security on the ActiveMQ broker within
ServiceMix, here is some feedback to improve the existing documentation.

Please add the following steps in the ActiveMQ documentation (or grant me
rights to do so on the Wiki)

1. http://activemq.apache.org/osgi-integration.html
Add at the end :
===
[Optional] In order to use the ActiveMQ console with a broker configured
with authentication, it is necessary to configure the username/password for
JMS connection as well.
#webconsole.jms.user=system
#webconsole.jms.password=manager
===

2. http://activemq.apache.org/security.html

Please add after the sentence With the above bean definition, Camel will
pass the specified security credentials when it connects to the broker.

===
If the broker is running in an OSGi container, add the following line after
the ActiveMQComponent bean definition :
service ref=activemq interface=org.apache.camel.Component/
===

3. http://activemq.apache.org/security.html

Please add after the sentence The above configuration is not set up to work
within a secure environment.
===
If the application is running in an OSGi container, add the following line
before the CamelContext definition :
osgi:reference id=activemq interface=org.apache.camel.Component /

This allows any pre-configured instance of the ActiveMQComponent deployed in
the container to take precedence on the default ActiveMQComponent.
===

Thanks in advance,

metatech



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


create a transacted policy with camel

2012-01-16 Thread Filippo Balicchia
Hello i try to use transaction from camel in osgi bundle.

My route look like this

from(jms:myqueue).transacted().id(DestRoute).throwException(new
Exception(persistence error))
And i my configuration look like this:

bean id=activemq
class=org.apache.activemq.camel.component.ActiveMQComponent
property name=connectionFactory
osgi:reference interface=javax.jms.ConnectionFactory 
/
/property
property name=transacted value=true /
property name=transactionManager
osgi:reference

interface=org.springframework.transaction.PlatformTransactionManager /
/property
/bean

camelContext xmlns=http://camel.apache.org/schema/spring;
routeBuilder ref=destRoute /
/camelContext

At bundle startup it tell me that that doesn't find camel-spring
'Cannot create a transacted policy as camel-spring.jar is not on the classpath'
It 'very clear but in my header package
org.springframework.transaction
org.apache.camel.spring
are present.

Where am I mistaken or forgotten, or what?


Re: Camel documentation update

2012-01-16 Thread Claus Ibsen
Hi

Thanks for sharing.

You can read here how you can help out and be able to edit the
documentation yourself. This is much appreciated.
http://camel.apache.org/contributing.html
http://camel.apache.org/how-do-i-edit-the-website.html



On Mon, Jan 16, 2012 at 2:52 PM, metatech metatec...@gmail.com wrote:
 Hi,

 After having successfully enabled security on the ActiveMQ broker within
 ServiceMix, here is some feedback to improve the existing documentation.

 Please add the following steps in the ActiveMQ documentation (or grant me
 rights to do so on the Wiki)

 1. http://activemq.apache.org/osgi-integration.html
 Add at the end :
 ===
 [Optional] In order to use the ActiveMQ console with a broker configured
 with authentication, it is necessary to configure the username/password for
 JMS connection as well.
 #webconsole.jms.user=system
 #webconsole.jms.password=manager
 ===

 2. http://activemq.apache.org/security.html

 Please add after the sentence With the above bean definition, Camel will
 pass the specified security credentials when it connects to the broker.

 ===
 If the broker is running in an OSGi container, add the following line after
 the ActiveMQComponent bean definition :
 service ref=activemq interface=org.apache.camel.Component/
 ===

 3. http://activemq.apache.org/security.html

 Please add after the sentence The above configuration is not set up to work
 within a secure environment.
 ===
 If the application is running in an OSGi container, add the following line
 before the CamelContext definition :
 osgi:reference id=activemq interface=org.apache.camel.Component /

 This allows any pre-configured instance of the ActiveMQComponent deployed in
 the container to take precedence on the default ActiveMQComponent.
 ===

 Thanks in advance,

 metatech



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Camel-documentation-update-tp5148751p5148751.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: create a transacted policy with camel

2012-01-16 Thread Filippo Balicchia
Thanks to all
I have resolved

Il 16 gennaio 2012 19:11, Filippo Balicchia fbalicc...@gmail.com ha scritto:
 Hello i try to use transaction from camel in osgi bundle.

 My route look like this

 from(jms:myqueue).transacted().id(DestRoute).throwException(new
 Exception(persistence error))
 And i my configuration look like this:

 bean id=activemq
 class=org.apache.activemq.camel.component.ActiveMQComponent
        property name=connectionFactory
                        osgi:reference 
 interface=javax.jms.ConnectionFactory /
        /property
        property name=transacted value=true /
        property name=transactionManager
                osgi:reference
                        
 interface=org.springframework.transaction.PlatformTransactionManager /
        /property
 /bean

 camelContext xmlns=http://camel.apache.org/schema/spring;
                routeBuilder ref=destRoute /
 /camelContext

 At bundle startup it tell me that that doesn't find camel-spring
 'Cannot create a transacted policy as camel-spring.jar is not on the 
 classpath'
 It 'very clear but in my header package
 org.springframework.transaction
 org.apache.camel.spring
 are present.

 Where am I mistaken or forgotten, or what?


Re: create a transacted policy with camel

2012-01-16 Thread Claus Ibsen
On Tue, Jan 17, 2012 at 7:24 AM, Filippo Balicchia fbalicc...@gmail.com wrote:
 Thanks to all
 I have resolved


Do you mind sharing your solution?
So others who have a similar issue, can read your solution.


 Il 16 gennaio 2012 19:11, Filippo Balicchia fbalicc...@gmail.com ha scritto:
 Hello i try to use transaction from camel in osgi bundle.

 My route look like this

 from(jms:myqueue).transacted().id(DestRoute).throwException(new
 Exception(persistence error))
 And i my configuration look like this:

 bean id=activemq
 class=org.apache.activemq.camel.component.ActiveMQComponent
        property name=connectionFactory
                        osgi:reference 
 interface=javax.jms.ConnectionFactory /
        /property
        property name=transacted value=true /
        property name=transactionManager
                osgi:reference
                        
 interface=org.springframework.transaction.PlatformTransactionManager /
        /property
 /bean

 camelContext xmlns=http://camel.apache.org/schema/spring;
                routeBuilder ref=destRoute /
 /camelContext

 At bundle startup it tell me that that doesn't find camel-spring
 'Cannot create a transacted policy as camel-spring.jar is not on the 
 classpath'
 It 'very clear but in my header package
 org.springframework.transaction
 org.apache.camel.spring
 are present.

 Where am I mistaken or forgotten, or what?



-- 
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: create a transacted policy with camel

2012-01-16 Thread Filippo Balicchia
Sorry surely

from(jms:myqueue).transacted(PROPAGATION_REQUIRED).id(DestRoute).throwException(new
Exception(persistence error))

In spring file definition

bean id=PROPAGATION_REQUIRED
class=org.apache.camel.spring.spi.SpringTransactionPolicy
property name=transactionManager
osgi:reference

interface=org.springframework.transaction.PlatformTransactionManager /
/property
property name=propagationBehaviorName 
value=PROPAGATION_REQUIRED /
/bean



Il 17 gennaio 2012 07:31, Claus Ibsen claus.ib...@gmail.com ha scritto:
 On Tue, Jan 17, 2012 at 7:24 AM, Filippo Balicchia fbalicc...@gmail.com 
 wrote:
 Thanks to all
 I have resolved


 Do you mind sharing your solution?
 So others who have a similar issue, can read your solution.


 Il 16 gennaio 2012 19:11, Filippo Balicchia fbalicc...@gmail.com ha 
 scritto:
 Hello i try to use transaction from camel in osgi bundle.

 My route look like this

 from(jms:myqueue).transacted().id(DestRoute).throwException(new
 Exception(persistence error))
 And i my configuration look like this:

 bean id=activemq
 class=org.apache.activemq.camel.component.ActiveMQComponent
        property name=connectionFactory
                        osgi:reference 
 interface=javax.jms.ConnectionFactory /
        /property
        property name=transacted value=true /
        property name=transactionManager
                osgi:reference
                        
 interface=org.springframework.transaction.PlatformTransactionManager /
        /property
 /bean

 camelContext xmlns=http://camel.apache.org/schema/spring;
                routeBuilder ref=destRoute /
 /camelContext

 At bundle startup it tell me that that doesn't find camel-spring
 'Cannot create a transacted policy as camel-spring.jar is not on the 
 classpath'
 It 'very clear but in my header package
 org.springframework.transaction
 org.apache.camel.spring
 are present.

 Where am I mistaken or forgotten, or what?



 --
 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/


Lost message with Transactionl client

2012-01-16 Thread Filippo Balicchia
Hello i have configuration my route to have a Transaction receiver

here the route

from(jms:myqueue).transacted(PROPAGATION_REQUIRED).id(DestRoute).throwException(new
Exception(persistence error))

With this configuration I'm wainting that the message would still be
on th queue but it isn't.

I check activemq console i see that
Number Of Pending Messages 0
Messages Dequeued  1


I made ​​some mistakes concept or configuration?


Re: Lost message with Transactionl client

2012-01-16 Thread Filippo Balicchia
The problem is misconfiguration of ActiveMQComponent

I forget
property name=transacted value=true/

Cheers

--Filippo

Il 17 gennaio 2012 07:59, Filippo Balicchia fbalicc...@gmail.com ha scritto:
 Hello i have configuration my route to have a Transaction receiver

 here the route

 from(jms:myqueue).transacted(PROPAGATION_REQUIRED).id(DestRoute).throwException(new
 Exception(persistence error))

 With this configuration I'm wainting that the message would still be
 on th queue but it isn't.

 I check activemq console i see that
 Number Of Pending Messages 0
 Messages Dequeued  1


 I made some mistakes concept or configuration?