Re: consumer count not coming down when there is no load with Activemq and camel

2020-02-09 Thread sujin sr
Can anyone help me with this, please?

On Fri, 7 Feb 2020 at 13:31, sujin sr  wrote:

> I have a route which read messages from an ActiveMQ queue and writes to
> another queue.
> When message load increases consumers count reaching
> maxConcurrentConsumers value but when message load decreases or producer
> stopped then consumer count not coming down to idleConsumerLimit value.
> I am using Spring Jndi to connect ActiveMQ
>
> Here is the Route
> 
>
> 
> 
> 
> 
>
> and Bean configuration
> 
> 
>
> 
> 
>  key="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory
> tcp://localhost:61616
> 
> 
> 
>
>  class="org.springframework.jndi.JndiObjectFactoryBean">
> 
> 
> 
>
> 
> 
> 
> 
> 
> 
>
> 
>
> Kindly advise on this.
>
> Thanks.
>
>
>
>
>
>


consumer count not coming down when there is no load with Activemq and camel

2020-02-07 Thread sujin sr
I have a route which read messages from an ActiveMQ queue and writes to
another queue.
When message load increases consumers count reaching maxConcurrentConsumers
value but when message load decreases or producer stopped then consumer
count not coming down to idleConsumerLimit value.
I am using Spring Jndi to connect ActiveMQ

Here is the Route







and Bean configuration





org.apache.activemq.jndi.ActiveMQInitialContextFactory
tcp://localhost:61616


















Kindly advise on this.

Thanks.


Re: configuration value not injected for custom processor id

2019-09-23 Thread sujin sr
Hi Jan Bednář,

I have done typo error while posting the question in the forum,
In actual code i have used {{sample.route.myroute.processor.myprocessorid}}
but it was not working.

The code snippet I have posted was a sample of actual code.


On Tue, 24 Sep 2019 at 01:06, Jan Bednář  wrote:

> Hi,
> you have probably meant to use
> {{sample.route.myroute.processor.myprocessorid}}
>
> Dne 23.9.2019 v 14:30 sujin sr napsal(a):
> > Hi,
> >
> > I have a .yml file where all the route information has been defined, i
> have
> > injected the value into the route. But injected value has been applied
> for
> > route id and autostartup but value not has been applied for custom
> > processor id. I am using springboot to start the camel context
> >
> > example route:
> >  > autoStartup="{{sample.route.myroute.autostart:true}}">
> >  
> >   > ref="mySampleProcessor"/>
> >  
> > 
> > 
> >
> > In this route value has been applied for  sample.route.myroute.id and
> > sample.route.myroute.autostart but  value for
> > sample.route.myroute.myprocessorid not injected.
> >
> > example yml file
> > sample:
> >route:
> >  myroute:
> >  id: myrouteId
> >  processor:
> >myprocessorid: mySampleProcessor
> >secondprocessor: mysecondProcessor
> >
> > Kindly help me with this !!!
> >
>
>


configuration value not injected for custom processor id

2019-09-23 Thread sujin sr
Hi,

I have a .yml file where all the route information has been defined, i have
injected the value into the route. But injected value has been applied for
route id and autostartup but value not has been applied for custom
processor id. I am using springboot to start the camel context

example route:







In this route value has been applied for  sample.route.myroute.id and
sample.route.myroute.autostart but  value for
sample.route.myroute.myprocessorid not injected.

example yml file
sample:
  route:
myroute:
id: myrouteId
processor:
  myprocessorid: mySampleProcessor
  secondprocessor: mysecondProcessor

Kindly help me with this !!!


Re: InOut exchange pattern on Transactional JMS endpoint not working

2019-08-07 Thread sujin sr
Hi  Claus  Ibsen ,

Could you please provide some input on the previous queries?

Thanks.

On Wed, 7 Aug 2019 at 13:07, sujin sr  wrote:

