Re: Deprecating TestNG?

2016-10-18 Thread Giorgio Vespucci
Hi Claus?
May I know why you're deprecating TestNG?
Do you think it has no future?
Is it stuck in development?
Thank you

Il mar 18 ott 2016, 22:38 Claus Ibsen  ha scritto:

> Hi
>
> Its deprecated from Camel 2.18 onwards, but will stay there in 2.x.
>
> From Camel 3.x onwards we will removed deprecated stuff from 2.x.
>
>
>
> On Tue, Oct 18, 2016 at 9:36 PM, Goyal, Arpit  wrote:
> > Hi Claus,
> >
> > Heard your JDKIO Video 2016 (online) mentioning that TestNG support
> would be deprecated. Is there a timeline when you would deprecate and is
> there a possibility of removal (I presume 3.x?)
> >
> > Just wanted to know because we are currently using TestNG and want to
> have brief idea as to how much time we have to move or should we switch now
> itself.
> >
> > Regards,
> > Arpit.
> >
> > PS: Of course not so happy getting to know testng support is being
> removed.
>
>
>
> --
> Claus Ibsen
> -
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>


RE: send same message to multiple, not all, websocket clients

2016-10-18 Thread shemeem . sp
Hi Mark,
you have to keep connection keys from each client in a map or list,
then you need to send same data to the producer with different connection key.

here is how you can get the connection key from each client. whenever a client 
makes a connection with your websocket consumer you will get a connection key.

Apache camel websocket consumer example.
 from("direct:Consumer1")
.process(new Processor() {
 public void process(Exchange exchange) throws Exception {
   Map headers=exchange.getIn().getHeaders();
//you will get a unique connection key from the exchange header.This would 
be unique for each client.
//store this key somewhere, to send messages to particular client.
String 
uniqueConnectionKey=headers.get("websocket.connectionKey").toString();
  //you can get message from the client like below.
  String dataFromClient=exchange.getIn().getBody().toString();
  
   }
}).end();

Apache camel websocket producer example:
  from("direct:Producer1").
  //we will use this connectionKey for uniquely identifying each connection 
from the client.
  setHeader(WebsocketConstants.CONNECTION_KEY, header("connectionKey")).
  to("websocket://{host}:{port}/camel-websocket?sendToAll=false").end();

here is the sample for producer template.
ProducerTemplate template=camelContext.createProducerTemplate();

repeat this step with same message and different connection key:
template.sendBodyAndHeader("direct:Producer1", {message}, "connectionKey", 
{connectionkey});

I hope this would help

-Original Message-
From: "Mark" 
Sent: Tuesday, October 18, 2016 10:51am
To: users@camel.apache.org
Subject: send same message to multiple, not all, websocket clients

I am receiving messages of data that I am processing with Camel, similar to
a chat system.  Clients may "subscribe" to the data feed which will require
me to send the messages to the clients that subscribe to that message type
over websockets.  How can I implement this websocket communication using
Camel since the current implementation only allows for one connection key
per message?  Would I somehow duplicate the message and set a different
connection key for each message?




Re: Is netty4 disconnect/reconnect notification possible?

2016-10-18 Thread Steve973
Thanks, Claus.  One Camel message mapping to one netty message is quite
fine, but it needs to keep a persistent TCP connection for our purposes.
We have to send something akin to a "hello" packet that lets the server at
the TCP destination know what kind of data it will be receiving, and other
"meta" information about the data.  As long as the connection persists, the
server will know what to do with the data.  But, once the connection drops
and, I assume, Camel transparently makes the connection again, the server
won't know enough about the data that we are sending to it in order to know
what to do with the data.  We need to know that a connection has been
dropped and re-established so that we can send our "hello" packet again,
and then the server will know what to do with our data.  Do I need a custom
ChannelHandler to get notification about dropped connections?  Or is there
another approach that we should take?

Thanks,
Steve

On Tue, Oct 18, 2016 at 4:44 PM, Claus Ibsen  wrote:

> I think you would need to implement some custom codec or something to
> deal with this kind of requirements.
>
> The out of the box behavior is to use netty for messaging like where
> each Camel message maps to one netty message being sent over the wire.
>
>
>
> On Tue, Oct 18, 2016 at 7:29 PM, Steve973  wrote:
> > Hello.  Our Camel route is sending messages to a netty4 tcp endpoint, but
> > we need to make sure to send a particular type of message as the first
> > message.  If a disconnection happens during processing, we have to send
> > this special message upon reconnection.  Is this possible to achieve?
> Will
> > we need to write a custom handler for netty to do this?  Any suggestions
> > are quite welcome!
> >
> > Thanks,
> > Steve
>
>
>
> --
> Claus Ibsen
> -
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>


RE: [camel-ftp] Can't catch Invalid SFTP port exception

2016-10-18 Thread Goyal, Arpit
Thanks Claus for the clarification. If you are able to recall and point me to 
the fix, that would be great. I would like to understand.

-Original Message-
From: Claus Ibsen [mailto:claus.ib...@gmail.com] 
Sent: Tuesday, October 18, 2016 1:54 PM
To: users@camel.apache.org
Subject: Re: [camel-ftp] Can't catch Invalid SFTP port exception

Try with Camel 2.18.0 release. We may have fixed something about this.
There is a vague memory of mine looking into and fixing something with
consumer template and bridge.



