Re: Using {date:..} placeholder in camel-context endpoint

2013-07-29 Thread roger_rabbit
Thank you for your answer.

I understand I can use a custom filter to filter directory based including
the date I want to process, but not sure it is suited for creating a
directory with such rule :
=> "write to a directory named /tmp/${MMdd} and create it if it does not
exist". 

For the moment, I also tried creating the endpoint in my Route Builder :

this.folderOut = "file:"+
  baseFolder+
  "/${date:now:MMdd}?autocreate=true";

But I got an exception saying :
/Dynamic expressions with ${ } placeholders is not allowed. Use the fileName
option to set the dynamic expression./



--
View this message in context: 
http://camel.465427.n5.nabble.com/Using-date-placeholder-in-camel-context-endpoint-tp5736295p5736403.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Setting header with simple

2013-07-29 Thread Bob Jolliffe
I am trying to set the value of a header in a route like:

...
  
  ${body.get('properties').get('Dhis2UID')}
...

The log message displays the expected value.

But the header is being populated with the literal text
"${body.get('properties').get('Dhis2UID')}".

Any idea what I am doing wrong?

Regards
Bob


Re: Using {date:..} placeholder in camel-context endpoint

2013-07-29 Thread Claus Ibsen
Hi

Yeah use baseFolder as the starting directory. And then use
/${date:now:MMdd} as prefix for the the file name.

?fileName=${date:now:MMdd}/${file:name}

For the name of the file you can use the file language (part of simple
language), see
http://camel.apache.org/file-language.html

There is some examples here
http://camel.apache.org/file-language.html

On Mon, Jul 29, 2013 at 10:17 AM, roger_rabbit  wrote:
> Thank you for your answer.
>
> I understand I can use a custom filter to filter directory based including
> the date I want to process, but not sure it is suited for creating a
> directory with such rule :
> => "write to a directory named /tmp/${MMdd} and create it if it does not
> exist".
>
> For the moment, I also tried creating the endpoint in my Route Builder :
>
> this.folderOut = "file:"+
>   baseFolder+
>   "/${date:now:MMdd}?autocreate=true";
>
> But I got an exception saying :
> /Dynamic expressions with ${ } placeholders is not allowed. Use the fileName
> option to set the dynamic expression./
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Using-date-placeholder-in-camel-context-endpoint-tp5736295p5736403.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: Setting header with simple

2013-07-29 Thread Claus Ibsen
constant is 100% constant, eg exactly what you type.

For dynamic values use a scripting language like simple, groovy etc


On Mon, Jul 29, 2013 at 10:25 AM, Bob Jolliffe  wrote:
> I am trying to set the value of a header in a route like:
>
> ...
>   
>   >${body.get('properties').get('Dhis2UID')}
> ...
>
> The log message displays the expected value.
>
> But the header is being populated with the literal text
> "${body.get('properties').get('Dhis2UID')}".
>
> Any idea what I am doing wrong?
>
> Regards
> Bob



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: Setting header with simple

2013-07-29 Thread Bob Jolliffe
Oops sorry I just solved it:
${body.get('properties').get('Dhis2UID')}

Constant is constant :-)


On 29 July 2013 09:34, Claus Ibsen  wrote:

> constant is 100% constant, eg exactly what you type.
>
> For dynamic values use a scripting language like simple, groovy etc
>
>
> On Mon, Jul 29, 2013 at 10:25 AM, Bob Jolliffe 
> wrote:
> > I am trying to set the value of a header in a route like:
> >
> > ...
> >   
> >   
> >>${body.get('properties').get('Dhis2UID')}
> > ...
> >
> > The log message displays the expected value.
> >
> > But the header is being populated with the literal text
> > "${body.get('properties').get('Dhis2UID')}".
> >
> > Any idea what I am doing wrong?
> >
> > Regards
> > Bob
>
>
>
> --
> Claus Ibsen
> -
> Red Hat, Inc.
> Email: cib...@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>


Re: How to get User ID from ActiveMQ to Camel

2013-07-29 Thread Daniel Kleine-Albers

Hi,

thank you very much! I had already tried to override the Header Filter 
Strategy, but I have not been successful with this method.


However, I was able to create a small ActiveMQ Plugin that puts the 
authenticated username in another header - and voila, this is perfectly 
visible in Camel.



Best regards
Daniel

On 28.07.2013 12:50, Claus Ibsen wrote:

Hi

Logged a ticket to improve this
https://issues.apache.org/jira/browse/CAMEL-6583

On Sun, Jul 28, 2013 at 12:22 PM, Claus Ibsen  wrote:

Hi

Ah spotted this, see the source code of
org.apache.camel.component.jms.JmsHeaderFilterStrategy

On Sun, Jul 28, 2013 at 12:21 PM, Claus Ibsen  wrote:

Hi

What version of ActiveMQ and Camel are you using?

And you can enable DEBUG or TRACE logging on
org.apache.camel.component.jms.EndpointMessageListener

Then Camel should log the receive JMS message. Maybe you can see if it
contains the user id somewhere.

You can also always get the original javax.jms.Message using a processor / bean

javax.jms.Message jms = exchange.getIn(JmsMessage.class).getJmsMessage();

and then check that original jms message what it contains

On Tue, Jul 23, 2013 at 2:06 PM, Daniel Kleine-Albers
 wrote:

Hi everyone,

I'm trying to get the ActiveMQ username of the sender of a particular
message into Camel for further processing. However this does not seem to
work.

I have setup my ActiveMQ broker to populate the JMSXUserID message property.

 http://activemq.apache.org/schema/core";>


With debugging enabled I can see that the message contains the userID as
expected:

13-07-23 13:46:27,916 [INFO]
(org.apache.activemq.broker.util.LoggingBrokerPlugin) - postProcessDispatch
:MessageDispatch {commandId = 7, responseRequired = false, consumerId =
ID:pc22-37613-1374579904970-3:1:1:1, destination = queue://fromclient,
message = ActiveMQBytesMessage {commandId = 6, responseRequired = false,
messageId = ID:pc22-37613-1374579904970-6:12:-1:1:2, originalDestination =
null, originalTransactionId = null, producerId =
ID:pc22-37613-1374579904970-6:12:-1:1, destination = queue://fromclient,
transactionId = null, expiration = 0, timestamp = 1374579987913, arrival =
0, brokerInTime = 1374579987913, brokerOutTime = 1374579987914,
correlationId = z1hbqqt065, replyTo = null, persistent = false, type = null,
priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null,
compressed = false, *userID = ws:RoWkBu9W9HrLXyPyOeXLgD3OwtIrW4si*, content
= org.apache.activemq.util.ByteSequence@6cb2b9ec, marshalledProperties =
null, dataStructure = null, redeliveryCounter = 0, size = 1028, properties =
{LMSMessageType=Ping}, readOnlyProperties = true, readOnlyBody = true,
droppable = false} ActiveMQBytesMessage{ bytesOut = null, dataOut = null,
dataIn = null }, redeliveryCounter = 0}


Additionally I have a very short route defined that just logs the message:

13-07-23 13:46:27,918 [INFO] (fromclient) - Exchange[ExchangePattern:InOnly,
Properties:{CamelBinding=org.apache.camel.component.jms.JmsBinding@5f41ab78,
CamelToEndpoint=log://fromclient?showHeaders=true&showProperties=true,
CamelCreatedTimestamp=Tue Jul 23 13:46:27 CEST 2013,
CamelExternalRedelivered=false}, Headers:{JMSExpiration=0, JMSPriority=4,
JMSReplyTo=null, JMSDeliveryMode=1, JMSDestination=queue://fromclient,
JMSRedelivered=false, JMSType=null,
JMSMessageID=ID:pc22-37613-1374579904970-6:12:-1:1:2,
JMSCorrelationID=z1hbqqt065,
breadcrumbId=ID:pc22-37613-1374579904970-6:12:-1:1:2, JMSXGroupID=null,
JMSTimestamp=1374579987913}, BodyType:byte[], Body:PING]

--> Here I can't see a user ID (I would expect a JMSXUserID header)

Do you have any idea on why this could happen?


Thanks
Daniel



--
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen



--
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen





SEDA with PriorityBlockingQueue

2013-07-29 Thread gquintana
Hi,

Is it possible to configure a SEDA endpoint so as to handle priorities using
a PriorityBlockingQueue instead of LinkedBlockingQueue, and optionally
provide a Comparator to sort messages?

Thanks,
Gérald



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


Re: SEDA with PriorityBlockingQueue

2013-07-29 Thread Claus Ibsen
Hi

Yeah if you use java code and create the SedaEndpoints manually. You
can pass in the queue instance of your choice.

Though maybe we should have an interface for a queue factory so people
can configure this once on the seda component once, and have it work
out of the box?


On Mon, Jul 29, 2013 at 10:52 AM, gquintana  wrote:
> Hi,
>
> Is it possible to configure a SEDA endpoint so as to handle priorities using
> a PriorityBlockingQueue instead of LinkedBlockingQueue, and optionally
> provide a Comparator to sort messages?
>
> Thanks,
> Gérald
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/SEDA-with-PriorityBlockingQueue-tp5736411.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Invoking Servlet from Camel

2013-07-29 Thread SyedBhai
Hi guys,
  I am having a servlet.  It expects one parameter, say 'message'.
  I want to invoke it using camel.
  I am able to invoke it successfully as a HTTP GET method as follows:
   
from("direct:start").to("http://192.168.221.109:8080/DSP1/ServletDsp?message=HelloCamel";);
String response=template.requestBody("direct:start", null,
String.class);

  What I want is instead of passing the parameter in the query string, can I
pass it as a message body?
String response=template.requestBody("direct:start", "HelloCamel",
String.class);

  Is there a way to accomplish this?
 
  I have already visited Camel Servlet Component webpage.

  It doesn't help.

Thanks,
Syed.



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


Re: Invoking Servlet from Camel

2013-07-29 Thread Claus Ibsen
Hi

See this page
http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html

On Mon, Jul 29, 2013 at 12:38 PM, SyedBhai  wrote:
> Hi guys,
>   I am having a servlet.  It expects one parameter, say 'message'.
>   I want to invoke it using camel.
>   I am able to invoke it successfully as a HTTP GET method as follows:
>
> from("direct:start").to("http://192.168.221.109:8080/DSP1/ServletDsp?message=HelloCamel";);
> String response=template.requestBody("direct:start", null,
> String.class);
>
>   What I want is instead of passing the parameter in the query string, can I
> pass it as a message body?
> String response=template.requestBody("direct:start", "HelloCamel",
> String.class);
>
>   Is there a way to accomplish this?
>
>   I have already visited Camel Servlet Component webpage.
>
>   It doesn't help.
>
> Thanks,
> Syed.
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Invoking-Servlet-from-Camel-tp5736417.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: Is it Camel Bug?

2013-07-29 Thread James Carman
Why do you need Camel here at all?  If you're just calling a web service,
that's simple enough using just cxf.

On Monday, July 29, 2013, SyedBhai wrote:

> Hello Willem,
>   Yes.  This is what I wanted.
>   When I add the option "synchronous=true" it shutsdown gracefully
> immediately.
>
> Thanks,
> Syed.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Is-it-Camel-Bug-tp5736288p5736399.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


Re: Invoking Servlet from Camel

2013-07-29 Thread Bilgin Ibryam
Hi Syed,

what you have done should work.
If you set a message body http4 component will use POST method to do
the http call and sent the message body as post body.

Have a look here http://camel.apache.org/http4.html

You can also set the http method manually if you prefer, like this:
 .setHeader(Exchange.HTTP_METHOD,
constant(org.apache.camel.component.http4.HttpMethods.POST))

But notice that in this case, in your servlet you will get the call
from doPost method and not from doGet

HTH
Bilgin

On 29 July 2013 11:38, SyedBhai  wrote:
> Hi guys,
>   I am having a servlet.  It expects one parameter, say 'message'.
>   I want to invoke it using camel.
>   I am able to invoke it successfully as a HTTP GET method as follows:
>
> from("direct:start").to("http://192.168.221.109:8080/DSP1/ServletDsp?message=HelloCamel";);
> String response=template.requestBody("direct:start", null,
> String.class);
>
>   What I want is instead of passing the parameter in the query string, can I
> pass it as a message body?
> String response=template.requestBody("direct:start", "HelloCamel",
> String.class);
>
>   Is there a way to accomplish this?
>
>   I have already visited Camel Servlet Component webpage.
>
>   It doesn't help.
>
> Thanks,
> Syed.
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Invoking-Servlet-from-Camel-tp5736417.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Invoking Servlet from Camel

2013-07-29 Thread James Carman
If you just set the query string using the header Exchange.HTTP_QUERY,
then it will use GET automatically.  Also, if you just use an
expression (as Claus was suggesting) to bind the body of the message
to the query parameter, it will use GET automatically also.

On Mon, Jul 29, 2013 at 6:58 AM, Bilgin Ibryam  wrote:
> Hi Syed,
>
> what you have done should work.
> If you set a message body http4 component will use POST method to do
> the http call and sent the message body as post body.
>
> Have a look here http://camel.apache.org/http4.html
>
> You can also set the http method manually if you prefer, like this:
>  .setHeader(Exchange.HTTP_METHOD,
> constant(org.apache.camel.component.http4.HttpMethods.POST))
>
> But notice that in this case, in your servlet you will get the call
> from doPost method and not from doGet
>
> HTH
> Bilgin
>
> On 29 July 2013 11:38, SyedBhai  wrote:
>> Hi guys,
>>   I am having a servlet.  It expects one parameter, say 'message'.
>>   I want to invoke it using camel.
>>   I am able to invoke it successfully as a HTTP GET method as follows:
>>
>> from("direct:start").to("http://192.168.221.109:8080/DSP1/ServletDsp?message=HelloCamel";);
>> String response=template.requestBody("direct:start", null,
>> String.class);
>>
>>   What I want is instead of passing the parameter in the query string, can I
>> pass it as a message body?
>> String response=template.requestBody("direct:start", "HelloCamel",
>> String.class);
>>
>>   Is there a way to accomplish this?
>>
>>   I have already visited Camel Servlet Component webpage.
>>
>>   It doesn't help.
>>
>> Thanks,
>> Syed.
>>
>>
>>
>> --
>> View this message in context: 
>> http://camel.465427.n5.nabble.com/Invoking-Servlet-from-Camel-tp5736417.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.