> Thanks Claus Ibsen for the response.
>
> So If I process replyQueue via a separate route I am wondering about the
> below two points
>   1. How I can transfer requestMessage headers values to the replyMessage
> headers.
>   2. I want to get the replyMessages only send from my producer alone, how
> to listen on specific correlation ids using camel approach.
>   This use case will occur when the same request/reply queue can have
> other jms producers and consumers.
>
> Kindly suggest some ideas.
>
>
> On Wed, 7 Aug 2019 at 12:55, Claus Ibsen  wrote:
>
>> Hi
>>
>> You cannot do request/reply via reply queues with InOut and with
>> transactions as its a chicken/egg situation.
>> The message that is sent to the request queue (for req/reply) is not
>> committed until the transaction is committed and therefore the
>> received cannot "see" the message.
>>
>> On Wed, Aug 7, 2019 at 9:05 AM sujin sr  wrote:
>> >
>> > Hi,
>> >
>> > I have a use case where two jms queues are available those are
>> > DataRequestQueue and DataReplyQueue. Where If I sent a message to the
>> > DataRequestQueue MDB will process the message and send the response to
>> > DataReplyQueue.
>> >
>> > I have used Camel to send the message and receive the response. I have
>> used
>> > InOut Exchange pattern in camel to send and receive the response back.
>> >
>> > Jms endpoint I am using is Transactional JMS endpoint, transaction
>> manager
>> > configured in spring bean.
>> >
>> >
>> .to("jms:queue:DataRequestQueue?replyTo=DataReplyQueue=InOut=60s")
>> >
>> >
>> > When I try to send the message to the request queue using InOut exchange
>> > camel throw ExchangeTimedOutException, but if I remove transaction
>> manager
>> > from the spring bean it working fine I able to get the response in the
>> > reply queue.
>> > I have also tried to create a separate jms component bean without
>> > transaction manager for InOut exchange alone but it was also not
>> working.
>> >
>> > Kindly suggest some idea to make the camel route work fine.
>> >
>> >
>> https://access.redhat.com/documentation/en-us/red_hat_jboss_fuse/6.3/html/transaction_guide/fmrtxnjmssynchronous
>> >
>> >
>> > This article suggested to use a separate queue for request and response,
>> > but I cannot split the route and make the route async.
>> >
>> > Thanks.
>>
>>
>>
>> --
>> Claus Ibsen
>> -
>> http://davsclaus.com @davsclaus
>> Camel in Action 2: https://www.manning.com/ibsen2
>>
>


Re: InOut exchange pattern on Transactional JMS endpoint not working

2019-08-07 Thread sujin sr
Thanks Claus Ibsen for the response.

So If I process replyQueue via a separate route I am wondering about the
below two points
  1. How I can transfer requestMessage headers values to the replyMessage
headers.
  2. I want to get the replyMessages only send from my producer alone, how
to listen on specific correlation ids using camel approach.
  This use case will occur when the same request/reply queue can have
other jms producers and consumers.

Kindly suggest some ideas.


On Wed, 7 Aug 2019 at 12:55, Claus Ibsen  wrote:

> Hi
>
> You cannot do request/reply via reply queues with InOut and with
> transactions as its a chicken/egg situation.
> The message that is sent to the request queue (for req/reply) is not
> committed until the transaction is committed and therefore the
> received cannot "see" the message.
>
> On Wed, Aug 7, 2019 at 9:05 AM sujin sr  wrote:
> >
> > Hi,
> >
> > I have a use case where two jms queues are available those are
> > DataRequestQueue and DataReplyQueue. Where If I sent a message to the
> > DataRequestQueue MDB will process the message and send the response to
> > DataReplyQueue.
> >
> > I have used Camel to send the message and receive the response. I have
> used
> > InOut Exchange pattern in camel to send and receive the response back.
> >
> > Jms endpoint I am using is Transactional JMS endpoint, transaction
> manager
> > configured in spring bean.
> >
> >
> .to("jms:queue:DataRequestQueue?replyTo=DataReplyQueue=InOut=60s")
> >
> >
> > When I try to send the message to the request queue using InOut exchange
> > camel throw ExchangeTimedOutException, but if I remove transaction
> manager
> > from the spring bean it working fine I able to get the response in the
> > reply queue.
> > I have also tried to create a separate jms component bean without
> > transaction manager for InOut exchange alone but it was also not working.
> >
> > Kindly suggest some idea to make the camel route work fine.
> >
> >
> https://access.redhat.com/documentation/en-us/red_hat_jboss_fuse/6.3/html/transaction_guide/fmrtxnjmssynchronous
> >
> >
> > This article suggested to use a separate queue for request and response,
> > but I cannot split the route and make the route async.
> >
> > Thanks.
>
>
>
> --
> Claus Ibsen
> -
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>


InOut exchange pattern on Transactional JMS endpoint not working

2019-08-07 Thread sujin sr
Hi,

I have a use case where two jms queues are available those are
DataRequestQueue and DataReplyQueue. Where If I sent a message to the
DataRequestQueue MDB will process the message and send the response to
DataReplyQueue.

I have used Camel to send the message and receive the response. I have used
InOut Exchange pattern in camel to send and receive the response back.