On Sun, Oct 16, 2016 at 9:54 PM, Goyal, Arpit  wrote:
> I am trying to handle all the exception use cases of SFTP for logging 
> purposes. In case user has given invalid Port address for sftp server even 
> when using pollStrategy attribute ->
>
> 1) We are not able to get the exception back in the code.
> 2) Exchange comes back null.
> 3) Associated below code to logger and see the exception logged though. 
> (Partial stack given first; complete exception later)
>
> I am intentionally giving wrong PORT () instead of the correct port (22). 
> What are we missing here?
>
> Other Cases:
>
> -  Valid Port - the poll strategy 'begin' & 'commit' are called.
>
> -  Invalid User or Invalid Password - 'rollback' method is invoked 
> with GenericFileOperationFailedException.
>
> Regards,
> Arpit.
>
> Exception:
> --
> org.apache.camel.component.file.GenericFileOperationFailedException: Cannot 
> connect to sftp://d...@test.rebex.net:
> at 
> org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:146)
> at 
> org.apache.camel.component.file.remote.RemoteFileConsumer.connectIfNecessary(RemoteFileConsumer.java:203)
> at 
> org.apache.camel.component.file.remote.RemoteFileConsumer.recoverableConnectIfNecessary(RemoteFileConsumer.java:171)
> at 
> org.apache.camel.component.file.remote.RemoteFileConsumer.prePollCheck(RemoteFileConsumer.java:59)
> at 
> org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:106)
> at 
> org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174)
> at 
> org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101)
> at 
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
> at 
> java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
> at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
> at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
> at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> at java.lang.Thread.run(Thread.java:812)
> Caused by: com.jcraft.jsch.JSchException: timeout: socket is not established
> at com.jcraft.jsch.Util.createSocket(Util.java:389)
> at com.jcraft.jsch.Session.connect(Session.java:215)
> at 
> org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:118)
> ... 13 more
>
> Sample Program:
> 
>
> public class ConsumerTemplateAndSftpIssues {
>
>   private static final String DIRECT_START = "direct:start";
>
>   public static void main(String[] args) throws Exception {
> BasicConfigurator.configure();
>
> DefaultCamelContext c = new DefaultCamelContext();
>
> SimpleRegistry sr = new SimpleRegistry();
> c.setRegistry(sr);
>
> sr.put("customPoll", new PollingConsumerPollStrategy(){
>
>   @Override
>   public boolean begin(Consumer consumer, Endpoint endpoint) {
> return true;
>   }
>
>   @Override
>   public void commit(Consumer consumer, Endpoint endpoint, int 
> polledMessages) {
> System.out.println(endpoint.getEndpointUri());
>   }
>
>   @Override
>   public boolean rollback(Consumer consumer, Endpoint endpoint, int 
> retryCounter, Exception cause) throws Exception {
> System.out.println(endpoint.getEndpointUri() + " Cause exception with 
> message " + cause.getMessage());
> throw cause;
>   }
> });
> RouteBuilder r1 = new RouteBuilder() {
>   @Override
>   public void configure() throws Exception {
> /* Can't use from("sftp://...;) because business logic triggering */
> RouteDefinition from = from(DIRECT_START);
>
> /* Processor reads data from sftp -- invalid port test */
> from.process(new Processor() {
>
>   @Override
>   public void process(Exchange exchange) throws Exception {
> ConsumerTemplate template = 
> 

Re: Camel Mail: Sending both text and html version of e-mail

2016-10-18 Thread Claus Ibsen
Hi

See the alternativeBodyHeader option at http://camel.apache.org/mail.html

On Thu, Oct 13, 2016 at 8:33 PM, dash  wrote:
> Hello.
> I need to send both /text/html/ and /text/plain/ versions in one email. Can
> this be done using Camel SMTP component?
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Camel-Mail-Sending-both-text-and-html-version-of-e-mail-tp5788739.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


Re: [camel-ftp] Can't catch Invalid SFTP port exception

2016-10-18 Thread Claus Ibsen
Try with Camel 2.18.0 release. We may have fixed something about this.
There is a vague memory of mine looking into and fixing something with
consumer template and bridge.



On Sun, Oct 16, 2016 at 9:54 PM, Goyal, Arpit  wrote:
> I am trying to handle all the exception use cases of SFTP for logging 
> purposes. In case user has given invalid Port address for sftp server even 
> when using pollStrategy attribute ->
>
> 1) We are not able to get the exception back in the code.
> 2) Exchange comes back null.
> 3) Associated below code to logger and see the exception logged though. 
> (Partial stack given first; complete exception later)
>
> I am intentionally giving wrong PORT () instead of the correct port (22). 
> What are we missing here?
>
> Other Cases:
>
> -  Valid Port - the poll strategy 'begin' & 'commit' are called.
>
> -  Invalid User or Invalid Password - 'rollback' method is invoked 
> with GenericFileOperationFailedException.
>
> Regards,
> Arpit.
>
> Exception:
> --
> org.apache.camel.component.file.GenericFileOperationFailedException: Cannot 
> connect to sftp://d...@test.rebex.net:
> at 
> org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:146)
> at 
> org.apache.camel.component.file.remote.RemoteFileConsumer.connectIfNecessary(RemoteFileConsumer.java:203)
> at 
> org.apache.camel.component.file.remote.RemoteFileConsumer.recoverableConnectIfNecessary(RemoteFileConsumer.java:171)
> at 
> org.apache.camel.component.file.remote.RemoteFileConsumer.prePollCheck(RemoteFileConsumer.java:59)
> at 
> org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:106)
> at 
> org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174)
> at 
> org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101)
> at 
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
> at 
> java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
> at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
> at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
> at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> at java.lang.Thread.run(Thread.java:812)
> Caused by: com.jcraft.jsch.JSchException: timeout: socket is not established
> at com.jcraft.jsch.Util.createSocket(Util.java:389)
> at com.jcraft.jsch.Session.connect(Session.java:215)
> at 
> org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:118)
> ... 13 more
>
> Sample Program:
> 
>
> public class ConsumerTemplateAndSftpIssues {
>
>   private static final String DIRECT_START = "direct:start";
>
>   public static void main(String[] args) throws Exception {
> BasicConfigurator.configure();
>
> DefaultCamelContext c = new DefaultCamelContext();
>
> SimpleRegistry sr = new SimpleRegistry();
> c.setRegistry(sr);
>
> sr.put("customPoll", new PollingConsumerPollStrategy(){
>
>   @Override
>   public boolean begin(Consumer consumer, Endpoint endpoint) {
> return true;
>   }
>
>   @Override
>   public void commit(Consumer consumer, Endpoint endpoint, int 
> polledMessages) {
> System.out.println(endpoint.getEndpointUri());
>   }
>
>   @Override
>   public boolean rollback(Consumer consumer, Endpoint endpoint, int 
> retryCounter, Exception cause) throws Exception {
> System.out.println(endpoint.getEndpointUri() + " Cause exception with 
> message " + cause.getMessage());
> throw cause;
>   }
> });
> RouteBuilder r1 = new RouteBuilder() {
>   @Override
>   public void configure() throws Exception {
> /* Can't use from("sftp://...;) because business logic triggering */
> RouteDefinition from = from(DIRECT_START);
>
> /* Processor reads data from sftp -- invalid port test */
> from.process(new Processor() {
>
>   @Override
>   public void process(Exchange exchange) throws Exception {
> ConsumerTemplate template = 
> exchange.getContext().createConsumerTemplate();
> template.start();
> try {
>   Exchange ex = template.receive("sftp://test.rebex.net:/?; + 
> "username=demo&" + "password=password&" + "stepwise=false&" + 
> "disconnect=true&"
>   + "reconnectDelay=5000&"
>   + "useList=false&" + 

Re: Clarify why lazy-loaded component mapping files are properties files that aren't labeled as such

2016-10-18 Thread Claus Ibsen
Hi

Welcome to the Camel community.

Those files are for Camel component developers. The file is used for
component discovery so Camel can automatic find components from the
classpath.

As a Camel *end user* you should not use those files. Instead if you
want to configure Camel components / routes / endpoints etc you can do
that in many ways. For example using property placeholders which you
can read about here:
http://camel.apache.org/using-propertyplaceholder.html


On Mon, Oct 17, 2016 at 6:30 PM, KARR, DAVID  wrote:
> I haven't really used Camel yet, I'm just reading the manual to familiarize 
> myself with it, as some projects I'll be working with use it.
>
> I noticed that the way you define the lazy-loaded mappings for components 
> uses properties files that aren't labeled as properties files.  For instance, 
> to define the mapping for a component named "foo", you place a file named 
> just "foo" in "META-INF/services/org/apache/camel/component", instead of 
> "foo.properties".
>
> I can deal with this, but it just seems odd.  Is there any background on why 
> it was done this way?



-- 
Claus Ibsen
-
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


Re: Apace Camel : Custom Redelivery Policy

2016-10-18 Thread Claus Ibsen
You can use onWhen on an onException where the onWhen is a predicate
to determine if that onException should trigger or not.

Some details here
http://camel.apache.org/exception-clause.html

If you have a copy of Camel in Action book this is covered much more
in details in that book, as it has a full chapter on error handling.



On Tue, Oct 18, 2016 at 10:38 AM, Shabin5785  wrote:
> I have a route that calls an external rest service. I have configured my
> error handler as shown below.
>
> errorHandler(deadLetterChannel("jms:dlc").maximumRedeliveries(3));
>
> What i want to do:
>
> 1) If connection to external api fails, i want to retry 3 times and then
> send to deadLetterChannel
> 2) If api call is fine, i want to check the status code, log the response
> and then send the message to deadLetterChannel.
> For that i set throwExceptionOnFailure to false.
>
> In my route i have a bean as the last endpoint. This bean receives the
> response from the external end point and checks for the status.
>
> void process(Exchange exchange){
>   //check http status code
>   //if not success
>   exchange.setProperty(Exchange.ROUTE_STOP,true);
>   //sendToDeadLetterQueue;
>   }
>
>
> My problem is that redelivery happens even when i am able to connect to API.
> I expect the redelivery to happen on error. I am handling the response from
> API and also stopping the exchange. So i expect my Bean to log the response
> from API, send to deadLetterQueue(I have a route for that) and stop. But
> redelivery happens 3 times evand so en when API call is successful and so
> deadletterchannel route is invoked 3 times
>
> Can i stop the redelivery from my bean?
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Apace-Camel-Custom-Redelivery-Policy-tp5788891.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


Re: Migrating issue from 2.10 to 2.17

2016-10-18 Thread Claus Ibsen
Hi

That is a big migration as there is many changes between 2.10 and
2.17. You can check all the release notes for all those releases and
see if anything stand out.

Also you dont show very much details what you are doing and what
happens / goes wrong etc.



On Tue, Oct 18, 2016 at 2:07 PM, Alexander Vladimirov
 wrote:
> Hello camel users,
>
> I an trying to migrate camel to 2.17.
> I am using multiple camel contexts and some of them are used as
> integration. Which means referring context 1 and routing the message to
> context to.
>
> When I am trying to initialize them I receive
> ResolveEndpointFailedException. I am trying to use the .to (:url)
> ideot.  Was there something changed between the versions?
>
> Before that this way worked.
>
> Cheers,
> Alex



-- 
Claus Ibsen
-
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


Re: send same message to multiple, not all, websocket clients

2016-10-18 Thread Claus Ibsen
Hi

So ootb camel-websocket is either point to point or pub/sub. So if you
need to send a point to point to more than one, but not all, then I
think you need to make your own house keeping of those connection keys
you want to send to, and then send to them one by one.



On Tue, Oct 18, 2016 at 4:51 PM, Mark  wrote:
> I am receiving messages of data that I am processing with Camel, similar to
> a chat system.  Clients may "subscribe" to the data feed which will require
> me to send the messages to the clients that subscribe to that message type
> over websockets.  How can I implement this websocket communication using
> Camel since the current implementation only allows for one connection key
> per message?  Would I somehow duplicate the message and set a different
> connection key for each message?



-- 
Claus Ibsen
-
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


Re: Is netty4 disconnect/reconnect notification possible?

2016-10-18 Thread Claus Ibsen
I think you would need to implement some custom codec or something to
deal with this kind of requirements.

The out of the box behavior is to use netty for messaging like where
each Camel message maps to one netty message being sent over the wire.



On Tue, Oct 18, 2016 at 7:29 PM, Steve973  wrote:
> Hello.  Our Camel route is sending messages to a netty4 tcp endpoint, but
> we need to make sure to send a particular type of message as the first
> message.  If a disconnection happens during processing, we have to send
> this special message upon reconnection.  Is this possible to achieve?  Will
> we need to write a custom handler for netty to do this?  Any suggestions
> are quite welcome!
>
> Thanks,
> Steve



-- 
Claus Ibsen
-
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


Re: serviceCall with exchangeProperty in URI

2016-10-18 Thread Claus Ibsen
Its better to provide dynamic query parameters as a
Exchange.HTTP_QUERY header then you reuse same endpoint.

So you can set a HTTP_QUERY header with the value clientId= where
xxx is the client id you want, which you can get from an exchange
property.

.setHeader(Exchange.HTTP_QUERY, simple("${exchangeProperty.clientId}"))

You can find more about that header here: http://camel.apache.org/http

On Tue, Oct 18, 2016 at 8:25 PM, ValeryN  wrote:
> Hello,
>
> Could you please give an example how to use a new serviceCall with dynamic
> URI parameter?
> Ideally from ${exchangeProperty.MY_PROPERTY}
>
> Wanna do something like that -
> serviceCall("http://my-service/api/v1/service?clientId=${exchangeProperty.clientId};)
> Using serviceCall because it supports Consul service discovery
>
> Thank you!
>
> Val
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/serviceCall-with-exchangeProperty-in-URI-tp5788921.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


Re: serviceCall: must be configured before it can be used

2016-10-18 Thread Claus Ibsen
Also mind its maybe easier and more understandable to configure
service call outside the route on a global level.

However the unit test embeds the configuring inside the route.



On Tue, Oct 18, 2016 at 10:39 PM, Claus Ibsen  wrote:
> You need to configure service call which registry to use, such as consul.
>
> There is a little unit test here
> https://github.com/apache/camel/blob/master/components/camel-consul/src/test/java/org/apache/camel/component/consul/processor/remote/ConsulServiceCallRouteTest.java
>
> On Tue, Oct 18, 2016 at 9:09 PM, ValeryN  wrote:
>> Hello,
>>
>> I'm trying to use serviceCall (introduced in 2.18 version) from Spring Boot
>> app, consul as a service discovery tool.
>>
>> Here is an example:
>> from("direct:test")
>> .serviceCall("config-api")
>> .log("${body}");
>>
>>
>> Both app and target service are discoverable through consul, RestTemplate
>> sends REST calls just fine, but when I configure a test apache camel route
>> it gives me :
>>
>> Caused by: java.lang.IllegalStateException: The ServiceCall:
>> ServiceCall[config-api] must be configured before it can be used.
>> at
>> org.apache.camel.impl.remote.DefaultServiceCallProcessorFactory.createProcessor(DefaultServiceCallProcessorFactory.java:84)
>> ~[camel-core-2.18.0.jar:2.18.0]
>> at
>> org.apache.camel.impl.remote.DefaultServiceCallProcessorFactory.createProcessor(DefaultServiceCallProcessorFactory.java:51)
>> ~[camel-core-2.18.0.jar:2.18.0]
>> at
>> org.apache.camel.impl.DefaultProcessorFactory.createProcessor(DefaultProcessorFactory.java:69)
>> ~[camel-core-2.18.0.jar:2.18.0]
>> at
>> org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:535)
>> ~[camel-core-2.18.0.jar:2.18.0]
>> at
>> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:500)
>> ~[camel-core-2.18.0.jar:2.18.0]
>> at
>> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:221)
>> ~[camel-core-2.18.0.jar:2.18.0]
>> at
>> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1068)
>> ~[camel-core-2.18.0.jar:2.18.0]
>>
>> Couldn't find anything regarding any extra configuration on the EIP page:
>> http://camel.apache.org/servicecall-eip.html
>>
>> My camel dependencies are:
>>
>> compile group: 'org.apache.camel', name: 'camel-stream', version:
>> "${apacheCamelVersion}"
>> compile group: 'org.apache.camel', name: 'camel-http', version:
>> "${apacheCamelVersion}"
>> compile group: 'org.apache.camel', name: 'camel-consul', version:
>> "${apacheCamelVersion}"
>>
>> compile group: 'org.apache.camel', name: 'camel-xmljson', version:
>> "${apacheCamelVersion}"
>> compile group: 'xom', name: 'xom', version: '1.2.5'
>>
>>
>>
>>
>>
>> --
>> View this message in context: 
>> http://camel.465427.n5.nabble.com/serviceCall-must-be-configured-before-it-can-be-used-tp5788922.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2



-- 
Claus Ibsen
-
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


Re: serviceCall: must be configured before it can be used

2016-10-18 Thread Claus Ibsen
You need to configure service call which registry to use, such as consul.

There is a little unit test here
https://github.com/apache/camel/blob/master/components/camel-consul/src/test/java/org/apache/camel/component/consul/processor/remote/ConsulServiceCallRouteTest.java

On Tue, Oct 18, 2016 at 9:09 PM, ValeryN  wrote:
> Hello,
>
> I'm trying to use serviceCall (introduced in 2.18 version) from Spring Boot
> app, consul as a service discovery tool.
>
> Here is an example:
> from("direct:test")
> .serviceCall("config-api")
> .log("${body}");
>
>
> Both app and target service are discoverable through consul, RestTemplate
> sends REST calls just fine, but when I configure a test apache camel route
> it gives me :
>
> Caused by: java.lang.IllegalStateException: The ServiceCall:
> ServiceCall[config-api] must be configured before it can be used.
> at
> org.apache.camel.impl.remote.DefaultServiceCallProcessorFactory.createProcessor(DefaultServiceCallProcessorFactory.java:84)
> ~[camel-core-2.18.0.jar:2.18.0]
> at
> org.apache.camel.impl.remote.DefaultServiceCallProcessorFactory.createProcessor(DefaultServiceCallProcessorFactory.java:51)
> ~[camel-core-2.18.0.jar:2.18.0]
> at
> org.apache.camel.impl.DefaultProcessorFactory.createProcessor(DefaultProcessorFactory.java:69)
> ~[camel-core-2.18.0.jar:2.18.0]
> at
> org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:535)
> ~[camel-core-2.18.0.jar:2.18.0]
> at
> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:500)
> ~[camel-core-2.18.0.jar:2.18.0]
> at
> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:221)
> ~[camel-core-2.18.0.jar:2.18.0]
> at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1068)
> ~[camel-core-2.18.0.jar:2.18.0]
>
> Couldn't find anything regarding any extra configuration on the EIP page:
> http://camel.apache.org/servicecall-eip.html
>
> My camel dependencies are:
>
> compile group: 'org.apache.camel', name: 'camel-stream', version:
> "${apacheCamelVersion}"
> compile group: 'org.apache.camel', name: 'camel-http', version:
> "${apacheCamelVersion}"
> compile group: 'org.apache.camel', name: 'camel-consul', version:
> "${apacheCamelVersion}"
>
> compile group: 'org.apache.camel', name: 'camel-xmljson', version:
> "${apacheCamelVersion}"
> compile group: 'xom', name: 'xom', version: '1.2.5'
>
>
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/serviceCall-must-be-configured-before-it-can-be-used-tp5788922.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


Re: Deprecating TestNG?

2016-10-18 Thread Claus Ibsen
Hi

Its deprecated from Camel 2.18 onwards, but will stay there in 2.x.

>From Camel 3.x onwards we will removed deprecated stuff from 2.x.



On Tue, Oct 18, 2016 at 9:36 PM, Goyal, Arpit  wrote:
> Hi Claus,
>
> Heard your JDKIO Video 2016 (online) mentioning that TestNG support would be 
> deprecated. Is there a timeline when you would deprecate and is there a 
> possibility of removal (I presume 3.x?)
>
> Just wanted to know because we are currently using TestNG and want to have 
> brief idea as to how much time we have to move or should we switch now itself.
>
> Regards,
> Arpit.
>
> PS: Of course not so happy getting to know testng support is being removed.



-- 
Claus Ibsen
-
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


Deprecating TestNG?

2016-10-18 Thread Goyal, Arpit
Hi Claus,

Heard your JDKIO Video 2016 (online) mentioning that TestNG support would be 
deprecated. Is there a timeline when you would deprecate and is there a 
possibility of removal (I presume 3.x?)

Just wanted to know because we are currently using TestNG and want to have 
brief idea as to how much time we have to move or should we switch now itself.

Regards,
Arpit.

PS: Of course not so happy getting to know testng support is being removed.


Re: Camel - Making parallel GET requests and aggregating the results via Dynamic Routes using Java DSL

2016-10-18 Thread Debraj Manna
Thanks Avnish.

On Tue, Oct 18, 2016 at 8:38 PM, Avnish Pundir 
wrote:

> You can use JsonPathExpression in your split body and allow parallel
> execution using executorServiceRef, following is a sample skeleton -
>
> from("jetty:http://localhost:/hello;).split(new
> JsonPathExpression("$.data[*]")).executorServiceRef(MY_EXECU
> TOR_REF).to(...)
>
> This will run your individual json tokens in parallel which you can use to
> send out independent GET requests to desired endpoints. You'll have to use
> aggregationStrategy though at end to accumulate the results (if you wish to
> combine some data) using strategyRef option. There are number of examples
> at http://camel.apache.org/splitter.html - towards the end of this
> documentation you'll see custome aggregationStrategy example as well.
>
> Just to clarify, JsonPathExpression comes from
> org.apache.camel.model.language.JsonPathExpression class (You'll have to
> import it in your route builder).
>
> Thanks,
> Avnish Pundir
>
>
> On 18-10-2016 16:23, Debraj Manna wrote:
>
>> I am receiving a request on a Jetty Http Endpoint. The request body
>> contains some urls in the request body. I have to make a GET request to
>> those urls. Then aggregate the results from each of the GET request and
>> return it to the caller.
>>
>> Request Body:-
>>
>> {
>> "data" : [
>> {"name" : "Hello", "url" : "http://server1"}
>> {"name" : "Hello2", "url" : "http://server2"}
>>
>> ]
>> }
>>
>> One way I can think of doing this is like below:-
>>
>> from("jetty:http://localhost:/hello;).process(new Processor() {
>> public void process(Exchange exchange) throws Exception {
>> // 1. Make the GET request in parallel using ThreadPoolExecutor
>> // 2. Wait for all calls to finish. Collate the response
>> // 3. Write it to exchange.getOut().setBody
>> }
>> })
>>
>> Can some one let me know if this can be achieved via Java DSL using camel
>> dynamic Routes, splitter & aggregator so that my Processor remains
>> relatively small?
>>
>> I am using camel 2.16.3.
>>
>
> --
>
> --
> Disclaimer: The information contained in this communication is
> confidential, private, proprietary, or otherwise privileged and is intended
> only for the use of the addressee.Unauthorized use, disclosure,
> distribution or copying is strictly prohibited and may be unlawful. If you
> have received this communication in error, please delete this message and
> notify the sender immediately - Samin TekMindz India Pvt.Ltd.
> --
>


