You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Edwin <ed...@gmail.com> on 2012/04/21 16:28:48 UTC

Load Balancer EIP

Hi Folks,

I'm using the Load Balancer EIP in a current project with a sticky policy.
The load balancer receives messages and based on header values places the
message onto one of 5 jms queues.

The "happy path" is: the same messages are continuously received throughout
the day and messages are enqueued on the 5 jms queues 

A situation may arise where I will no longer receive a message with header
value = "foo" for a lengthy period of time. Previously when this message was
received the sticky load balancer sent the message to jms queue "A". Since
this message is no longer been received, no messages will be sent to queue
"A" anymore. If this happened, I would like to place queue "A" back as a
candidate with the sticky load balancer to receive new messages with a
different header type and maybe employ a least recently used policy for
removing messages on queue "A" in order to receive the new incoming
messages.

I'm wondering if there is anything out of the box with the load balancer
that could help me achieve this or something close?

Any insights into this would be great!

Thanks,
Edwin. 

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

Re: Load Balancer EIP

Posted by Edwin <ed...@gmail.com>.
No I never read that in the Camel documentation. 

I incorrectly assumed that was the behaviour. 

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

Re: Load Balancer EIP

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Apr 24, 2012 at 10:37 AM, Edwin <ed...@gmail.com> wrote:
> After looking at the StickyLoadBalancer, it seems that it creates a
> RoundRobinLoadBalancer under the hood.
>
> When all processors are in use, I was under the notion that the
> StickyLoadBalancer would select a processor based on a least recently used
> policy.
>

No have you read this somewhere in the Camel documentation?

You can build a custom load balancer, where you can build your own
algorithm to pick which processor to use.
And thus also keep track on usage of the processors, so you can pick
the LRU etc. Or whatever.



>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Load-Balancer-EIP-tp5656311p5661342.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Load Balancer EIP

Posted by Edwin <ed...@gmail.com>.
After looking at the StickyLoadBalancer, it seems that it creates a
RoundRobinLoadBalancer under the hood. 

When all processors are in use, I was under the notion that the
StickyLoadBalancer would select a processor based on a least recently used
policy.


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

Re: Load Balancer EIP

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Apr 23, 2012 at 12:35 PM, Edwin <ed...@gmail.com> wrote:
> Thanks for the response Claus
>
> I am assuming the load balancer EIP sticky implementation maintains state in
> memory to map between the correlation key and the processor. Is it possible
> to programatically purge/delete this mapping?
>

Ah yeah it does. See the source code for
org.apache.camel.processor.loadbalancer.StickyLoadBalancer
You can implement a custom load balancer (possible extending the
sticky) where you can add support
for purge/delete mappings.

We love contributions though, so you are welcome to improve the
existing out of the box load balancers.

It would also be nice if they are enlisted in JMX using specialize JMX
operations so you can gain insight
and also purge using JMX.



> Edwin
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Load-Balancer-EIP-tp5656311p5658910.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Load Balancer EIP

Posted by Edwin <ed...@gmail.com>.
Thanks for the response Claus

I am assuming the load balancer EIP sticky implementation maintains state in
memory to map between the correlation key and the processor. Is it possible
to programatically purge/delete this mapping?

Edwin

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

Re: Load Balancer EIP

Posted by Claus Ibsen <cl...@gmail.com>.
On Sat, Apr 21, 2012 at 4:28 PM, Edwin <ed...@gmail.com> wrote:
> Hi Folks,
>
> I'm using the Load Balancer EIP in a current project with a sticky policy.
> The load balancer receives messages and based on header values places the
> message onto one of 5 jms queues.
>
> The "happy path" is: the same messages are continuously received throughout
> the day and messages are enqueued on the 5 jms queues
>
> A situation may arise where I will no longer receive a message with header
> value = "foo" for a lengthy period of time. Previously when this message was
> received the sticky load balancer sent the message to jms queue "A". Since
> this message is no longer been received, no messages will be sent to queue
> "A" anymore. If this happened, I would like to place queue "A" back as a
> candidate with the sticky load balancer to receive new messages with a
> different header type and maybe employ a least recently used policy for
> removing messages on queue "A" in order to receive the new incoming
> messages.
>
> I'm wondering if there is anything out of the box with the load balancer
> that could help me achieve this or something close?
>
> Any insights into this would be great!
>

You can use a bean as the expression on the sticky load balancer.

You can keep that bean statefull, and then keep track how long time
since a "foo" was last seen.
And if it happens to be a long time, then you can use the A queue again.

When using the method call expression in Camel for the bean
expression, then Camel will create the bean instance
once, and thus you can store state.

Mind that for concurrency the state in the bean is shared, so you need
to take care for those situations.



> Thanks,
> Edwin.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Load-Balancer-EIP-tp5656311p5656311.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/