Jms endpoint I am using is Transactional JMS endpoint, transaction manager
configured in spring bean.

.to("jms:queue:DataRequestQueue?replyTo=DataReplyQueue=InOut=60s")


When I try to send the message to the request queue using InOut exchange
camel throw ExchangeTimedOutException, but if I remove transaction manager
from the spring bean it working fine I able to get the response in the
reply queue.
I have also tried to create a separate jms component bean without
transaction manager for InOut exchange alone but it was also not working.

Kindly suggest some idea to make the camel route work fine.

https://access.redhat.com/documentation/en-us/red_hat_jboss_fuse/6.3/html/transaction_guide/fmrtxnjmssynchronous


This article suggested to use a separate queue for request and response,
but I cannot split the route and make the route async.

Thanks.


Re: ClassCast Exception while using nested split

2019-07-26 Thread sujin sr
Thanks Claus. After adding end before endchoice my route is working now.

.to("stream:out")
.end()
.endChoice()

My understanding about end & endchoice is that, end() will close the
choice() clause, endchoice() will close the when() clause. Then why do
we need another end() before endChoice in 2 split?

Correct me if my understanding is wrong.


On Fri, 26 Jul 2019 at 14:23, Claus Ibsen  wrote:

> You have 2 splits, so you need and end before the end choice
>
> On Fri, Jul 26, 2019 at 10:51 AM sujin sr  wrote:
> >
> > I am getting ClassCastException while trying to execute camel route
> >
> > from("timer://messageSplitterTest?repeatCount=1")
> > .process(exchange -> {
> > Message message = exchange.getMessage();
> > List ongoingMessages = new ArrayList<>();
> > for (int i = 0; i < 10; i++) {
> > Message listMessage = message.copy();
> > listMessage.setHeader("count", String.valueOf(i));
> > ongoingMessages.add(listMessage);
> > }
> > exchange.getIn().setBody(ongoingMessages);
> > exchange.getIn().setHeader("primary", "true");
> > })
> > .choice()
> > .when(header("primary").isEqualTo("true"))
> > .split(body())
> > .process(exchange -> {
> > Message msg = exchange.getMessage();
> > System.out.println("After Split, count=" +
> > msg.getHeader("count", String.class));
> > })
> > .split(body())
> > .to("stream:out")
> > .endChoice()
> > .otherwise()
> > .to("stream:out")
> > .end()
> > ;
> >
> > I got below error
> >
> > Exception in thread "main" java.lang.ClassCastException:
> > org.apache.camel.model.SplitDefinition cannot be cast to
> > org.apache.camel.model.ChoiceDefinition
> > at
> org.apache.camel.model.ProcessorDefinition.endChoice(ProcessorDefinition.java:1415)
> > at
> com.temenos.tti.test.utils.camel.MessageSplitCamelTest4$1.configure(MessageSplitCamelTest4.java:40)
> >
> >
> > Kindly Help me to fix this error.
>
>
>
> --
> Claus Ibsen
> -
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>


ClassCast Exception while using nested split

2019-07-26 Thread sujin sr
I am getting ClassCastException while trying to execute camel route

from("timer://messageSplitterTest?repeatCount=1")
.process(exchange -> {
Message message = exchange.getMessage();
List ongoingMessages = new ArrayList<>();
for (int i = 0; i < 10; i++) {
Message listMessage = message.copy();
listMessage.setHeader("count", String.valueOf(i));
ongoingMessages.add(listMessage);
}
exchange.getIn().setBody(ongoingMessages);
exchange.getIn().setHeader("primary", "true");
})
.choice()
.when(header("primary").isEqualTo("true"))
.split(body())
.process(exchange -> {
Message msg = exchange.getMessage();
System.out.println("After Split, count=" +
msg.getHeader("count", String.class));
})
.split(body())
.to("stream:out")
.endChoice()
.otherwise()
.to("stream:out")
.end()
;

I got below error

Exception in thread "main" java.lang.ClassCastException:
org.apache.camel.model.SplitDefinition cannot be cast to
org.apache.camel.model.ChoiceDefinition
at 
org.apache.camel.model.ProcessorDefinition.endChoice(ProcessorDefinition.java:1415)
at 
com.temenos.tti.test.utils.camel.MessageSplitCamelTest4$1.configure(MessageSplitCamelTest4.java:40)


Kindly Help me to fix this error.


Re: JMS Transaction rollback with dead letter channel using Apache Camel

2019-06-26 Thread sujin sr
Hi,