serviceCall: must be configured before it can be used

2016-10-18 Thread ValeryN
Hello,

I'm trying to use serviceCall (introduced in 2.18 version) from Spring Boot
app, consul as a service discovery tool.

Here is an example:
from("direct:test")
.serviceCall("config-api")
.log("${body}");


Both app and target service are discoverable through consul, RestTemplate
sends REST calls just fine, but when I configure a test apache camel route
it gives me :

Caused by: java.lang.IllegalStateException: The ServiceCall:
ServiceCall[config-api] must be configured before it can be used.
at
org.apache.camel.impl.remote.DefaultServiceCallProcessorFactory.createProcessor(DefaultServiceCallProcessorFactory.java:84)
~[camel-core-2.18.0.jar:2.18.0]
at
org.apache.camel.impl.remote.DefaultServiceCallProcessorFactory.createProcessor(DefaultServiceCallProcessorFactory.java:51)
~[camel-core-2.18.0.jar:2.18.0]
at
org.apache.camel.impl.DefaultProcessorFactory.createProcessor(DefaultProcessorFactory.java:69)
~[camel-core-2.18.0.jar:2.18.0]
at
org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:535)
~[camel-core-2.18.0.jar:2.18.0]
at
org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:500)
~[camel-core-2.18.0.jar:2.18.0]
at
org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:221)
~[camel-core-2.18.0.jar:2.18.0]
at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1068)
~[camel-core-2.18.0.jar:2.18.0]

