Re: Issue in upload with Camel
The sendTemplate.sendBody() is a sync API and it will return if the ftp uploading processor is finished. So your main method could be // create context CamelContext context = new DefaultCamelContext(); // create consumer and producer template ConsumerTemplate consumer = context.createConsumerTemplate(); ProducerTemplate producer = context.createProducerTemplate(); // loop to empty file directory while (true) { // receive the message from the file directory, wait at most 3 sec Exchange exchange = consumer.receive("file:c:\\uploadfiles?noop=true", 3000); if (msg == null) { // no more messages in queue break; } // You can do the message transformation here // send it to the ftp endpoint Exchange result = producer.send("FTP URI", exchange); // You may check the result state to see if there is any exception is thrown } Willem Hebert Hu wrote: I looked into the example and still uncertain about how to check whether the sendTemplate is returned. Would you please show me a code snippet? willem.jiang wrote: If you are using file endpoint to pull the directory, it is hard to tell if the uploading processor is over, Can you take look at the camel polling consumer API[1] (Timer based polling consumer example), in this way you can add you logic to check if the file pulling is finished, and the sendTemplate will return when the uploading work is over. [1]http://camel.apache.org/polling-consumer.html Willem Hebert Hu wrote: I started the upload like this CamelContext context = new DefaultCamelContext(); RouteBuilder route = createRouteBuilder(); context.addRoutes(route); context.start(); I'm able to get the route service status by RouteDefinition definition = context.getRouteDefinitions().get(0); context.getRouteStatus(definition) But how can I tell whther the upload is finished? As I always get "Started" even the upload is finished. Hebert Hu wrote: Hi, I've encountered a strange problem when using Camel Sftp component for uploading. Here's my code protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() throws Exception { from("file:c:\\uploadfiles?noop=true").to(getFtpUrl()); from(getFtpUrl()).to("mock:result"); } }; } private String getFtpUrl(){ return "sftp://usern...@sftpserver/ftpload?password=password&binary=true&knownHostsFile=c://.ssh//known_hosts";; } The problem is: When I start my upload procedure, for the files in the c:\uploadfiles (multiples files), some of them will create a .camellock file while others not. As in the remote server, some of the files that have a .camellock copy will be uploaded while others not. Noted that not all the files that has .camellock copies will be uploaded. And an exception is thrown SEVERE: Cannot retrieve file: ftpload/a.txt org.apache.camel.component.file.GenericFileOperationFailedException: Cannot retrieve file: ftpload/a.txt at org.apache.camel.component.file.remote.SftpOperations.retrieveFileToStreamInBody(SftpOperations.java:326) at org.apache.camel.component.file.remote.SftpOperations.retrieveFile(SftpOperations.java:312) at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:183) at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:120) at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:93) at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:99) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:432) at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:295) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:80) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:157) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:181) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690) at java.lang.Thread.run(Thread.java:799) When I run the upload procedure again, more .camellock files appeared, more files been uploaded, and the exception is still thrown. For example. 10 files in c:\uploadfiles, run the upload for the first time, 5 .camellock appeared, 1 file with .camellock uploaded, and an exception. Run for the second time, 2 more .camellock appeared, 1 more file u
Re: In a route, how can I process a batch of messages to send a single output?
Hi, Can you try the lastest Camel 2.2-SNAPSHOT ? As Claus fixed this bug[1] two weeks ago. You can also find the mail thread[2] which discussed this issue. [1]https://issues.apache.org/activemq/browse/CAMEL-2303 [2]http://old.nabble.com/Help%21-org.apache.camel.impl.GroupedExchange-does-not-exist-in-the-latest-download-ts26841584.html Willem alex12345 wrote: I am trying something very simple with Camel 2.1.0. I want to add a Processor to my route that receives batches of 10 messages. With those 10 messages I create a new message that is what I want to be sent. I tried to use an aggregator, with a batchSize of 10, but it doesn't work fine. This is the route definition inside my RouteBuilder.configure() method: from("myEndpoint1...") .aggregate().constant(true).batchSize(10).groupExchanges() .process(new Processor() { public void process(Exchange e) { List list = e.getProperty(Exchange.GROUPED_EXCHANGE, List.class); System.out.println("I am going to process "+list.size()+ "messages"); Object result = CreateSingleOutputFromCollection(list); e.getIn().setBody(result); } }) .to("myEndpoint2..."); The problem is that the list always contains one single element only. What am I doing wrong?
Re: [Patch] Failing tests for bindy CSV with sections
Hi Kevin, Please feel free to create a JIRA[1] and submit the patch with it. It is a easy way for use to track the code issue :) [1] http://issues.apache.org/activemq/browse/CAMEL Willem Kevin Jackson wrote: Hi, I've created a bare bones unit test and model for complex CSV with sections Please see attached or inline version. This patch is against trunk. Happy to help fix this issue any way I can Thanks, Kev
[Patch] Failing tests for bindy CSV with sections
Hi, I've created a bare bones unit test and model for complex CSV with sections Please see attached or inline version. This patch is against trunk. Happy to help fix this issue any way I can Thanks, Kev Index: components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/sections/Footer.java === --- components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/sections/Footer.java (revision 0) +++ components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/sections/Footer.java (revision 0) @@ -0,0 +1,36 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.dataformat.bindy.model.complex.sections; + +import org.apache.camel.dataformat.bindy.annotation.DataField; +import org.apache.camel.dataformat.bindy.annotation.Section; + +...@section(number=3) +...@link +public class Footer { + + @DataField + private String f = "footer"; + + public String getF() { + return f; + } + + public void setF(String f) { + this.f = f; + } +} Index: components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/sections/Header.java === --- components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/sections/Header.java (revision 0) +++ components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/sections/Header.java (revision 0) @@ -0,0 +1,36 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.dataformat.bindy.model.complex.sections; + +import org.apache.camel.dataformat.bindy.annotation.DataField; +import org.apache.camel.dataformat.bindy.annotation.Section; + +...@section(number=1) +...@link +public class Header { + + @DataField + private String h = "HEADER"; + + public String getH() { + return h; + } + + public void setH(String h) { + this.h = h; + } +} Index: components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/sections/Line.java === --- components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/sections/Line.java (revision 0) +++ components/camel-bindy/src/test/java/org/apache/camel/dataformat/bindy/model/complex/sections/Line.java (revision 0) @@ -0,0 +1,37 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.dataformat.bindy.model.com
Re: Issue in upload with Camel
Since I only need to check whether the upload is finished, I wrote from(fileUrl).onCompletion().to(ftpUrl).end() am I writing the right syntax? Since it didn't work well It seems that the in flight count way is more convenient, but I can't find the function available neither in 2.0 or 2.1.Is it a new feature in 2.2? BTW, the download link for 2.2 is not valid currently Claus Ibsen-2 wrote: > > On Tue, Dec 29, 2009 at 8:59 AM, Willem Jiang > wrote: >> If you are using file endpoint to pull the directory, it is hard to tell >> if >> the uploading processor is over, >> Can you take look at the camel polling consumer API[1] (Timer based >> polling >> consumer example), in this way you can add you logic to check if the file >> pulling is finished, and the sendTemplate will return when the uploading >> work is over. >> >> [1]http://camel.apache.org/polling-consumer.html >> > > > You can also use onCompletion or check the inflight registry if there > are any current exchanges. > http://camel.apache.org/oncompletion.html > > CamelContext.getInflightRegistry() > > Which has a counter for the number of exchanges in flight. When it > reaches 0 the file should have been transferred. > > > >> Willem >> >> Hebert Hu wrote: >>> >>> I started the upload like this >>> >>> CamelContext context = new DefaultCamelContext(); >>> RouteBuilder route = createRouteBuilder(); >>> context.addRoutes(route); >>> context.start(); >>> >>> I'm able to get the route service status by RouteDefinition definition = >>> context.getRouteDefinitions().get(0); >>> context.getRouteStatus(definition) >>> >>> But how can I tell whther the upload is finished? >>> As I always get "Started" even the upload is finished. >>> >>> >>> Hebert Hu wrote: Hi, I've encountered a strange problem when using Camel Sftp component for uploading. Here's my code protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() throws Exception { from("file:c:\\uploadfiles?noop=true").to(getFtpUrl()); from(getFtpUrl()).to("mock:result"); } }; } private String getFtpUrl(){ return "sftp://usern...@sftpserver/ftpload?password=password&binary=true&knownHostsFile=c://.ssh//known_hosts";; } The problem is: When I start my upload procedure, for the files in the c:\uploadfiles (multiples files), some of them will create a .camellock file while others not. As in the remote server, some of the files that have a .camellock copy will be uploaded while others not. Noted that not all the files that has .camellock copies will be uploaded. And an exception is thrown SEVERE: Cannot retrieve file: ftpload/a.txt org.apache.camel.component.file.GenericFileOperationFailedException: Cannot retrieve file: ftpload/a.txt at org.apache.camel.component.file.remote.SftpOperations.retrieveFileToStreamInBody(SftpOperations.java:326) at org.apache.camel.component.file.remote.SftpOperations.retrieveFile(SftpOperations.java:312) at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:183) at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:120) at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:93) at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:99) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:432) at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:295) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:80) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:157) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:181) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690) at java.lang.Thread.run(Thread.java:799) When I run the upload procedure again, more .camellock files appeared, more files been uploaded, and the exception is still thrown. For example. 10 files in c:\uploadfiles, run the upload for the first time, 5 .camellock appeared, 1 file with .camellock uploaded, and an exception. Run for the se
Re: Issue in upload with Camel
I looked into the example and still uncertain about how to check whether the sendTemplate is returned. Would you please show me a code snippet? willem.jiang wrote: > > If you are using file endpoint to pull the directory, it is hard to tell > if the uploading processor is over, > Can you take look at the camel polling consumer API[1] (Timer based > polling consumer example), in this way you can add you logic to check if > the file pulling is finished, and the sendTemplate will return when the > uploading work is over. > > [1]http://camel.apache.org/polling-consumer.html > > Willem > > Hebert Hu wrote: >> I started the upload like this >> >> CamelContext context = new DefaultCamelContext(); >> RouteBuilder route = createRouteBuilder(); >> context.addRoutes(route); >> context.start(); >> >> I'm able to get the route service status by >> RouteDefinition definition = context.getRouteDefinitions().get(0); >> context.getRouteStatus(definition) >> >> But how can I tell whther the upload is finished? >> As I always get "Started" even the upload is finished. >> >> >> Hebert Hu wrote: >>> Hi, >>> >>> I've encountered a strange problem when using Camel Sftp component for >>> uploading. >>> >>> Here's my code >>> >>> protected RouteBuilder createRouteBuilder() throws Exception { >>> return new RouteBuilder() { >>> public void configure() throws Exception { >>> from("file:c:\\uploadfiles?noop=true").to(getFtpUrl()); >>> from(getFtpUrl()).to("mock:result"); >>> } >>> }; >>> } >>> >>> private String getFtpUrl(){ >>> return >>> "sftp://usern...@sftpserver/ftpload?password=password&binary=true&knownHostsFile=c://.ssh//known_hosts";; >>> } >>> >>> The problem is: When I start my upload procedure, for the files in the >>> c:\uploadfiles (multiples files), some of them will create a .camellock >>> file while others not. As in the remote server, some of the files that >>> have a .camellock copy will be uploaded while others not. Noted that not >>> all the files that has .camellock copies will be uploaded. And an >>> exception is thrown >>> SEVERE: Cannot retrieve file: ftpload/a.txt >>> org.apache.camel.component.file.GenericFileOperationFailedException: >>> Cannot retrieve file: ftpload/a.txt >>> at >>> org.apache.camel.component.file.remote.SftpOperations.retrieveFileToStreamInBody(SftpOperations.java:326) >>> at >>> org.apache.camel.component.file.remote.SftpOperations.retrieveFile(SftpOperations.java:312) >>> at >>> org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:183) >>> at >>> org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:120) >>> at >>> org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:93) >>> at >>> org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:99) >>> at >>> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:432) >>> at >>> java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:295) >>> at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150) >>> at >>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:80) >>> at >>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:157) >>> at >>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:181) >>> at >>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665) >>> at >>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690) >>> at java.lang.Thread.run(Thread.java:799) >>> When I run the upload procedure again, more .camellock files appeared, >>> more files been uploaded, and the exception is still thrown. >>> For example. 10 files in c:\uploadfiles, run the upload for the first >>> time, 5 .camellock appeared, 1 file with .camellock uploaded, and an >>> exception. Run for the second time, 2 more .camellock appeared, 1 more >>> file uploaded, and an exception again. >>> >>> I'm using Camel-core 2.0.0, camel-ftp 2.0.0 >>> >>> Can any one shed some light on me? >>> >> > > > -- View this message in context: http://old.nabble.com/Issue-in-upload-with-Camel-tp26940685p26964265.html Sent from the Camel - Users mailing list archive at Nabble.com.
Processing 5 files at a time - Threads? SEDA + Concurrent Consumers?
I am trying to write a process that will use a file endpoint (camel 2.1.0) to read from a directory. I need the process to read a file from the directory and then do some processing on the contents (namely hitting a REST service for each record in the file). We have been asked to limit the number of threads that are hitting the service to 5. So we decided to simply process 5 files at a time (to avoid concurrency issues reading 1 file and writing to 1 file with 5 threads) I tried a few different approaches, and I wanted to see if there was a way to do what I want. Approach 1: from("file://incoming").to("seda:filequeue") from("seda:filequeue").thread(5).process() Now - this reads in ALL of the files in the directory (places camelLock on all) and then sends them to the seda endpoint. I saw log messages that referred to thread 1 through 6. But from what I read on the documentation, thread() is not necessarily going t limit it at that number. Approach 2: from("file://incoming").thread(5).process() This only processed 5 files at a time - but created camelLocks on all files in the directory. So then I tried approach 3: from("file://incoming").to("seda:filequeue") from("seda:filequeue?concurrentConsumers=5").process() Again this seems to work, however it puts a camelLock on all the files (because they were all processed by the first part of the route, they are just queued up in the second). While approach 3 works - what I would really like is to not have the camelLock placed on the files that are not being processed. So watching the directory, there would be (at most) 5 files with camelLock files created at a time, when they finish they are moved to the .camel directory, and then it starts processing the next file in the directory. Is that possible? Is there anything I should be sure to do in an error route so that I "roll back" the camel locks to ensure that unprocessed files are ready to process the next time the application starts? -- View this message in context: http://old.nabble.com/Processing-5-files-at-a-time---Threads--SEDA-%2B-Concurrent-Consumers--tp26960942p26960942.html Sent from the Camel - Users mailing list archive at Nabble.com.
In a route, how can I process a batch of messages to send a single output?
I am trying something very simple with Camel 2.1.0. I want to add a Processor to my route that receives batches of 10 messages. With those 10 messages I create a new message that is what I want to be sent. I tried to use an aggregator, with a batchSize of 10, but it doesn't work fine. This is the route definition inside my RouteBuilder.configure() method: from("myEndpoint1...") .aggregate().constant(true).batchSize(10).groupExchanges() .process(new Processor() { public void process(Exchange e) { List list = e.getProperty(Exchange.GROUPED_EXCHANGE, List.class); System.out.println("I am going to process "+list.size()+ "messages"); Object result = CreateSingleOutputFromCollection(list); e.getIn().setBody(result); } }) .to("myEndpoint2..."); The problem is that the list always contains one single element only. What am I doing wrong? -- View this message in context: http://old.nabble.com/In-a-route%2C-how-can-I-process-a-batch-of-messages-to-send-a-single-output--tp26959490p26959490.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: newbie help
On Tue, Dec 29, 2009 at 1:58 PM, yaog wrote: > > > > Claus Ibsen-2 wrote: >> >> You got a few issues mixed up. >> >> from A -> B will let Camel create a polling consumer and invoke A all the >> time. >> >> What you are looking for is some queue like functionally where you can >> send a message to that queue and then have it routed. >> http://camel.apache.org/seda.html >> >> > > This indeed helped me out. > > Thank you very much. > > 1. I haven't seen anything about this in documentation. Can you refer me to > somewhere that can help sort these things out? > Check out the Polling Consumer EIP pattern from the Camel pattern page > 2. Is there a way to have all the route be synchronic within the same > thread? Is "direct" the way to do it? > Yes direct is sync. Are you using Camel together with something else, lets say ServiceMix? If you are just started with Camel it may be a good idea to try using Camel 2.1.0 as all new development etc. is happening on the 2.x branch. > > > -- > View this message in context: > http://old.nabble.com/newbie-help-tp26951866p26954156.html > Sent from the Camel - Users mailing list archive at Nabble.com. > > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus
Re: newbie help
Claus Ibsen-2 wrote: > > You got a few issues mixed up. > > from A -> B will let Camel create a polling consumer and invoke A all the > time. > > What you are looking for is some queue like functionally where you can > send a message to that queue and then have it routed. > http://camel.apache.org/seda.html > > This indeed helped me out. Thank you very much. 1. I haven't seen anything about this in documentation. Can you refer me to somewhere that can help sort these things out? 2. Is there a way to have all the route be synchronic within the same thread? Is "direct" the way to do it? -- View this message in context: http://old.nabble.com/newbie-help-tp26951866p26954156.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel-xmpp througth proxy
Claus Ibsen wrote: On Tue, Dec 29, 2009 at 2:58 AM, Willem Jiang wrote: Hi, I just did a quick search and find Smack API 3.1.0 (which is not finally released yet) supports the proxy setting[1]. And now we use the Smack API 3.0.4 in camel-xmpp component, and it doesn't support the proxy setting. Please feel free to submit a upgrading patch for it :) Has Smack 3.1.0 been released? The latest release is Smack 3.1.0 beta1, which is released 1 year, 1 month ago :( [1]http://www.igniterealtime.org/issues/browse/SMACK-226 Willem Claus Ibsen wrote: Hi Check out the XMPP Smack API which is used for the XMPP stuff, whether it supports http proxy and how it does. On Wed, Dec 23, 2009 at 10:00 AM, Aleksey Masny wrote: Hello all! My route: from("stream:in?promptMessage=You message: ").to("xmpp://pi...@qip.ru/aleksey.ma...@gmail.com?password=xx"); My problem: At home, without proxy server, this route send message to aleksey.ma...@gmail.com sucessfull. But at office computer, with proxy server, xmpp component throw exception after try to connect, and message not send. Tracer INFO 2e15772d-07ff-48e7-b720-0708c4aee90e (route1) from(stream://in?promptMessage=You message: ) --> xmpp://pi...@qip.ru/aleksey.ma...@gmail.com?password=xx <<< Pattern:InOnly, BodyType:String, Body:mymessage XmppPrivateChatProducerDEBUG Creating XmppPrivateChatProducer to participant aleksey.ma...@gmail.com DefaultManagementAgent DEBUG Registered MBean with objectname: org.apache.camel:context=masny/camelContext,type=producers,name=XmppPrivateChatProducer(0x14627a) XmppPrivateChatProducerDEBUG Starting producer: Producer[xmpp://pi...@qip.ru/aleksey.ma...@gmail.com?password=xx] ProducerCache DEBUG Adding to producer cache with key: Endpoint[xmpp://pi...@qip.ru/aleksey.ma...@gmail.com?password=xx] for producer: Producer[xmpp://pi...@qip.ru/aleksey.ma...@gmail.com?password=xx] DefaultErrorHandlerDEBUG Failed delivery for exchangeId: 2e15772d-07ff-48e7-b720-0708c4aee90e. On delivery attempt: 0 caught: java.lang.NullPointerException DefaultErrorHandlerDEBUG This exchange is not handled so its marked as failed: Exchange[Message: mymessage] I try to set proxy before init Camel public static void main(String... args) throws Exception { System.getProperties().put("proxySet", "true"); System.getProperties().put("proxyHost", "127.0.0.1"); System.getProperties().put("proxyPort", "8989"); Main.main(args); } But message not sended. I try to set VM parameters when running my route -DproxyHost="osaka.mti.net" -DproxyPort=3128 Yes, message not sended also. How settings proxy for camel-xmpp component? For example, in camel-http component have own proxy settings. Sorry my English. -- View this message in context: http://old.nabble.com/camel-xmpp-througth-proxy-tp26897637p26897637.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel-xmpp througth proxy
On Tue, Dec 29, 2009 at 2:58 AM, Willem Jiang wrote: > Hi, > > I just did a quick search and find Smack API 3.1.0 (which is not finally > released yet) supports the proxy setting[1]. > And now we use the Smack API 3.0.4 in camel-xmpp component, and it doesn't > support the proxy setting. > > Please feel free to submit a upgrading patch for it :) > Has Smack 3.1.0 been released? > [1]http://www.igniterealtime.org/issues/browse/SMACK-226 > > Willem > > > Claus Ibsen wrote: >> >> Hi >> >> Check out the XMPP Smack API which is used for the XMPP stuff, whether >> it supports http proxy and how it does. >> >> >> On Wed, Dec 23, 2009 at 10:00 AM, Aleksey Masny >> wrote: >>> >>> Hello all! >>> >>> My route: >>> from("stream:in?promptMessage=You message: >>> ").to("xmpp://pi...@qip.ru/aleksey.ma...@gmail.com?password=xx"); >>> >>> My problem: >>> At home, without proxy server, this route send message to >>> aleksey.ma...@gmail.com sucessfull. >>> But at office computer, with proxy server, xmpp component throw exception >>> after try to connect, and message not send. >>> >>> Tracer INFO 2e15772d-07ff-48e7-b720-0708c4aee90e >> >> (route1) from(stream://in?promptMessage=You message: ) --> >>> >>> xmpp://pi...@qip.ru/aleksey.ma...@gmail.com?password=xx <<< >>> Pattern:InOnly, BodyType:String, Body:mymessage >>> XmppPrivateChatProducer DEBUG Creating XmppPrivateChatProducer to >>> participant aleksey.ma...@gmail.com >>> DefaultManagementAgent DEBUG Registered MBean with objectname: >>> >>> org.apache.camel:context=masny/camelContext,type=producers,name=XmppPrivateChatProducer(0x14627a) >>> XmppPrivateChatProducer DEBUG Starting producer: >>> Producer[xmpp://pi...@qip.ru/aleksey.ma...@gmail.com?password=xx] >>> ProducerCache DEBUG Adding to producer cache with key: >>> Endpoint[xmpp://pi...@qip.ru/aleksey.ma...@gmail.com?password=xx] for >>> producer: >>> Producer[xmpp://pi...@qip.ru/aleksey.ma...@gmail.com?password=xx] >>> DefaultErrorHandler DEBUG Failed delivery for exchangeId: >>> 2e15772d-07ff-48e7-b720-0708c4aee90e. On delivery attempt: 0 caught: >>> java.lang.NullPointerException >>> DefaultErrorHandler DEBUG This exchange is not handled so its >>> marked as failed: Exchange[Message: mymessage] >>> >>> I try to set proxy before init Camel >>> public static void main(String... args) throws Exception { >>> >>> System.getProperties().put("proxySet", "true"); >>> System.getProperties().put("proxyHost", "127.0.0.1"); >>> System.getProperties().put("proxyPort", "8989"); >>> >>> Main.main(args); >>> } >>> >>> But message not sended. >>> >>> I try to set VM parameters when running my route >>> -DproxyHost="osaka.mti.net" >>> -DproxyPort=3128 >>> Yes, message not sended also. >>> >>> How settings proxy for camel-xmpp component? >>> >>> For example, in camel-http component have own proxy settings. >>> Sorry my English. >>> -- >>> View this message in context: >>> http://old.nabble.com/camel-xmpp-througth-proxy-tp26897637p26897637.html >>> Sent from the Camel - Users mailing list archive at Nabble.com. >>> >>> >> >> >> > > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus
Re: newbie help
You got a few issues mixed up. from A -> B will let Camel create a polling consumer and invoke A all the time. What you are looking for is some queue like functionally where you can send a message to that queue and then have it routed. http://camel.apache.org/seda.html So try using: from("seda:start").to("bean:beanB"); And then send a message to seda:start using the producer template. Or use both beans from("seda:start").to("bean:beanA").to("bean:beanB"); On Tue, Dec 29, 2009 at 11:56 AM, yaog wrote: > > It does not. > > This is the code in compA. I see the system out: > > public String start2(String from){ > String message = "in compA from: \"" + from + "\""; > System.out.println(message); > return message; > } > > This is the code in compB. I do not see the system out: > > public String start(String from){ > String message = "in compB from: " + from; > System.out.println(message); > return message; > } > > Obviously I am doing something wrong, but even this simple case does not > work for me. I assume the creation of message/exchange between A and B > should be done by Camel, right? > -- > View this message in context: > http://old.nabble.com/newbie-help-tp26951866p26953226.html > Sent from the Camel - Users mailing list archive at Nabble.com. > > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus
Re: Issue in upload with Camel
On Tue, Dec 29, 2009 at 8:59 AM, Willem Jiang wrote: > If you are using file endpoint to pull the directory, it is hard to tell if > the uploading processor is over, > Can you take look at the camel polling consumer API[1] (Timer based polling > consumer example), in this way you can add you logic to check if the file > pulling is finished, and the sendTemplate will return when the uploading > work is over. > > [1]http://camel.apache.org/polling-consumer.html > You can also use onCompletion or check the inflight registry if there are any current exchanges. http://camel.apache.org/oncompletion.html CamelContext.getInflightRegistry() Which has a counter for the number of exchanges in flight. When it reaches 0 the file should have been transferred. > Willem > > Hebert Hu wrote: >> >> I started the upload like this >> >> CamelContext context = new DefaultCamelContext(); >> RouteBuilder route = createRouteBuilder(); >> context.addRoutes(route); >> context.start(); >> >> I'm able to get the route service status by RouteDefinition definition = >> context.getRouteDefinitions().get(0); >> context.getRouteStatus(definition) >> >> But how can I tell whther the upload is finished? >> As I always get "Started" even the upload is finished. >> >> >> Hebert Hu wrote: >>> >>> Hi, >>> I've encountered a strange problem when using Camel Sftp component for >>> uploading. >>> >>> Here's my code >>> >>> protected RouteBuilder createRouteBuilder() throws Exception { >>> return new RouteBuilder() { >>> public void configure() throws Exception { >>> from("file:c:\\uploadfiles?noop=true").to(getFtpUrl()); >>> from(getFtpUrl()).to("mock:result"); >>> } >>> }; >>> } >>> >>> private String getFtpUrl(){ >>> return >>> >>> "sftp://usern...@sftpserver/ftpload?password=password&binary=true&knownHostsFile=c://.ssh//known_hosts";; >>> } >>> >>> The problem is: When I start my upload procedure, for the files in the >>> c:\uploadfiles (multiples files), some of them will create a .camellock >>> file while others not. As in the remote server, some of the files that >>> have a .camellock copy will be uploaded while others not. Noted that not >>> all the files that has .camellock copies will be uploaded. And an >>> exception is thrown >>> SEVERE: Cannot retrieve file: ftpload/a.txt >>> org.apache.camel.component.file.GenericFileOperationFailedException: >>> Cannot retrieve file: ftpload/a.txt >>> at >>> >>> org.apache.camel.component.file.remote.SftpOperations.retrieveFileToStreamInBody(SftpOperations.java:326) >>> at >>> >>> org.apache.camel.component.file.remote.SftpOperations.retrieveFile(SftpOperations.java:312) >>> at >>> >>> org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:183) >>> at >>> >>> org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:120) >>> at >>> >>> org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:93) >>> at >>> >>> org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:99) >>> at >>> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:432) >>> at >>> >>> java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:295) >>> at >>> java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150) >>> at >>> >>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:80) >>> at >>> >>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:157) >>> at >>> >>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:181) >>> at >>> >>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665) >>> at >>> >>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690) >>> at java.lang.Thread.run(Thread.java:799) >>> When I run the upload procedure again, more .camellock files appeared, >>> more files been uploaded, and the exception is still thrown. >>> For example. 10 files in c:\uploadfiles, run the upload for the first >>> time, 5 .camellock appeared, 1 file with .camellock uploaded, and an >>> exception. Run for the second time, 2 more .camellock appeared, 1 more >>> file uploaded, and an exception again. >>> >>> I'm using Camel-core 2.0.0, camel-ftp 2.0.0 >>> >>> Can any one shed some light on me? >>> >> > > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus
Re: Startup invocation of a route
Claus Ibsen-2 wrote: > > On Tue, Dec 29, 2009 at 12:29 AM, huntc wrote: > > Just a note. Do you want the route to trigger *only* when CamelContext > has just been started? > What if you stop and start the route later, eg using JMX? > Having the route fired off in this circumstance is also good. For me it is irrelevant what starts/stops the context. Claus Ibsen-2 wrote: > > I wonder if Quartz got some configuration to fire on startup as well? > Dunno. Claus Ibsen-2 wrote: > > But the notification might be a nicer solution as you get fine grained > callbacks and can fire upon camel context started etc. > Yes indeed. Very nice. Thanks again! -- View this message in context: http://old.nabble.com/Startup-invocation-of-a-route-tp26949232p26953636.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: newbie help
It does not. This is the code in compA. I see the system out: public String start2(String from){ String message = "in compA from: \"" + from + "\""; System.out.println(message); return message; } This is the code in compB. I do not see the system out: public String start(String from){ String message = "in compB from: " + from; System.out.println(message); return message; } Obviously I am doing something wrong, but even this simple case does not work for me. I assume the creation of message/exchange between A and B should be done by Camel, right? -- View this message in context: http://old.nabble.com/newbie-help-tp26951866p26953226.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: newbie help
Yeah looks like you B bean returns null. Please return something else. On Tue, Dec 29, 2009 at 10:32 AM, Willem Jiang wrote: > Form the log it looks like you just passed null into the bean method , and > bean method returning the null result. > > I don't know if it will cause the message stop routing , but can you try to > return some thing in your bean:compA ? > > Willem > > yaog wrote: >> >> Changing my main to have: >> >> producerTemplate.sendBody("bean:compB", ExchangePattern.InOut, null); >> >> shows that compB is invoked. >> >> full log file attached. >> >> Please advise. http://old.nabble.com/file/p26952227/trace_log.txt >> trace_log.txt > > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus
Re: Startup invocation of a route
On Tue, Dec 29, 2009 at 12:29 AM, huntc wrote: > > One thing that has always eluded me is how to specify that something be done > immediately upon the CamelContext having started up. > > For example, I have a Quartz based service that executes every hour at 10 > minutes past the hour. However when the CamelContext starts up I'd like this > service to be invoked immediately and then go into its scheduling behaviour. > This is so that other consumers of the services I provide can get their data > immediately without having to wait up to an hour given service startup. > > Firstly it'd be great if there was an option on the Quartz component to > always fire off an initial event. However in general terms it'd be great to > have the ability to specify that a route is invoked upon the CamelContext > having been established (with all of its routes configured within the > current RouterBuilder). Perhaps RouteBuilder needs a new overide-able method > that is invoked in this situation. > > Incidentally I see many references to from("direct:start") throughout the > doco and examples, but no idea of how this route is invoked. > Just a note. Do you want the route to trigger *only* when CamelContext has just been started? What if you stop and start the route later, eg using JMX? I wonder if Quartz got some configuration to fire on startup as well? But anyway Stephen showed a great solution later in this mail thread. Also you can just register some spring bean and have it depends on camel and then fire in some messages to the routes you want to get started. But the notification might be a nicer solution as you get fine grained callbacks and can fire upon camel context started etc. > Thanks for any help in unwinding my confusion. > -- > View this message in context: > http://old.nabble.com/Startup-invocation-of-a-route-tp26949232p26949232.html > Sent from the Camel - Users mailing list archive at Nabble.com. > > -- Claus Ibsen Apache Camel Committer Author of Camel in Action: http://www.manning.com/ibsen/ Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus
Re: Startup invocation of a route
Stephen Gargan wrote: > > Claus has got you covered ;) > How could I have doubted him! Stephen Gargan wrote: > > There is an EventNotification mechanism > that you can use... > This works beautifully. Thanks so much. -- View this message in context: http://old.nabble.com/Startup-invocation-of-a-route-tp26949232p26952882.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: newbie help
Form the log it looks like you just passed null into the bean method , and bean method returning the null result. I don't know if it will cause the message stop routing , but can you try to return some thing in your bean:compA ? Willem yaog wrote: Changing my main to have: producerTemplate.sendBody("bean:compB", ExchangePattern.InOut, null); shows that compB is invoked. full log file attached. Please advise. http://old.nabble.com/file/p26952227/trace_log.txt trace_log.txt
Re: newbie help
Changing my main to have: producerTemplate.sendBody("bean:compB", ExchangePattern.InOut, null); shows that compB is invoked. full log file attached. Please advise. http://old.nabble.com/file/p26952227/trace_log.txt trace_log.txt -- View this message in context: http://old.nabble.com/newbie-help-tp26951866p26952227.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Startup invocation of a route
Maybe we can add option in camel-quartz to let it fire the trigger when the route is started. Willem Stephen Gargan wrote: Christopher, Claus has got you covered ;) There is an EventNotification mechanism that you can use. Add the following to your routes configure public class InvokedOnStartupRoute extends RouteBuilder { @Override public void configure() throws Exception { final CamelContext context = getContext(); context.getManagementStrategy().setEventNotifier(new EventNotifier() { public void notify(EventObject event) throws Exception { if(event instanceof CamelContextStartedEvent) { ProducerTemplate template = context.createProducerTemplate(); template.sendBody("direct:invokedOnStartup", "Started"); } } public boolean isEnabled(EventObject event) { return true; } }); from("direct:invokedOnStartup").to("mock:invokedOnStartup"); } } It might be nice also if there were a method in the LifecycleStrategy interface, onInitializationComplete or the like, that fit a similar purpose. I'll let Claus comment on that. rgds, ste On Mon, Dec 28, 2009 at 6:06 PM, huntc wrote: Hi Stephen, Thanks for your response. I do understand the use of the direct component, but thanks for the explanation any how. I guess using the Spring Events mechanism will get me there, but it'd be nice to codify the solution in a way that remains agnostic of being invoked from Spring. I'm thinking that it'd be useful to raise a JIRA so that RouteBuilder gets the opportunity of kicking things off once the context is ready. What'd think? BTW: I do not have a Main class as I'm using org.apache.camel.spring.Main. Kind regards, Christopher -- View this message in context: http://old.nabble.com/Startup-invocation-of-a-route-tp26949232p26950280.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: newbie help
yaog wrote: Hi, I am a newbie with Camel. 1. how does the routesBuilder work in IDS? simple "from" and "to in code of course does not compile... Sorry , what's IDS? 2. I have the following spring section: http://camel.apache.org/schema/spring";> In My Main I do this: ApplicationContext context = new ClassPathXmlApplicationContext("spring-camel-context.xml"); ProducerTemplate producerTemplate = (ProducerTemplate)context.getBean("camelTemplate"); producerTemplate.sendBody("bean:compA", ExchangePattern.InOut, "message"); But I see it gets to compA but not to compB. what is the problem? from logs looks like route is built ok: Route 0: EventDrivenConsumerRoute[Endpoint[bean://compA] -> Instrumentation:route[UnitOfWork(Channel[sendTo(Endpoint[bean://compB])])]] Please advise. It could be your compB has more than one method :) Can you try to use the producerTemplate to send the message to bean:compB to see if the compB can be invoked ? Can you try to enable trace in the camelContext like this, to see more log trace? xmlns="http://camel.apache.org/schema/spring";> Thanks. Willem
Re: Issue in upload with Camel
If you are using file endpoint to pull the directory, it is hard to tell if the uploading processor is over, Can you take look at the camel polling consumer API[1] (Timer based polling consumer example), in this way you can add you logic to check if the file pulling is finished, and the sendTemplate will return when the uploading work is over. [1]http://camel.apache.org/polling-consumer.html Willem Hebert Hu wrote: I started the upload like this CamelContext context = new DefaultCamelContext(); RouteBuilder route = createRouteBuilder(); context.addRoutes(route); context.start(); I'm able to get the route service status by RouteDefinition definition = context.getRouteDefinitions().get(0); context.getRouteStatus(definition) But how can I tell whther the upload is finished? As I always get "Started" even the upload is finished. Hebert Hu wrote: Hi, I've encountered a strange problem when using Camel Sftp component for uploading. Here's my code protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() throws Exception { from("file:c:\\uploadfiles?noop=true").to(getFtpUrl()); from(getFtpUrl()).to("mock:result"); } }; } private String getFtpUrl(){ return "sftp://usern...@sftpserver/ftpload?password=password&binary=true&knownHostsFile=c://.ssh//known_hosts";; } The problem is: When I start my upload procedure, for the files in the c:\uploadfiles (multiples files), some of them will create a .camellock file while others not. As in the remote server, some of the files that have a .camellock copy will be uploaded while others not. Noted that not all the files that has .camellock copies will be uploaded. And an exception is thrown SEVERE: Cannot retrieve file: ftpload/a.txt org.apache.camel.component.file.GenericFileOperationFailedException: Cannot retrieve file: ftpload/a.txt at org.apache.camel.component.file.remote.SftpOperations.retrieveFileToStreamInBody(SftpOperations.java:326) at org.apache.camel.component.file.remote.SftpOperations.retrieveFile(SftpOperations.java:312) at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:183) at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:120) at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:93) at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:99) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:432) at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:295) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:80) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:157) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:181) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690) at java.lang.Thread.run(Thread.java:799) When I run the upload procedure again, more .camellock files appeared, more files been uploaded, and the exception is still thrown. For example. 10 files in c:\uploadfiles, run the upload for the first time, 5 .camellock appeared, 1 file with .camellock uploaded, and an exception. Run for the second time, 2 more .camellock appeared, 1 more file uploaded, and an exception again. I'm using Camel-core 2.0.0, camel-ftp 2.0.0 Can any one shed some light on me?