What is the best practice for trigger

2013-07-29 Thread zzkozak
Hi,

 I have the following route:

 It's running in my, so called, "integration server". It is handling
discount updates from other system. At the end of the processing I would
like to trigger the shopping system to update the discount (because they are
cached). What is the best practice to do it? I could simply forward the
original message " but I would
like to avoid to send the whole payload of the discount.

 Thank you,
Marcin



--
View this message in context: 
http://camel.465427.n5.nabble.com/What-is-the-best-practice-for-trigger-tp5736422.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Adding MultiConsumer support to a ScheduledPollEndpoint/ScheduledPollConsumer

2013-07-29 Thread cgiera
Claus Ibsen-2 wrote
> They are not the same. The former is for allowing 2+ routes with the
> same endpoint, eg multiple consumers, eg:
> 
> from A
>   to B
> 
> from A
>   to C
> 
> 
> concurrentConsumers is for the same consumer, eg
> 
> from A concurrentConsumers = 10
>   to B
> 
>> I have looked through the existing components and there are only jms,
>> seda
>> and timer which support this feature. Non of them does fit my
>> requirements
>> exactly(or I don't understand it enough).
>>
>> Sorry if I've missed something and it is really easy, thanks for your
>> time.
>>
>> kind regards,
>> Christoph
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Adding-MultiConsumer-support-to-a-ScheduledPollEndpoint-ScheduledPollConsumer-tp5736266.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> 
> 
> -- 
> Claus Ibsen
> -
> Red Hat, Inc.
> Email: 

> cibsen@

> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen

Hello,

yes I want to implement

from A concurrentConsumers = 10
  to B

but there I'm missing the step where I can easily create/register more than
1 consumer.

kind regards,
Christoph



--
View this message in context: 
http://camel.465427.n5.nabble.com/Adding-MultiConsumer-support-to-a-ScheduledPollEndpoint-ScheduledPollConsumer-tp5736266p5736424.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Invoking Servlet from Camel

2013-07-29 Thread SyedBhai
Hello.
  But how can I ensure that the body I am passing is connected to the
parameter 'message'?

Thanks,
Syed.



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


Re: What is the best practice for trigger

2013-07-29 Thread zzkozak
I just learned that there exist a JMX Endpoint which I can use in this case,
since our shop system offers an MBean with a method for reloading the
discounts.



--
View this message in context: 
http://camel.465427.n5.nabble.com/What-is-the-best-practice-for-trigger-tp5736422p5736427.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Long <-> Date TypeConverter

2013-07-29 Thread Marco Zapletal

Hi folks,


I recently encountered the situation that we required a Long (unix 
timestamp) to java.util.Date conversion. I was pretty sure that such a 
converter will exist in core-camel, but it doesn't. Furthermore, I came 
across some pieces of code in camel-core, where this conversion is done 
"manually" and not via a type converter - e.g., FileOperations:328


 Date date = exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, 
Date.class);

if (date != null) {
last = date.getTime();
} else {
// fallback and try a long
last = 
exchange.getIn().getHeader(Exchange.FILE_LAST_MODIFIED, Long.class);

 }


Is there a special reason why no Long <-> Date converter exists in the 
DateTimeConverter? If not, I would suggest to open a JIRA issue and 
attach a patch there.



Best regards,

Marco


Re: Adding MultiConsumer support to a ScheduledPollEndpoint/ScheduledPollConsumer

2013-07-29 Thread Claus Ibsen
You have to implement this logic yourself in your custom component.

On Mon, Jul 29, 2013 at 1:46 PM, cgiera  wrote:
> Claus Ibsen-2 wrote
>> They are not the same. The former is for allowing 2+ routes with the
>> same endpoint, eg multiple consumers, eg:
>>
>> from A
>>   to B
>>
>> from A
>>   to C
>>
>>
>> concurrentConsumers is for the same consumer, eg
>>
>> from A concurrentConsumers = 10
>>   to B
>>
>>> I have looked through the existing components and there are only jms,
>>> seda
>>> and timer which support this feature. Non of them does fit my
>>> requirements
>>> exactly(or I don't understand it enough).
>>>
>>> Sorry if I've missed something and it is really easy, thanks for your
>>> time.
>>>
>>> kind regards,
>>> Christoph
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://camel.465427.n5.nabble.com/Adding-MultiConsumer-support-to-a-ScheduledPollEndpoint-ScheduledPollConsumer-tp5736266.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>>
>> --
>> Claus Ibsen
>> -
>> Red Hat, Inc.
>> Email:
>
>> cibsen@
>
>> Twitter: davsclaus
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>
> Hello,
>
> yes I want to implement
>
> from A concurrentConsumers = 10
>   to B
>
> but there I'm missing the step where I can easily create/register more than
> 1 consumer.
>
> kind regards,
> Christoph
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Adding-MultiConsumer-support-to-a-ScheduledPollEndpoint-ScheduledPollConsumer-tp5736266p5736424.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: Adding MultiConsumer support to a ScheduledPollEndpoint/ScheduledPollConsumer

2013-07-29 Thread cgiera
Yes, but I haven't found an easy way to add my consumer(when I extend from
ScheduledPollConsumer it is a Runnable) to the underlying executerService. I
think there should be an easy way but I haven't found it.

kind regards,
Christoph



--
View this message in context: 
http://camel.465427.n5.nabble.com/Adding-MultiConsumer-support-to-a-ScheduledPollEndpoint-ScheduledPollConsumer-tp5736266p5736431.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Adding MultiConsumer support to a ScheduledPollEndpoint/ScheduledPollConsumer

2013-07-29 Thread Claus Ibsen
ScheduledPollConsumer is by default a single threaded consumer.

You would need to schedule more tasks yourself, see the startScheduler
method in ScheduledPollConsumer.
You can override that and schedule more tasks.

By default only 1 task is scheduled.

On Mon, Jul 29, 2013 at 2:52 PM, cgiera  wrote:
> Yes, but I haven't found an easy way to add my consumer(when I extend from
> ScheduledPollConsumer it is a Runnable) to the underlying executerService. I
> think there should be an easy way but I haven't found it.
>
> kind regards,
> Christoph
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Adding-MultiConsumer-support-to-a-ScheduledPollEndpoint-ScheduledPollConsumer-tp5736266p5736431.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


JMS properties to In message headers

2013-07-29 Thread Marco Crivellaro
Hi all,
I am using Camel 2.11.1

By default Camel adds the a list of JMS properties to the In message headers
when it receives a JMS message, for instance: JMSTimestamp, JMSType,
JMSXGroupID...

is there a way to extend this list without having to create a Processor to
the route?

I would like to access JMSActiveMQBrokerInTime and JMSActiveMQBrokerOutTime.



Thank you,
Marco