Couldn't find anything regarding any extra configuration on the EIP page:
http://camel.apache.org/servicecall-eip.html

My camel dependencies are:

compile group: 'org.apache.camel', name: 'camel-stream', version:
"${apacheCamelVersion}"
compile group: 'org.apache.camel', name: 'camel-http', version:
"${apacheCamelVersion}"
compile group: 'org.apache.camel', name: 'camel-consul', version:
"${apacheCamelVersion}"

compile group: 'org.apache.camel', name: 'camel-xmljson', version:
"${apacheCamelVersion}"
compile group: 'xom', name: 'xom', version: '1.2.5'





--
View this message in context: 
http://camel.465427.n5.nabble.com/serviceCall-must-be-configured-before-it-can-be-used-tp5788922.html
Sent from the Camel - Users mailing list archive at Nabble.com.


serviceCall with exchangeProperty in URI

2016-10-18 Thread ValeryN
Hello,

Could you please give an example how to use a new serviceCall with dynamic
URI parameter?
Ideally from ${exchangeProperty.MY_PROPERTY}

Wanna do something like that -
serviceCall("http://my-service/api/v1/service?clientId=${exchangeProperty.clientId};)
Using serviceCall because it supports Consul service discovery

Thank you!

Val



--
View this message in context: 
http://camel.465427.n5.nabble.com/serviceCall-with-exchangeProperty-in-URI-tp5788921.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Is netty4 disconnect/reconnect notification possible?

2016-10-18 Thread Steve973
Hello.  Our Camel route is sending messages to a netty4 tcp endpoint, but
we need to make sure to send a particular type of message as the first
message.  If a disconnection happens during processing, we have to send
this special message upon reconnection.  Is this possible to achieve?  Will
we need to write a custom handler for netty to do this?  Any suggestions
are quite welcome!

Thanks,
Steve


Re: Send message to temporary queue

2016-10-18 Thread Quinn Stevenson
I don’t see where you’re using Camel in this snippet - am I missing something?

What type of error are you seeing?

> On Oct 14, 2016, at 5:16 AM, axdz  wrote:
> 
> Hi all,
> 
> Follow this link 
> http://activemq.apache.org/how-should-i-implement-request-response-with-jms.html
> 
>   
> 
> I did it but, it can not send message to temporary queue (which is got from
> replyTo field).
> 
> //Set the correlation ID from the received message to be the correlation id
> of the response message
>//this lets the client identify which message this is a response
> to if it has more than
>//one outstanding message to the server
>response.setJMSCorrelationID(message.getJMSCorrelationID());
> 
>//Send the response to the Destination specified by the
> JMSReplyTo field of the received message,
>//this is presumably a temporary queue created by the client
>this.replyProducer.send(message.getJMSReplyTo(), response);
> 
> Can you explain to me about temporary queue and what should i do in this
> problem.
> Thanks,
> 
> 
> 
> 
> 
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Send-message-to-temporary-queue-tp5788779.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



Re: Apace Camel : Custom Redelivery Policy

2016-10-18 Thread Quinn Stevenson
Is there a specific exception you can catch when the connection fails?  If so, 
you could use onException to handle that case.

onException(ConnectException.class).maximumRedeliveries(3).handled(true).to(jms:dlc)

Something like the above should handle #1.


> On Oct 18, 2016, at 2:38 AM, Shabin5785  wrote:
> 
> I have a route that calls an external rest service. I have configured my
> error handler as shown below.
> 
> errorHandler(deadLetterChannel("jms:dlc").maximumRedeliveries(3));
> 
> What i want to do:
> 
> 1) If connection to external api fails, i want to retry 3 times and then
> send to deadLetterChannel
> 2) If api call is fine, i want to check the status code, log the response
> and then send the message to deadLetterChannel.
> For that i set throwExceptionOnFailure to false.
> 
> In my route i have a bean as the last endpoint. This bean receives the
> response from the external end point and checks for the status.
> 
> void process(Exchange exchange){
>  //check http status code
>  //if not success
>  exchange.setProperty(Exchange.ROUTE_STOP,true);
>  //sendToDeadLetterQueue;
>  }
> 
> 
> My problem is that redelivery happens even when i am able to connect to API.
> I expect the redelivery to happen on error. I am handling the response from
> API and also stopping the exchange. So i expect my Bean to log the response
> from API, send to deadLetterQueue(I have a route for that) and stop. But
> redelivery happens 3 times evand so en when API call is successful and so
> deadletterchannel route is invoked 3 times
> 
> Can i stop the redelivery from my bean?
> 
> 
> 
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Apace-Camel-Custom-Redelivery-Policy-tp5788891.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