I have tried with OnException and doTry/doCatch error handler still I am
getting the same behaviour as message sends to JMS_ONE.

error handler


java.lang.RuntimeException
java.lang.IllegalArgumentException

true












I have tried with adding rollback in error handler, in that case message
not written to JMS_ONE queue, it has redelivered message to source queue
JMS_IN for some count but finally, it has not sent the message to ERROR.

Kindly advise if I miss anything!!!


On Wed, 26 Jun 2019 at 13:25, Claus Ibsen  wrote:

> Hi
>
> You are using dead letter channel as Camel's error handler which will
> mark the message as succesfull.
> Just use a regular error handler
>
> On Wed, Jun 26, 2019 at 9:50 AM sujin sr  wrote:
> >
> > Thanks for the Response.
> >
> > Before implementing 'transacted JMS acknowledge' i have tried to create
> > separate JMS component for ERROR. But still, I see the same behaviour as
> > message sent to the JMS_ONE not rollbacked
> >
> > I have added this beans and changed ERROR route like below
> >
> >  > class="org.apache.camel.component.jms.JmsConfiguration">
> > 
> > 
> >
> > 
> > 
> > 
> >
> >
> > 
> > 
> > 
> > 
> > 
> > 
> >
> > Where i am missing anything here, kindly advise
> >
> >
> >
> > On Wed, 26 Jun 2019 at 12:51, Claus Ibsen  wrote:
> >
> > > Hi
> > >
> > > Its likely better to use just the brokers error handling with
> > > transaction (transacted JMS acknowledge).
> > > Then you can configure the broker with redelivery and its dead letter
> > > queue.
> > > Then you dont need any Camel error handler, and only need to setup JMS
> > > component for transacted JMS ack mode.
> > >
> > > Otherwise in your use case, you cannot both rollback sending to ONE
> > > and TWO but send to ERROR as they are all in the same transaction.
> > > So in this example you need to setup a 2nd JMS component for ERROR, so
> > > the JMS can rollback, and ERROR can commit. Also mind that the
> > > incoming endpoint is also JMS and it will also rollback as part of ONE
> > > and TWO. So you will get the message redelibered again from the
> > > broker.
> > >
> > > So try instead to just use broker error handling.
> > >
> > >
> > >
> > >
> > > On Wed, Jun 26, 2019 at 9:01 AM sujin sr  wrote:
> > > >
> > > > I am facing a issue while trying to implement JMS transaction using
> > > Camel.
> > > >
> > > > Here is the scenario
> > > >
> > > > 1. Primary route which read the message from the queue(JMS_IN), pass
> the
> > > > same exchange to the two sub route(direct route)
> > > > 2. First sub route process the message successfully and send to the
> > > another
> > > > queue(JMS_ONE)
> > > > 3. Second sub route process the message and send to the another
> > > > queue(JMS_TWO).
> > > > 4. If any error occurred during the sub route processing all the
> message
> > > > should rollback and original message sent to another queue(ERROR)
> that is
> > > > dead letter queue.
> > > > 5. In the example Context I have created throw RuntimeException
> during
> > > > second sub route processing.
> > > > 6. So expected behavior is to move the original message to ERROR
> queue,
> > > > same time no message should send to JMS_ONE & JMS_TWO
> > > > 7. But actual behavior is original message was sent to the ERROR
> queue,
> > > but
> > > > message sent the JMS_ONE.
> > > >
> > > > I am using Apache Camel 2.24.0, Jboss HornetQ and spring transaction
> > > > manager.
> > > >
> > > > Kindly help me on this, I am struck at this for couple of days
> > > >
> > > > Camel Context Below
> > > >
> > > >  class="org.springframework.jndi.JndiTemplate">
> > > > 
> > > > 
> > > >  > > >
> > >
> key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory
> > > > 

Re: JMS Transaction rollback with dead letter channel using Apache Camel

2019-06-26 Thread sujin sr
Thanks for the Response.

Before implementing 'transacted JMS acknowledge' i have tried to create
separate JMS component for ERROR. But still, I see the same behaviour as
message sent to the JMS_ONE not rollbacked

I have added this beans and changed ERROR route like below

















Where i am missing anything here, kindly advise



On Wed, 26 Jun 2019 at 12:51, Claus Ibsen  wrote:

> Hi
>
> Its likely better to use just the brokers error handling with
> transaction (transacted JMS acknowledge).
> Then you can configure the broker with redelivery and its dead letter
> queue.
> Then you dont need any Camel error handler, and only need to setup JMS
> component for transacted JMS ack mode.
>
> Otherwise in your use case, you cannot both rollback sending to ONE
> and TWO but send to ERROR as they are all in the same transaction.
> So in this example you need to setup a 2nd JMS component for ERROR, so
> the JMS can rollback, and ERROR can commit. Also mind that the
> incoming endpoint is also JMS and it will also rollback as part of ONE
> and TWO. So you will get the message redelibered again from the
> broker.
>
> So try instead to just use broker error handling.
>
>
>
>
> On Wed, Jun 26, 2019 at 9:01 AM sujin sr  wrote:
> >
> > I am facing a issue while trying to implement JMS transaction using
> Camel.
> >
> > Here is the scenario
> >
> > 1. Primary route which read the message from the queue(JMS_IN), pass the
> > same exchange to the two sub route(direct route)
> > 2. First sub route process the message successfully and send to the
> another
> > queue(JMS_ONE)
> > 3. Second sub route process the message and send to the another
> > queue(JMS_TWO).
> > 4. If any error occurred during the sub route processing all the message
> > should rollback and original message sent to another queue(ERROR) that is
> > dead letter queue.
> > 5. In the example Context I have created throw RuntimeException during
> > second sub route processing.
> > 6. So expected behavior is to move the original message to ERROR queue,
> > same time no message should send to JMS_ONE & JMS_TWO
> > 7. But actual behavior is original message was sent to the ERROR queue,
> but
> > message sent the JMS_ONE.
> >
> > I am using Apache Camel 2.24.0, Jboss HornetQ and spring transaction
> > manager.
> >
> > Kindly help me on this, I am struck at this for couple of days
> >
> > Camel Context Below
> >
> > 
> > 
> > 
> >  >
> key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory
> >  > key="java.naming.provider.url">http-remoting://localhost:9089
> > 
> > TESTUSR
> >  key="java.naming.security.credentials">TESTUSR
> > 
> > 
> > 
> >
> >  class="org.springframework.jms.core.JmsTemplate">
> > 
> > 
> >
> >  > class="org.springframework.jndi.JndiObjectFactoryBean">
> > 
> > 
> > 
> >
> >  > class="org.springframework.jms.connection.JmsTransactionManager">
> > 
> > 
> >
> >  > class="org.apache.camel.component.jms.JmsConfiguration">
> > 
> > 
> > 
> > 
> >
> > 
> > 
> > 
> >
> > 
> > 
> >  > class="com.test.DeadChannelTestProcessor"/>
> >
> >
> >  > class="org.apache.camel.builder.DeadLetterChannelBuilder">
> >  value="direct:dead_letter_channel"/>
> >  ref="myRedeliveryPolicyConfig"/>
> > 
> >
> >  > class="org.apache.camel.processor.RedeliveryPolicy">
> > 
> > 
> >
> > http://camel.apache.org/schema/spring;
> > errorHandlerRef="myDeadLetterErrorHandler">
> >
> > 
> > 
> > 
> > 
> > 
> > 
> >
> > 
> > 
> > 
> > 
> > 
> > 
> >
> > 
> > 
> > 
> > 
> > 
> > 
> >
> > 
> > 
> > 
> > 
> > 
> >
> > 
> >
> > Thanks!!!
>
>
>
> --
> Claus Ibsen
> -
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>


JMS Transaction rollback with dead letter channel using Apache Camel

2019-06-26 Thread sujin sr
I am facing a issue while trying to implement JMS transaction using Camel.

Here is the scenario

1. Primary route which read the message from the queue(JMS_IN), pass the
same exchange to the two sub route(direct route)
2. First sub route process the message successfully and send to the another
queue(JMS_ONE)
3. Second sub route process the message and send to the another
queue(JMS_TWO).
4. If any error occurred during the sub route processing all the message
should rollback and original message sent to another queue(ERROR) that is
dead letter queue.
5. In the example Context I have created throw RuntimeException during
second sub route processing.
6. So expected behavior is to move the original message to ERROR queue,
same time no message should send to JMS_ONE & JMS_TWO
7. But actual behavior is original message was sent to the ERROR queue, but
message sent the JMS_ONE.

I am using Apache Camel 2.24.0, Jboss HornetQ and spring transaction
manager.

Kindly help me on this, I am struck at this for couple of days

Camel Context Below




org.jboss.naming.remote.client.InitialContextFactory
http-remoting://localhost:9089

TESTUSR
TESTUSR









































http://camel.apache.org/schema/spring;
errorHandlerRef="myDeadLetterErrorHandler">






























Thanks!!!