--
View this message in context: 
http://camel.465427.n5.nabble.com/JMS-properties-to-In-message-headers-tp5736433.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Adding MultiConsumer support to a ScheduledPollEndpoint/ScheduledPollConsumer

2013-07-29 Thread cgiera
Yes, that's a good hint.
>From your experience is it a viable way to implement it like this?


It looks strange to me to add new consumers in a consumer class.

Maybe there is some impact on the general functionallity if I don't create
consumers with the endpoint.createConsumer method or something like that



--
View this message in context: 
http://camel.465427.n5.nabble.com/Adding-MultiConsumer-support-to-a-ScheduledPollEndpoint-ScheduledPollConsumer-tp5736266p5736434.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: JMS properties to In message headers

2013-07-29 Thread gquintana
I think you should extend the  JmsHeaderFilterStrategy

  



--
View this message in context: 
http://camel.465427.n5.nabble.com/JMS-properties-to-In-message-headers-tp5736433p5736435.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: FTP Consumer, move file to failed directory

2013-07-29 Thread Ayache Khettar
Hi

Many thanks Claus for your help. I will certainly be posting the messages
in the malling list in the future.

Regards,

Ayache


On 27 July 2013 09:03, Claus Ibsen  wrote:

> Hi
>
> Signup and use the mailing list instead of the nabble forum to post
> quicker.
> From nabble ppl have to moderate the mails and that is frankly time
> consuing and we have holidays and whatnot. So have patience when using
> nabble.
>
> And to answer your question there is a moveFailed option.
> http://camel.apache.org/file2
>
> On Fri, Jul 26, 2013 at 9:54 AM, akcameluser 
> wrote:
> > Hi
> >
> > This post has been submitted yesterday and it's still flagged that it
> hasn't
> > been accepted by the mailing list yet. Have done anything wrong?
> >
> > Thanks
> >
> > Ayache
> >
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/FTP-Consumer-move-file-to-failed-directory-tp5736265p5736282.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -
> Red Hat, Inc.
> Email: cib...@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>


Re: SEDA with PriorityBlockingQueue

2013-07-29 Thread Christian Müller
+1

Best,
Christian
Am 29.07.2013 11:00 schrieb "Claus Ibsen" :

> Hi
>
> Yeah if you use java code and create the SedaEndpoints manually. You
> can pass in the queue instance of your choice.
>
> Though maybe we should have an interface for a queue factory so people
> can configure this once on the seda component once, and have it work
> out of the box?
>
>
> On Mon, Jul 29, 2013 at 10:52 AM, gquintana 
> wrote:
> > Hi,
> >
> > Is it possible to configure a SEDA endpoint so as to handle priorities
> using
> > a PriorityBlockingQueue instead of LinkedBlockingQueue, and optionally
> > provide a Comparator to sort messages?
> >
> > Thanks,
> > Gérald
> >
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/SEDA-with-PriorityBlockingQueue-tp5736411.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -
> Red Hat, Inc.
> Email: cib...@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>


Camel Spring DSL - FTP consumerTemplate.receive gives null Exchange

2013-07-29 Thread hardikdesai81
Hi folks,

I am using Camel with Spring DSL. I have implemented the FTP producer
correctly and I am able to generated a JSON object at runtime and send it to
an FTP Endpoint. However, when trying to consume that same JSON using
Consumer Template, I am facing a sporadic problem.

Following is my Spring context XML:



classpath:ftp.properties
classpath:jdbc.properties











Following is my Producer code which is working fine:
@Service
public class FtpSenderServiceImpl implements FtpSenderService {

private final ProducerTemplate producerTemplate;
private final Endpoint ftpEndpoint;

@Autowired
FtpSenderServiceImpl(ProducerTemplate producerTemplate, Endpoint
ftpEndpoint) {
this.producerTemplate = producerTemplate;
this.ftpEndpoint = ftpEndpoint;
}

@Override
public void sendFile(File file) throws CamelExecutionException,
UnsupportedEncodingException {
producerTemplate.sendBodyAndHeader(ftpEndpoint, file,
Exchange.FILE_NAME, file.getName());
}
}

Following is my Consumer code:
@Service
public class FtpReceiverServiceImpl implements FtpReceiverService {

private final ConsumerTemplate consumerTemplate;
private final Endpoint ftpEndpoint;

@Autowired
FtpReceiverServiceImpl(ConsumerTemplate consumerTemplate, Endpoint
ftpEndpoint) {
this.consumerTemplate = consumerTemplate;
this.ftpEndpoint = ftpEndpoint;
}

@Override
public List receiveFiles() throws InterruptedException {
List files = new ArrayList();
Exchange ex = consumerTemplate.receive(ftpEndpoint, 5000);
while(ex!=null) {
files.add((String) 
ex.getIn().getHeader("CamelFileName"));
ex = consumerTemplate.receive(ftpEndpoint, 5000);
}
return files;
}
}

Basically, the receiveFiles() method should create a list of all files on
the FTP site. When I start my server, and immediately invoke my Service to
call receiveFiles(), then consumerTemplate.receive(ftpEndpoint, 5000)
returns a 'null' Exchange. 

But, if I wait for few seconds, and then execute the same
consumerTemplate.receive(ftpEndpoint, 5000), I am successfully able to fetch
the DefaultExchange object.

Why doesn't the consumerTemplate.receive(ftpEndpoint, 5000) return the valid
Exchange object in first attempt? Is there some configuration that I can set
in my FTP URI that can force it to invoke receive() only after a valid FTP
connection has been established?





--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-Spring-DSL-FTP-consumerTemplate-receive-gives-null-Exchange-tp5736439.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Camel Spring DSL - FTP consumerTemplate.receive gives FTP time out

2013-07-29 Thread hardikdesai81
Hi folks, 

I am using Camel with Spring DSL. I have implemented the FTP producer
correctly and I am able to generated a JSON object at runtime and send it to
an FTP Endpoint. However, when trying to consume that same JSON using
Consumer Template, I am facing an FTP connection timeout problem when I
leave my server running for some time. Please see details below.

Following is my Spring context XML: 






Following is my Consumer code: 
@Service 
public class FtpReceiverServiceImpl implements FtpReceiverService { 

private final ConsumerTemplate consumerTemplate; 
private final Endpoint ftpEndpoint; 

@Autowired 
FtpReceiverServiceImpl(ConsumerTemplate consumerTemplate, Endpoint
ftpEndpoint) { 
this.consumerTemplate = consumerTemplate; 
this.ftpEndpoint = ftpEndpoint; 
} 

@Override 
public List receiveFiles() throws InterruptedException { 
List files = new ArrayList(); 
Exchange ex = consumerTemplate.receive(ftpEndpoint, 5000); 
while(ex!=null) { 
files.add((String)
ex.getIn().getHeader("CamelFileName")); 
ex = consumerTemplate.receive(ftpEndpoint, 5000); 
} 
return files; 
} 
} 

When I leave the server running for few minutes, and then try
consumerTemplate.receive(ftpEndpoint, 5000), I get the following time out
exception.