RE: [camel-ftp] Can't catch Invalid SFTP port exception

2016-10-18 Thread Goyal, Arpit
Yes - it is part of the URL in the below code and it didn't work - I am more 
and more inclined there is some bug here; but not an expert. 

"consumer.bridgeErrorHandler=true&"

Regards,
Arpit.

-Original Message-
From: Quinn Stevenson [mailto:qu...@pronoia-solutions.com] 
Sent: Tuesday, October 18, 2016 8:10 AM
To: users@camel.apache.org
Subject: Re: [camel-ftp] Can't catch Invalid SFTP port exception

Have you tried enabling the bridge error handler feature 
(consumer.bridgeErrorHandler)? http://camel.apache.org/file2.html 


> On Oct 18, 2016, at 7:33 AM, Goyal, Arpit  wrote:
> 
> Anyone having idea about what's wrong here?
> 
> Sent from my iPhone
> 
>> On Oct 16, 2016, at 12:55 PM, Goyal, Arpit  wrote:
>> 
>> I am trying to handle all the exception use cases of SFTP for logging 
>> purposes. In case user has given invalid Port address for sftp server even 
>> when using pollStrategy attribute ->
>> 
>> 1) We are not able to get the exception back in the code.
>> 2) Exchange comes back null.
>> 3) Associated below code to logger and see the exception logged though. 
>> (Partial stack given first; complete exception later)
>> 
>> I am intentionally giving wrong PORT () instead of the correct port 
>> (22). What are we missing here?
>> 
>> Other Cases:
>> 
>> -  Valid Port - the poll strategy 'begin' & 'commit' are called.
>> 
>> -  Invalid User or Invalid Password - 'rollback' method is invoked 
>> with GenericFileOperationFailedException.
>> 
>> Regards,
>> Arpit.
>> 
>> Exception:
>> --
>> org.apache.camel.component.file.GenericFileOperationFailedException: Cannot 
>> connect to sftp://d...@test.rebex.net:
>>   at 
>> org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:146)
>>   at 
>> org.apache.camel.component.file.remote.RemoteFileConsumer.connectIfNecessary(RemoteFileConsumer.java:203)
>>   at 
>> org.apache.camel.component.file.remote.RemoteFileConsumer.recoverableConnectIfNecessary(RemoteFileConsumer.java:171)
>>   at 
>> org.apache.camel.component.file.remote.RemoteFileConsumer.prePollCheck(RemoteFileConsumer.java:59)
>>   at 
>> org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:106)
>>   at 
>> org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174)
>>   at 
>> org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101)
>>   at 
>> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
>>   at 
>> java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
>>   at 
>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
>>   at 
>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
>>   at 
>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>>   at 
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>>   at java.lang.Thread.run(Thread.java:812)
>> Caused by: com.jcraft.jsch.JSchException: timeout: socket is not established
>>   at com.jcraft.jsch.Util.createSocket(Util.java:389)
>>   at com.jcraft.jsch.Session.connect(Session.java:215)
>>   at 
>> org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:118)
>>   ... 13 more
>> 
>> Sample Program:
>> 
>> 
>> public class ConsumerTemplateAndSftpIssues {
>> 
>> private static final String DIRECT_START = "direct:start";
>> 
>> public static void main(String[] args) throws Exception {
>>   BasicConfigurator.configure();
>> 
>>   DefaultCamelContext c = new DefaultCamelContext();
>> 
>>   SimpleRegistry sr = new SimpleRegistry();
>>   c.setRegistry(sr);
>> 
>>   sr.put("customPoll", new PollingConsumerPollStrategy(){
>> 
>> @Override
>> public boolean begin(Consumer consumer, Endpoint endpoint) {
>>   return true;
>> }
>> 
>> @Override
>> public void commit(Consumer consumer, Endpoint endpoint, int 
>> polledMessages) {
>>   System.out.println(endpoint.getEndpointUri());
>> }
>> 
>> @Override
>> public boolean rollback(Consumer consumer, Endpoint endpoint, int 
>> retryCounter, Exception cause) throws Exception {
>>   System.out.println(endpoint.getEndpointUri() + " Cause exception with 
>> message " + cause.getMessage());
>>   throw cause;
>> }
>>   });
>>   RouteBuilder r1 = new RouteBuilder() {
>> @Override
>> public void configure() throws Exception {
>>   /* Can't use from("sftp://...;) because business logic triggering */
>>   RouteDefinition from = from(DIRECT_START);
>> 
>>   /* 

Re: apache camel returns statusCode:500

2016-10-18 Thread Avnish Pundir
Looks like your web-service is expecting special headers (either content 
type or something alike), you can try setting the content type and also 
set the request type to POST explicitly (in one of the peculiar use case 
I had to use it explicitly) using following code:


.setHeader(Exchange.HTTP_METHOD, constant("POST"))
.setHeader(Exchange.CONTENT_TYPE, constant("application/json"))

I'll still recommend that you either look into your server logs to find 
out exact root cause or enable the TRACE logging for apache http package 
(assuming you are using http or http4 component) to see what's going on 
the wire, compare it what postman is sending and adapt your route 
accordingly.


Thanks,
Avnish Pundir



On 18-10-2016 07:06, meng wrote:

Hi All,
I'm the new of camel. I now use apache camel to call several our
webservices.

Here is my code:
public void configure() throws Exception{
from("direct:start")
.marshal()
.string(UTF_8)
.to(TARGET http)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws
Exception {
String message =
exchange.getIn().getBody(String.class);
System.out.println(message);
}
})
   .to("stream:out");

I'm sure there is no problem about the target endpoint, for I can get
correct response using postman.
But camel give me 500 error.
Caused by: org.apache.camel.http.common.HttpOperationFailedException: HTTP
operation failed invoking http:// with statusCode: 500
at
org.apache.camel.component.http.HttpProducer.populateHttpOperationFailedException(HttpProducer.java:240)
~[camel-http-2.16.1.jar:2.16.1]
at
org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:162)
~[camel-http-2.16.1.jar:2.16.1]
at
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
~[camel-core-2.16.1.jar:2.16.1]
at 
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:141)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:460)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
~[camel-core-2.16.1.jar:2.16.1]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
~[camel-core-2.16.1.jar:2.16.1]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:68)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:412)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:380)
~[camel-core-2.16.1.jar:2.16.1]
at 
org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:270)
~[camel-core-2.16.1.jar:2.16.1]
at 
org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:380)
~[camel-core-2.16.1.jar:2.16.1]
at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:238)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:128)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:132)
~[camel-core-2.16.1.jar:2.16.1]
... 16 common frames omitted

Could you help what's my problem or how can I debug it?
Thanks a lot!



--
View this message in context: 
http://camel.465427.n5.nabble.com/apache-camel-returns-statusCode-500-tp578.html
Sent from the Camel - Users mailing list archive at Nabble.com.



--

--
Disclaimer: The information contained in this communication is 
confidential, private, proprietary, or otherwise privileged and is intended 
only for the use of the addressee.Unauthorized use, disclosure, 
distribution or copying is strictly prohibited and may be unlawful. If you 
have received this communication in 

Re: [camel-ftp] Can't catch Invalid SFTP port exception

2016-10-18 Thread Quinn Stevenson
Have you tried enabling the bridge error handler feature 
(consumer.bridgeErrorHandler)? http://camel.apache.org/file2.html 


> On Oct 18, 2016, at 7:33 AM, Goyal, Arpit  wrote:
> 
> Anyone having idea about what's wrong here?
> 
> Sent from my iPhone
> 
>> On Oct 16, 2016, at 12:55 PM, Goyal, Arpit  wrote:
>> 
>> I am trying to handle all the exception use cases of SFTP for logging 
>> purposes. In case user has given invalid Port address for sftp server even 
>> when using pollStrategy attribute ->
>> 
>> 1) We are not able to get the exception back in the code.
>> 2) Exchange comes back null.
>> 3) Associated below code to logger and see the exception logged though. 
>> (Partial stack given first; complete exception later)
>> 
>> I am intentionally giving wrong PORT () instead of the correct port 
>> (22). What are we missing here?
>> 
>> Other Cases:
>> 
>> -  Valid Port - the poll strategy 'begin' & 'commit' are called.
>> 
>> -  Invalid User or Invalid Password - 'rollback' method is invoked 
>> with GenericFileOperationFailedException.
>> 
>> Regards,
>> Arpit.
>> 
>> Exception:
>> --
>> org.apache.camel.component.file.GenericFileOperationFailedException: Cannot 
>> connect to sftp://d...@test.rebex.net:
>>   at 
>> org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:146)
>>   at 
>> org.apache.camel.component.file.remote.RemoteFileConsumer.connectIfNecessary(RemoteFileConsumer.java:203)
>>   at 
>> org.apache.camel.component.file.remote.RemoteFileConsumer.recoverableConnectIfNecessary(RemoteFileConsumer.java:171)
>>   at 
>> org.apache.camel.component.file.remote.RemoteFileConsumer.prePollCheck(RemoteFileConsumer.java:59)
>>   at 
>> org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:106)
>>   at 
>> org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174)
>>   at 
>> org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101)
>>   at 
>> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
>>   at 
>> java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
>>   at 
>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
>>   at 
>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
>>   at 
>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>>   at 
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>>   at java.lang.Thread.run(Thread.java:812)
>> Caused by: com.jcraft.jsch.JSchException: timeout: socket is not established
>>   at com.jcraft.jsch.Util.createSocket(Util.java:389)
>>   at com.jcraft.jsch.Session.connect(Session.java:215)
>>   at 
>> org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:118)
>>   ... 13 more
>> 
>> Sample Program:
>> 
>> 
>> public class ConsumerTemplateAndSftpIssues {
>> 
>> private static final String DIRECT_START = "direct:start";
>> 
>> public static void main(String[] args) throws Exception {
>>   BasicConfigurator.configure();
>> 
>>   DefaultCamelContext c = new DefaultCamelContext();
>> 
>>   SimpleRegistry sr = new SimpleRegistry();
>>   c.setRegistry(sr);
>> 
>>   sr.put("customPoll", new PollingConsumerPollStrategy(){
>> 
>> @Override
>> public boolean begin(Consumer consumer, Endpoint endpoint) {
>>   return true;
>> }
>> 
>> @Override
>> public void commit(Consumer consumer, Endpoint endpoint, int 
>> polledMessages) {
>>   System.out.println(endpoint.getEndpointUri());
>> }
>> 
>> @Override
>> public boolean rollback(Consumer consumer, Endpoint endpoint, int 
>> retryCounter, Exception cause) throws Exception {
>>   System.out.println(endpoint.getEndpointUri() + " Cause exception with 
>> message " + cause.getMessage());
>>   throw cause;
>> }
>>   });
>>   RouteBuilder r1 = new RouteBuilder() {
>> @Override
>> public void configure() throws Exception {
>>   /* Can't use from("sftp://...;) because business logic triggering */
>>   RouteDefinition from = from(DIRECT_START);
>> 
>>   /* Processor reads data from sftp -- invalid port test */
>>   from.process(new Processor() {
>> 
>> @Override
>> public void process(Exchange exchange) throws Exception {
>>   ConsumerTemplate template = 
>> exchange.getContext().createConsumerTemplate();
>>   template.start();
>>   try {
>> Exchange ex = template.receive("sftp://test.rebex.net:/?; + 
>> 

Re: Camel - Making parallel GET requests and aggregating the results via Dynamic Routes using Java DSL

2016-10-18 Thread Avnish Pundir
You can use JsonPathExpression in your split body and allow parallel 
execution using executorServiceRef, following is a sample skeleton -


from("jetty:http://localhost:/hello;).split(new 
JsonPathExpression("$.data[*]")).executorServiceRef(MY_EXECUTOR_REF).to(...)


This will run your individual json tokens in parallel which you can use 
to send out independent GET requests to desired endpoints. You'll have 
to use aggregationStrategy though at end to accumulate the results (if 
you wish to combine some data) using strategyRef option. There are 
number of examples at http://camel.apache.org/splitter.html - towards 
the end of this documentation you'll see custome aggregationStrategy 
example as well.


Just to clarify, JsonPathExpression comes from 
org.apache.camel.model.language.JsonPathExpression class (You'll have to 
import it in your route builder).


Thanks,
Avnish Pundir

On 18-10-2016 16:23, Debraj Manna wrote:

I am receiving a request on a Jetty Http Endpoint. The request body
contains some urls in the request body. I have to make a GET request to
those urls. Then aggregate the results from each of the GET request and
return it to the caller.

Request Body:-

{
"data" : [
{"name" : "Hello", "url" : "http://server1"}
{"name" : "Hello2", "url" : "http://server2"}

]
}

One way I can think of doing this is like below:-

from("jetty:http://localhost:/hello;).process(new Processor() {
public void process(Exchange exchange) throws Exception {
// 1. Make the GET request in parallel using ThreadPoolExecutor
// 2. Wait for all calls to finish. Collate the response
// 3. Write it to exchange.getOut().setBody
}
})

Can some one let me know if this can be achieved via Java DSL using camel
dynamic Routes, splitter & aggregator so that my Processor remains
relatively small?

I am using camel 2.16.3.


--

--
Disclaimer: The information contained in this communication is 
confidential, private, proprietary, or otherwise privileged and is intended 
only for the use of the addressee.Unauthorized use, disclosure, 
distribution or copying is strictly prohibited and may be unlawful. If you 
have received this communication in error, please delete this message and 
notify the sender immediately - Samin TekMindz India Pvt.Ltd. 
--


CamelBlueprintTestSupport errors out when the blueprint has a custom threadpool

2016-10-18 Thread rw83
Sample of my blueprint is attached here.

http://camel.apache.org/schema/blueprint;>






Scheduler





 

 I am trying to load this blueprint file from my test case which extends
CamelBluePrintTest. 
@Override
protected String getBlueprintDescriptor() {
return "my-blueprint.xml";

}

The problem is when my blueprint has a custom threadpool defined as above,
the container is unable to start this bundle. I don't see any descriptive
error other than below message. 
16/10/18 09:56:46 ERROR container.BlueprintContainerImpl: Unable to start
blueprint container for bundle MyBundle/1.0.0

But If I commented out the threadPool definition, then it works as a charm.
Any Idea why this happens and how to fix this. I am using Camel 2.16.2 







--
View this message in context: 
http://camel.465427.n5.nabble.com/CamelBlueprintTestSupport-errors-out-when-the-blueprint-has-a-custom-threadpool-tp5788903.html
Sent from the Camel - Users mailing list archive at Nabble.com.


send same message to multiple, not all, websocket clients

2016-10-18 Thread Mark
I am receiving messages of data that I am processing with Camel, similar to
a chat system.  Clients may "subscribe" to the data feed which will require
me to send the messages to the clients that subscribe to that message type
over websockets.  How can I implement this websocket communication using
Camel since the current implementation only allows for one connection key
per message?  Would I somehow duplicate the message and set a different
connection key for each message?


Re: Choice Based On Pojo in Exchange

2016-10-18 Thread Claus Ibsen
You can use simple, mvel, ognl, groovy as the language to build that predicate
http://camel.apache.org/languages

For example with simple

when(simple("${body.isErrors().size()} < 1"))



On Tue, Oct 18, 2016 at 3:53 PM, spurcell  wrote:
> Hello Team,
>
> I have a Pojo in my exchange, and the pojo has a List that may be
> empty or may have 0..* errors. I would like to create a .choice() based upon
> the size of the errors list. Is this possible? I see that I can use header
> and body in the choice, but not sure if the pojo will work. Can someone
> chime in on this?
>
> Thanks
>
> Something like this:
>  .choice()
> .when(body().isErrors().size() < 1))
> .to("bean:xxx"")
> .otherwise()
> .to("bean:xxx");
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Choice-Based-On-Pojo-in-Exchange-tp5788899.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


Choice Based On Pojo in Exchange

2016-10-18 Thread spurcell
Hello Team,

I have a Pojo in my exchange, and the pojo has a List that may be
empty or may have 0..* errors. I would like to create a .choice() based upon
the size of the errors list. Is this possible? I see that I can use header
and body in the choice, but not sure if the pojo will work. Can someone
chime in on this?

Thanks

Something like this:
 .choice()
.when(body().isErrors().size() < 1))
.to("bean:xxx"")
.otherwise()
.to("bean:xxx");



--
View this message in context: 
http://camel.465427.n5.nabble.com/Choice-Based-On-Pojo-in-Exchange-tp5788899.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: [camel-ftp] Can't catch Invalid SFTP port exception

2016-10-18 Thread Goyal, Arpit
Anyone having idea about what's wrong here?

Sent from my iPhone

> On Oct 16, 2016, at 12:55 PM, Goyal, Arpit  wrote:
> 
> I am trying to handle all the exception use cases of SFTP for logging 
> purposes. In case user has given invalid Port address for sftp server even 
> when using pollStrategy attribute ->
> 
> 1) We are not able to get the exception back in the code.
> 2) Exchange comes back null.
> 3) Associated below code to logger and see the exception logged though. 
> (Partial stack given first; complete exception later)
> 
> I am intentionally giving wrong PORT () instead of the correct port (22). 
> What are we missing here?
> 
> Other Cases:
> 
> -  Valid Port - the poll strategy 'begin' & 'commit' are called.
> 
> -  Invalid User or Invalid Password - 'rollback' method is invoked 
> with GenericFileOperationFailedException.
> 
> Regards,
> Arpit.
> 
> Exception:
> --
> org.apache.camel.component.file.GenericFileOperationFailedException: Cannot 
> connect to sftp://d...@test.rebex.net:
>at 
> org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:146)
>at 
> org.apache.camel.component.file.remote.RemoteFileConsumer.connectIfNecessary(RemoteFileConsumer.java:203)
>at 
> org.apache.camel.component.file.remote.RemoteFileConsumer.recoverableConnectIfNecessary(RemoteFileConsumer.java:171)
>at 
> org.apache.camel.component.file.remote.RemoteFileConsumer.prePollCheck(RemoteFileConsumer.java:59)
>at 
> org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:106)
>at 
> org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174)
>at 
> org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101)
>at 
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
>at 
> java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
>at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
>at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
>at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>at java.lang.Thread.run(Thread.java:812)
> Caused by: com.jcraft.jsch.JSchException: timeout: socket is not established
>at com.jcraft.jsch.Util.createSocket(Util.java:389)
>at com.jcraft.jsch.Session.connect(Session.java:215)
>at 
> org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:118)
>... 13 more
> 
> Sample Program:
> 
> 
> public class ConsumerTemplateAndSftpIssues {
> 
>  private static final String DIRECT_START = "direct:start";
> 
>  public static void main(String[] args) throws Exception {
>BasicConfigurator.configure();
> 
>DefaultCamelContext c = new DefaultCamelContext();
> 
>SimpleRegistry sr = new SimpleRegistry();
>c.setRegistry(sr);
> 
>sr.put("customPoll", new PollingConsumerPollStrategy(){
> 
>  @Override
>  public boolean begin(Consumer consumer, Endpoint endpoint) {
>return true;
>  }
> 
>  @Override
>  public void commit(Consumer consumer, Endpoint endpoint, int 
> polledMessages) {
>System.out.println(endpoint.getEndpointUri());
>  }
> 
>  @Override
>  public boolean rollback(Consumer consumer, Endpoint endpoint, int 
> retryCounter, Exception cause) throws Exception {
>System.out.println(endpoint.getEndpointUri() + " Cause exception with 
> message " + cause.getMessage());
>throw cause;
>  }
>});
>RouteBuilder r1 = new RouteBuilder() {
>  @Override
>  public void configure() throws Exception {
>/* Can't use from("sftp://...;) because business logic triggering */
>RouteDefinition from = from(DIRECT_START);
> 
>/* Processor reads data from sftp -- invalid port test */
>from.process(new Processor() {
> 
>  @Override
>  public void process(Exchange exchange) throws Exception {
>ConsumerTemplate template = 
> exchange.getContext().createConsumerTemplate();
>template.start();
>try {
>  Exchange ex = template.receive("sftp://test.rebex.net:/?; + 
> "username=demo&" + "password=password&" + "stepwise=false&" + 
> "disconnect=true&"
>  + "reconnectDelay=5000&"
>  + "useList=false&" + 
> "ignoreFileNotFoundOrPermissionError=false&" + 
> "throwExceptionOnConnectFailed=true&" + "fileName=readme.txt&"
>  + 

Migrating issue from 2.10 to 2.17

2016-10-18 Thread Alexander Vladimirov
Hello camel users,

I an trying to migrate camel to 2.17.
I am using multiple camel contexts and some of them are used as
integration. Which means referring context 1 and routing the message to
context to.

When I am trying to initialize them I receive
ResolveEndpointFailedException. I am trying to use the .to (:url)
ideot.  Was there something changed between the versions?

Before that this way worked.

Cheers,
Alex


Camel - Making parallel GET requests and aggregating the results via Dynamic Routes using Java DSL

2016-10-18 Thread Debraj Manna
I am receiving a request on a Jetty Http Endpoint. The request body
contains some urls in the request body. I have to make a GET request to
those urls. Then aggregate the results from each of the GET request and
return it to the caller.

Request Body:-

{
"data" : [
{"name" : "Hello", "url" : "http://server1"}
{"name" : "Hello2", "url" : "http://server2"}

]
}

One way I can think of doing this is like below:-

from("jetty:http://localhost:/hello;).process(new Processor() {
public void process(Exchange exchange) throws Exception {
// 1. Make the GET request in parallel using ThreadPoolExecutor
// 2. Wait for all calls to finish. Collate the response
// 3. Write it to exchange.getOut().setBody
}
})

Can some one let me know if this can be achieved via Java DSL using camel
dynamic Routes, splitter & aggregator so that my Processor remains
relatively small?

I am using camel 2.16.3.


Apace Camel : Custom Redelivery Policy

2016-10-18 Thread Shabin5785
I have a route that calls an external rest service. I have configured my
error handler as shown below.

errorHandler(deadLetterChannel("jms:dlc").maximumRedeliveries(3));

What i want to do:

1) If connection to external api fails, i want to retry 3 times and then
send to deadLetterChannel
2) If api call is fine, i want to check the status code, log the response
and then send the message to deadLetterChannel.
For that i set throwExceptionOnFailure to false.

In my route i have a bean as the last endpoint. This bean receives the
response from the external end point and checks for the status.

void process(Exchange exchange){
  //check http status code
  //if not success
  exchange.setProperty(Exchange.ROUTE_STOP,true);
  //sendToDeadLetterQueue;
  }


My problem is that redelivery happens even when i am able to connect to API.
I expect the redelivery to happen on error. I am handling the response from
API and also stopping the exchange. So i expect my Bean to log the response
from API, send to deadLetterQueue(I have a route for that) and stop. But
redelivery happens 3 times evand so en when API call is successful and so
deadletterchannel route is invoked 3 times

Can i stop the redelivery from my bean?



--
View this message in context: 
http://camel.465427.n5.nabble.com/Apace-Camel-Custom-Redelivery-Policy-tp5788891.html
Sent from the Camel - Users mailing list archive at Nabble.com.


apache camel returns statusCode:500

2016-10-18 Thread meng
Hi All, 
I'm the new of camel. I now use apache camel to call several our
webservices.

Here is my code:
public void configure() throws Exception{
from("direct:start")
.marshal()
.string(UTF_8)
.to(TARGET http)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws
Exception {
String message =
exchange.getIn().getBody(String.class);
System.out.println(message);
}
})
   .to("stream:out");

I'm sure there is no problem about the target endpoint, for I can get
correct response using postman.
But camel give me 500 error.
Caused by: org.apache.camel.http.common.HttpOperationFailedException: HTTP
operation failed invoking http:// with statusCode: 500
at
org.apache.camel.component.http.HttpProducer.populateHttpOperationFailedException(HttpProducer.java:240)
~[camel-http-2.16.1.jar:2.16.1]
at
org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:162)
~[camel-http-2.16.1.jar:2.16.1]
at
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
~[camel-core-2.16.1.jar:2.16.1]
at 
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:141)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:460)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
~[camel-core-2.16.1.jar:2.16.1]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
~[camel-core-2.16.1.jar:2.16.1]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:190)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:68)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:412)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:380)
~[camel-core-2.16.1.jar:2.16.1]
at 
org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:270)
~[camel-core-2.16.1.jar:2.16.1]
at 
org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:380)
~[camel-core-2.16.1.jar:2.16.1]
at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:238)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:128)
~[camel-core-2.16.1.jar:2.16.1]
at
org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:132)
~[camel-core-2.16.1.jar:2.16.1]
... 16 common frames omitted

Could you help what's my problem or how can I debug it?
Thanks a lot!



--
View this message in context: 
http://camel.465427.n5.nabble.com/apache-camel-returns-statusCode-500-tp578.html
Sent from the Camel - Users mailing list archive at Nabble.com.