views:

34

answers:

2

Hi,

I want to load balance JMS messages using message selectors.

A message has a property "EntitiyIX".

The selectors shall be like:

"EntitiyIX Modulus 2 == 0" ==> route to queue A
"EntitiyIX Modulus 2 != 0" ==> route to queue B

What's the operator to calculated the modulus in a JMS message selector?

Thanks, Alex

A: 

Assuming that the property is an integer, then I believe you could do

  • (EntityIX / 2) = ((EntityIX+1) / 2) -> route to A
  • (EntityIX / 2) != ((EntityIX+1) / 2) -> route to B
Robin
Means: there is no modulus operator?
Alex
Not that I can tell. It appears to only support basic operators (+ - * /). I don't have an environment to test with.
Robin
+1  A: 

According to the API (http://download.oracle.com/javaee/1.4/api/javax/jms/Message.html - scroll down to "Message Selectors") there isn't a modulus operator.

What @Robin suggested sounds right.

Eran Harel
+1: useful link!
Alex