WARN :
org.apache.camel.component.file.remote.RemoteFilePollingConsumerPollStrategy
- Trying to recover by disconnecting from remote server forcing a re-connect
at next poll: ftp://anonym...@xx.xx.xx.xx:21
WARN : org.apache.camel.component.file.remote.FtpConsumer - Error occurred
while disconnecting from ftp://anonym...@xx.xx.xx.xx:21 due: File operation
failed: 421 Terminating connection.
 FTP response 421 received.  Server closed connection.. Code: 421. This
exception will be ignored.
WARN : org.apache.camel.component.file.remote.FtpConsumer - Consumer
FtpConsumer[ftp://anonym...@xx.xx.xx.xx/Test/Test1?download=true&localWorkDirectory=D%3A%2Fmetamodel&passiveMode=false&password=**]
failed polling endpoint:
Endpoint[ftp://anonym...@xx.xx.xx.xx/Test/Test1?download=true&localWorkDirectory=D%3A%2Fmetamodel&passiveMode=false&password=**].
Will try again at next poll. Caused by:
[org.apache.camel.component.file.GenericFileOperationFailedException - File
operation failed: 421 Timeout (120 seconds): closing control connection.
 FTP response 421 received.  Server closed connection.. Code: 421]
org.apache.camel.component.file.GenericFileOperationFailedException: File
operation failed: 421 Timeout (120 seconds): closing control connection.
 FTP response 421 received.  Server closed connection.. Code: 421
at
org.apache.camel.component.file.remote.FtpOperations.getCurrentDirectory(FtpOperations.java:700)
at
org.apache.camel.component.file.remote.FtpConsumer.pollDirectory(FtpConsumer.java:45)
at
org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:115)
at
org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:142)
at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:92)
at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at
java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.commons.net.ftp.FTPConnectionClosedException: FTP
response 421 received.  Server closed connection.
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:363)
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:290)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:479)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:552)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:601)
at org.apache.commons.net.ftp.FTP.pwd(FTP.java:1399)
at
org.apache.commons.net.ftp.FTPClient.printWorkingDirectory(FTPClient.java:2469)
at
org.apache.camel.component.file.remote.FtpOperations.getCurrentDirectory(FtpOperations.java:696)
... 13 more

Am I missing a configuration parameter in 

Aggregator message redelivery issues

2013-07-29 Thread piotrsl
Hi Guys 
I'm struggling with the following issue and maybe you will be able to help
me.

Recently i have noticed that messages which are aggregated by camel
Aggregator2 with hawtdb persistence store are lost because the following
exception

2013-07-29 10:02:18,478 | ERROR | Failed delivery for exchangeId:
ID-UK1DAAMQ001VA-57144-1374756544748-0-9284. Exhausted after delivery
attempt: 1 caught: java.lang.RuntimeException: Error getting key 125AAA from
repository futuresAggregatorRepository |
org.apache.camel.processor.DefaultErrorHandler | Camel (camel) thread #11 -
JmsConsumer[GC.Canonical.ClearedTrade.Tempest.Test]
java.lang.RuntimeException: Error getting key 125AAA  from repository
AggregatorRepository
at
org.apache.camel.component.hawtdb.HawtDBAggregationRepository.get(HawtDBAggregationRepository.java:164)
.
Caused by: java.io.IOException
at java.nio.MappedByteBuffer.force0(Native Method)
at java.nio.MappedByteBuffer.force(MappedByteBuffer.java:154)
at
org.fusesource.hawtdb.internal.io.MemoryMappedFile.sync(MemoryMappedFile.java:255)
at
org.fusesource.hawtdb.internal.page.HawtTxPageFile.syncBatches(HawtTxPageFile.java:656)
at
org.fusesource.hawtdb.internal.page.HawtTxPageFile.flush(HawtTxPageFile.java:551)
at
org.apache.camel.component.hawtdb.HawtDBFile.doExecute(HawtDBFile.java:165)
at
org.apache.camel.component.hawtdb.HawtDBFile.execute(HawtDBFile.java:113)
at
org.apache.camel.component.hawtdb.HawtDBAggregationRepository.get(HawtDBAggregationRepository.java:144)

--
CAMEL



  









Do you know what might be causing java.io.IOException
And why redelivery mechanism didn't work


Details
apache-activemq-5.5.1-fuse-03-06
hawtdb-1.6.jar
hawtbuf-1.9.jar
camel-hawtdb-2.8.6.jar





--
View this message in context: 
http://camel.465427.n5.nabble.com/Aggregator-message-redelivery-issues-tp5736445.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Camel testing

2013-07-29 Thread Costash
Hi,

I've just started to use camel, and I'm trying to understand and create some
unit tests, but i don t understand how Mok is working or how unit tests
should look like (i've read the tutorials and documentation about camel
test).
What do i mean by not understanging is:

i have a defined route:
=
public class MyRouteBuilder extends RouteBuilder{
.
@Override
public void configure() throws Exception {
from("jms:queue:inputQueueName").process(new Processor()
{.}).to("jms:queue:outputputQueueName");
==

in all the examples found , a new Class extends CamelTestSupport {

and also creating the rounting inside, so it can be moked:
===
   @Override
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
   
from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
}
};
}

so the route is defined exactly here, so it can be moked and get the
endpoints.

BUT, what about to test an allready created route?
I can't say .to("mock:result");

i suposed it should be:

=
 @Override
protected RouteBuilder createRouteBuilder() {
return new MyRouteBuilder();
}
==


So my questions are:
1. how can i test a route? (i can't define the rules of routing inside the
test class by overwriting the createRouteBuilder() , because i already have
the route implementation => duplicate code)
2. Should my MyRouteBuilder have specific methods implemented so i can mok
it after in the test class?
3. is it there another way to test the output messages of a router besides
Mok?
  - I did it in one way, but i think is not the "correct" one:
   - In a Test Class, I've created a Connection factory to a jms
queue and creating a context
   - I've added the desired route to be tested into the context
(  context.addRoute(new MyRoutebuilder()))
   - Started the context (so my router is running in 
"backgroud" let s say)
   - i've put a message into the input queue of the router with
another test Router (from file to queue)
   - i've taken the message from output queue of the router with
a test router (From message to file)
   - compare the file with an expected one.
  
But this is bad as concept for unit tests (let s say Junits), i think.

4. Do you a link, or something to a generic test example of a camel route?

PS: Sorry if the are stupid questions

Thanks,
Vlad



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


Re: Is it Camel Bug?

2013-07-29 Thread SyedBhai
Sir,
  You asked "why do you need camel at all"?
  The answer is firstly I know camel not cxf.
  Secondly I need to communicate with external programs which could be tcp
services, udp services, web services, servlets, etc.
  So using camel I can write uniform code to communicate with all the above
mentioned programs.
  Do you have any more questions?

Thanks,
Syed.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Is-it-Camel-Bug-tp5736288p5736447.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Is it Camel Bug?

2013-07-29 Thread James Carman
Well, you said all you needed to do was call a web service.  If that's
all you need, Camel is overkill.  Now, if you have other points of
integration, sure Camel's the right choice.

On Mon, Jul 29, 2013 at 2:48 PM, SyedBhai  wrote:
> Sir,
>   You asked "why do you need camel at all"?
>   The answer is firstly I know camel not cxf.
>   Secondly I need to communicate with external programs which could be tcp
> services, udp services, web services, servlets, etc.
>   So using camel I can write uniform code to communicate with all the above
> mentioned programs.
>   Do you have any more questions?
>
> Thanks,
> Syed.
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Is-it-Camel-Bug-tp5736288p5736447.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Use MessageFilter to process files that are 30 or more days old

2013-07-29 Thread Karim Garza
Hi,

I am trying to use the MessageFilter to process files that are 30 days or
older. I came up with this code to do the work, but it appears that
the CamelFileLastModified header is a long and I do not know how to use to
compare it with a date.

public void configure() throws Exception {
DateTime date = new DateTime();
 from("file:{{file.inbox}}?delete=true")
.filter(header("CamelFileLastModified").isLessThan(date.minusDays(30)))
 .process(new FileProcessor());
}

I would appreciate any help you can provide,

Karim


Camel route only dealing with headers

2013-07-29 Thread jduncan
I have a route that listens on an ActiveMQ endpoint and only manipulates
exchange headers.  I don't care about the body of the exchange at all. 
Consequently, I don't want to have to
marshal/unmarshal/serialize/deserialize the body at all, but just send it
along to anything downstream.  Particularly, I don't want to try and
deserialize object messages in case I do not have the serialized class in my
classpath.  I have tried adding the mapJmsMessage=false property to my AMQ
consumer, but when I do that a null body gets passed to any downstream
routes.

How can I pass along the original body without touching it at all?

Thanks!
Jared



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-route-only-dealing-with-headers-tp5736452.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel route only dealing with headers

2013-07-29 Thread Christian Müller
Hello Jared!

If you have to propagate the body to a downstream service, you have to care
about the body. You have to make sure the body has a format ActiveMQ can
serialize (String, byte array, map, ...). Otherwise, how should ActiveMQ be
able to send your body over the wire?

Best,
Christian
-

Software Integration Specialist

Apache Camel committer: https://camel.apache.org/team
V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Mon, Jul 29, 2013 at 11:20 PM, jduncan  wrote:

> I have a route that listens on an ActiveMQ endpoint and only manipulates
> exchange headers.  I don't care about the body of the exchange at all.
> Consequently, I don't want to have to
> marshal/unmarshal/serialize/deserialize the body at all, but just send it
> along to anything downstream.  Particularly, I don't want to try and
> deserialize object messages in case I do not have the serialized class in
> my
> classpath.  I have tried adding the mapJmsMessage=false property to my AMQ
> consumer, but when I do that a null body gets passed to any downstream
> routes.
>
> How can I pass along the original body without touching it at all?
>
> Thanks!
> Jared
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-route-only-dealing-with-headers-tp5736452.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


Re: Camel route only dealing with headers

2013-07-29 Thread Christian Posta
Object message is not a very good way to send payload for various reasons.

Is your use case constrained to scenarios where ObjectMessages are being
used and cannot be changed? The more versatile choice would otherwise be
BytesMessage.




On Mon, Jul 29, 2013 at 2:20 PM, jduncan  wrote:

> I have a route that listens on an ActiveMQ endpoint and only manipulates
> exchange headers.  I don't care about the body of the exchange at all.
> Consequently, I don't want to have to
> marshal/unmarshal/serialize/deserialize the body at all, but just send it
> along to anything downstream.  Particularly, I don't want to try and
> deserialize object messages in case I do not have the serialized class in
> my
> classpath.  I have tried adding the mapJmsMessage=false property to my AMQ
> consumer, but when I do that a null body gets passed to any downstream
> routes.
>
> How can I pass along the original body without touching it at all?
>
> Thanks!
> Jared
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-route-only-dealing-with-headers-tp5736452.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta


Re: Use MessageFilter to process files that are 30 or more days old

2013-07-29 Thread John D. Ament
Karim,

Did you try date.minusDays(30).getMillis()?
Typically long formats for dates/times are in milliseconds.


On Mon, Jul 29, 2013 at 4:45 PM, Karim Garza  wrote:

> Hi,
>
> I am trying to use the MessageFilter to process files that are 30 days or
> older. I came up with this code to do the work, but it appears that
> the CamelFileLastModified header is a long and I do not know how to use to
> compare it with a date.
>
> public void configure() throws Exception {
> DateTime date = new DateTime();
>  from("file:{{file.inbox}}?delete=true")
> .filter(header("CamelFileLastModified").isLessThan(date.minusDays(30)))
>  .process(new FileProcessor());
> }
>
> I would appreciate any help you can provide,
>
> Karim
>


Re: Use MessageFilter to process files that are 30 or more days old

2013-07-29 Thread Christian Müller
Use the file component option "filter" [1], not the filter EIP.
Implement the org.apache.camel.component.file.GenericFileFilter class.
Create a new Calendar instance, subtract 30 days and take the time in
millis. If it's higher than the "CamelFileLastModified" header value,
return true. Otherwise, return false.

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

Best,
Christian
-

Software Integration Specialist

Apache Camel committer: https://camel.apache.org/team
V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Mon, Jul 29, 2013 at 10:45 PM, Karim Garza  wrote:

> Hi,
>
> I am trying to use the MessageFilter to process files that are 30 days or
> older. I came up with this code to do the work, but it appears that
> the CamelFileLastModified header is a long and I do not know how to use to
> compare it with a date.
>
> public void configure() throws Exception {
> DateTime date = new DateTime();
>  from("file:{{file.inbox}}?delete=true")
> .filter(header("CamelFileLastModified").isLessThan(date.minusDays(30)))
>  .process(new FileProcessor());
> }
>
> I would appreciate any help you can provide,
>
> Karim
>


Re: SEDA with PriorityBlockingQueue

2013-07-29 Thread Raul Kripalani
+1. It would enable many interesting solutions.
On 29 Jul 2013 15:48, "Christian Müller" 
wrote:

> +1
>
> Best,
> Christian
> Am 29.07.2013 11:00 schrieb "Claus Ibsen" :
>
> > Hi
> >
> > Yeah if you use java code and create the SedaEndpoints manually. You
> > can pass in the queue instance of your choice.
> >
> > Though maybe we should have an interface for a queue factory so people
> > can configure this once on the seda component once, and have it work
> > out of the box?
> >
> >
> > On Mon, Jul 29, 2013 at 10:52 AM, gquintana 
> > wrote:
> > > Hi,
> > >
> > > Is it possible to configure a SEDA endpoint so as to handle priorities
> > using
> > > a PriorityBlockingQueue instead of LinkedBlockingQueue, and optionally
> > > provide a Comparator to sort messages?
> > >
> > > Thanks,
> > > Gérald
> > >
> > >
> > >
> > > --
> > > View this message in context:
> >
> http://camel.465427.n5.nabble.com/SEDA-with-PriorityBlockingQueue-tp5736411.html
> > > Sent from the Camel - Users mailing list archive at Nabble.com.
> >
> >
> >
> > --
> > Claus Ibsen
> > -
> > Red Hat, Inc.
> > Email: cib...@redhat.com
> > Twitter: davsclaus
> > Blog: http://davsclaus.com
> > Author of Camel in Action: http://www.manning.com/ibsen
> >
>


Re: Camel route only dealing with headers

2013-07-29 Thread Christian Posta
You may wish to take a look at 'forceSendOriginalMessage' on the camel jms
endpoint... eg:

For example, the following does what you're asking:

from("jms:incoming?mapJmsMessage=false").to("jms:outgoing?forceSendOriginalMessage=true");

May have to play with the config a bit if you have other parts of your
route that manipulates headers, but check to docs and you should be good to
go:

http://camel.apache.org/jms.html


On Mon, Jul 29, 2013 at 3:00 PM, Christian Posta
wrote:

> Object message is not a very good way to send payload for various reasons.
>
> Is your use case constrained to scenarios where ObjectMessages are being
> used and cannot be changed? The more versatile choice would otherwise be
> BytesMessage.
>
>
>
>
> On Mon, Jul 29, 2013 at 2:20 PM, jduncan  wrote:
>
>> I have a route that listens on an ActiveMQ endpoint and only manipulates
>> exchange headers.  I don't care about the body of the exchange at all.
>> Consequently, I don't want to have to
>> marshal/unmarshal/serialize/deserialize the body at all, but just send it
>> along to anything downstream.  Particularly, I don't want to try and
>> deserialize object messages in case I do not have the serialized class in
>> my
>> classpath.  I have tried adding the mapJmsMessage=false property to my AMQ
>> consumer, but when I do that a null body gets passed to any downstream
>> routes.
>>
>> How can I pass along the original body without touching it at all?
>>
>> Thanks!
>> Jared
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/Camel-route-only-dealing-with-headers-tp5736452.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>
>
> --
> *Christian Posta*
> http://www.christianposta.com/blog
> twitter: @christianposta
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta


Re: Camel testing

2013-07-29 Thread Christian Posta
So keep in mind that the "endpoints" to a route are just
java.lang.String... So you can do:

String startRoute = "jms:incoming";
String endRoute = "jms:outgoing";

from(startRoute)..to(endRoute)

And then have that string injectable, so you can do
setEndRoute("mock:endpointName")...

But even if you don't want to do that, you can check out "adviceWith" which
wraps the existing endpoint with interesting behavior, including mocking it
out, and/or adding interceptors.

You should check out the doco at http://camel.apache.org/mock.html
You can also check out this refcard that covers essential camel components,
including the Mock component:
http://refcardz.dzone.com/refcardz/essential-camel-components
And lastly, but certainly not least.. the camel source code is packed with
unit tests. There are no better examples than the unit tests from the camel
code base:
http://camel.apache.org/how-can-i-get-the-source-code.html

Cheers,
Christian


On Mon, Jul 29, 2013 at 9:15 AM, Costash  wrote:

> Hi,
>
> I've just started to use camel, and I'm trying to understand and create
> some
> unit tests, but i don t understand how Mok is working or how unit tests
> should look like (i've read the tutorials and documentation about camel
> test).
> What do i mean by not understanging is:
>
> i have a defined route:
> =
> public class MyRouteBuilder extends RouteBuilder{
> .
> @Override
> public void configure() throws Exception {
> from("jms:queue:inputQueueName").process(new Processor()
> {.}).to("jms:queue:outputputQueueName");
> ==
>
> in all the examples found , a new Class extends CamelTestSupport {
>
> and also creating the rounting inside, so it can be moked:
> ===
>@Override
> protected RouteBuilder createRouteBuilder() {
> return new RouteBuilder() {
> public void configure() {
>
>
> from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:result");
> }
> };
> }
> 
> so the route is defined exactly here, so it can be moked and get the
> endpoints.
>
> BUT, what about to test an allready created route?
> I can't say .to("mock:result");
>
> i suposed it should be:
>
> =
>  @Override
> protected RouteBuilder createRouteBuilder() {
> return new MyRouteBuilder();
> }
> ==
>
>
> So my questions are:
> 1. how can i test a route? (i can't define the rules of routing inside the
> test class by overwriting the createRouteBuilder() , because i already have
> the route implementation => duplicate code)
> 2. Should my MyRouteBuilder have specific methods implemented so i can mok
> it after in the test class?
> 3. is it there another way to test the output messages of a router besides
> Mok?
>   - I did it in one way, but i think is not the "correct" one:
>- In a Test Class, I've created a Connection factory to a
> jms
> queue and creating a context
>- I've added the desired route to be tested into the context
> (  context.addRoute(new MyRoutebuilder()))
>- Started the context (so my router is running in
> "backgroud" let s say)
>- i've put a message into the input queue of the router with
> another test Router (from file to queue)
>- i've taken the message from output queue of the router
> with
> a test router (From message to file)
>- compare the file with an expected one.
>
> But this is bad as concept for unit tests (let s say Junits), i think.
>
> 4. Do you a link, or something to a generic test example of a camel route?
>
> PS: Sorry if the are stupid questions
>
> Thanks,
> Vlad
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-testing-tp5736444.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta


Re: SEDA with PriorityBlockingQueue

2013-07-29 Thread Christian Posta
+1 ... good idea Claus


On Mon, Jul 29, 2013 at 4:32 PM, Raul Kripalani  wrote:

> +1. It would enable many interesting solutions.
> On 29 Jul 2013 15:48, "Christian Müller" 
> wrote:
>
> > +1
> >
> > Best,
> > Christian
> > Am 29.07.2013 11:00 schrieb "Claus Ibsen" :
> >
> > > Hi
> > >
> > > Yeah if you use java code and create the SedaEndpoints manually. You
> > > can pass in the queue instance of your choice.
> > >
> > > Though maybe we should have an interface for a queue factory so people
> > > can configure this once on the seda component once, and have it work
> > > out of the box?
> > >
> > >
> > > On Mon, Jul 29, 2013 at 10:52 AM, gquintana  >
> > > wrote:
> > > > Hi,
> > > >
> > > > Is it possible to configure a SEDA endpoint so as to handle
> priorities
> > > using
> > > > a PriorityBlockingQueue instead of LinkedBlockingQueue, and
> optionally
> > > > provide a Comparator to sort messages?
> > > >
> > > > Thanks,
> > > > Gérald
> > > >
> > > >
> > > >
> > > > --
> > > > View this message in context:
> > >
> >
> http://camel.465427.n5.nabble.com/SEDA-with-PriorityBlockingQueue-tp5736411.html
> > > > Sent from the Camel - Users mailing list archive at Nabble.com.
> > >
> > >
> > >
> > > --
> > > Claus Ibsen
> > > -
> > > Red Hat, Inc.
> > > Email: cib...@redhat.com
> > > Twitter: davsclaus
> > > Blog: http://davsclaus.com
> > > Author of Camel in Action: http://www.manning.com/ibsen
> > >
> >
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta


how to consume messages by timestamp

2013-07-29 Thread shin938
I have a simple route spring DSL ,activemq queue. I want to consume messages
that are 2 minutes old and more. what would be my best approach?



--
View this message in context: 
http://camel.465427.n5.nabble.com/how-to-consume-messages-by-timestamp-tp5736463.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: VM queue for 2 camel context

2013-07-29 Thread keesvandieren
Have the same need here:

We need to do transparent publish-subscribe from one producer to multiple
consumers across multiple war applications in one container.

The problem I am facing: only the consumers of one of the wars is notified,
never consumers of both wars are notified.

Is this supported by the VM component? If not, what alternate component is
recommended to use?

More details:
I have created a test-project:
https://github.com/keesvandieren/camel-wicket-atmosphere, which shows the
problem. Readme.txt describes how to run the project and see only war being
notified.

Thanks in advance for your time.



--
View this message in context: 
http://camel.465427.n5.nabble.com/VM-queue-for-2-camel-context-tp5485770p5736464.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: best practice for logging execution time

2013-07-29 Thread salemi
I like to identify the average execution time spent in Camel. I have a
aggregator that aggregate 10 messages before it send them out to the
endpoint.
Would EventNotifier still work?



-
Alireza Salemi
--
View this message in context: 
http://camel.465427.n5.nabble.com/best-practice-for-logging-execution-time-tp2844045p5736458.html
Sent from the Camel - Users mailing list archive at Nabble.com.


AW: Camel testing

2013-07-29 Thread jhm
And the configure()-methode in the test class just returns a RouteBuilder.
It doesn't have to return a new created one ...

public class MyTest extends CamelTestSupport {
   @Override
   protected RouteBuilder createRouteBuilder() {
  RouteBuilder rb = new MyRouteBuilder();
  // adviceWith ...
  // "inject" new endpoint uris
  rb.setFromUri("direct:in");
  rb.setToDatabase("mock:db");
  return rb;
   }
}


Jan

> -Ursprüngliche Nachricht-
> Von: Christian Posta [mailto:christian.po...@gmail.com]
> Gesendet: Dienstag, 30. Juli 2013 05:10
> An: users@camel.apache.org
> Betreff: Re: Camel testing
> 
> So keep in mind that the "endpoints" to a route are just
> java.lang.String... So you can do:
> 
> String startRoute = "jms:incoming";
> String endRoute = "jms:outgoing";
> 
> from(startRoute)..to(endRoute)
> 
> And then have that string injectable, so you can do
> setEndRoute("mock:endpointName")...
> 
> But even if you don't want to do that, you can check out "adviceWith"
> which wraps the existing endpoint with interesting behavior, including
> mocking it out, and/or adding interceptors.
> 
> You should check out the doco at http://camel.apache.org/mock.html You
> can also check out this refcard that covers essential camel components,
> including the Mock component:
> http://refcardz.dzone.com/refcardz/essential-camel-components
> And lastly, but certainly not least.. the camel source code is packed
> with unit tests. There are no better examples than the unit tests from
> the camel code base:
> http://camel.apache.org/how-can-i-get-the-source-code.html
> 
> Cheers,
> Christian
> 
> 
> On Mon, Jul 29, 2013 at 9:15 AM, Costash 
> wrote:
> 
> > Hi,
> >
> > I've just started to use camel, and I'm trying to understand and
> > create some unit tests, but i don t understand how Mok is working or
> > how unit tests should look like (i've read the tutorials and
> > documentation about camel test).
> > What do i mean by not understanging is:
> >
> > i have a defined route:
> > =
> > public class MyRouteBuilder extends RouteBuilder{ .
> > @Override
> > public void configure() throws Exception {
> > from("jms:queue:inputQueueName").process(new Processor()
> > {.}).to("jms:queue:outputputQueueName");
> > ==
> >
> > in all the examples found , a new Class extends CamelTestSupport {
> >
> > and also creating the rounting inside, so it can be moked:
> > ===
> >@Override
> > protected RouteBuilder createRouteBuilder() {
> > return new RouteBuilder() {
> > public void configure() {
> >
> >
> >
> from("direct:start").filter(header("foo").isEqualTo("bar")).to("mock:re
> sult");
> > }
> > };
> > }
> > 
> > so the route is defined exactly here, so it can be moked and get the
> > endpoints.
> >
> > BUT, what about to test an allready created route?
> > I can't say .to("mock:result");
> >
> > i suposed it should be:
> >
> > =
> >  @Override
> > protected RouteBuilder createRouteBuilder() { return new
> > MyRouteBuilder(); } ==
> >
> >
> > So my questions are:
> > 1. how can i test a route? (i can't define the rules of routing
> inside
> > the test class by overwriting the createRouteBuilder() , because i
> > already have the route implementation => duplicate code) 2. Should my
> > MyRouteBuilder have specific methods implemented so i can mok it
> after
> > in the test class?
> > 3. is it there another way to test the output messages of a router
> > besides Mok?
> >   - I did it in one way, but i think is not the "correct" one:
> >- In a Test Class, I've created a Connection factory
> to
> > a jms queue and creating a context
> >- I've added the desired route to be tested into the
> > context (  context.addRoute(new MyRoutebuilder()))
> >- Started the context (so my router is running in
> > "backgroud" let s say)
> >- i've put a message into the input queue of the
> router
> > with another test Router (from file to queue)
> >- i've taken the message from output queue of the
> > router with a test router (From message to file)
> >- compare the file with an expected one.
> >
> > But this is bad as concept for unit tests (let s say Junits), i
> think.
> >
> > 4. Do you a link, or something to a generic test example of a camel
> route?
> >
> > PS: Sorry if the are stupid questions
> >
> > Thanks,
> > Vlad
> >
> >
> >
> > --
> > View this message in context:
> > http://camel.465427.n5.nabble.com/Camel-testing-tp5736444.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
> >
> 
> 
> 
> --
> *Christian Posta*
> http://www.christianposta.com/blog
> twitter: @christianposta



Re: VM queue for 2 camel context

2013-07-29 Thread nirro
You can try embedded ActiveMQ broker with "VM connector" (i.e.vm://default)
to organize cross war communication. It's a heavier than VM component, but
much powerful solution.


2013/7/30 keesvandieren [via Camel] 

> Have the same need here:
>
> We need to do transparent publish-subscribe from one producer to multiple
> consumers across multiple war applications in one container.
>
> The problem I am facing: only the consumers of one of the wars is
> notified, never consumers of both wars are notified.
>
> Is this supported by the VM component? If not, what alternate component is
> recommended to use?
>
> More details:
> I have created a test-project:
> https://github.com/keesvandieren/camel-wicket-atmosphere, which shows the
> problem. Readme.txt describes how to run the project and see only war being
> notified.
>
> Thanks in advance for your time.
>
> --
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://camel.465427.n5.nabble.com/VM-queue-for-2-camel-context-tp5485770p5736464.html
>  To unsubscribe from VM queue for 2 camel context, click 
> here
> .
> NAML
>



-- 
С уважением,
Станислав Тюриков.




--
View this message in context: 
http://camel.465427.n5.nabble.com/VM-queue-for-2-camel-context-tp5485770p5736466.html
Sent from the Camel - Users mailing list archive at Nabble.com.