Pergunta

I have a Tibco EMS topic subscriber which I need to load balance among different instances. Each published message to the topic needs to be received by one (and only one) instance of each subscriber load balance group.

Just using global topics and balanced EMS connections (tcp://localhost:7222|tcp://localhost:7224) results in the same message received by all instances of each subscriber load balance group, producing duplicates.

Do you know any alternative for load balancing topic subscribers?

Foi útil?

Solução

You can:

A) Bridge the topic to a queue and reconfigure your subscribers to read from the queue. Queues behave differently to topics in that a message is only obtained by one subscriber rather than all.

B) Create a number of durable subscribers on the topic with selectors that divide messages between the durables. E.g. If a message has a property 'id' that is sequentially increasing:

create durable topic DURABLENAME1 selector="(id - 2 * (id / 2)) = 0"
create durable topic DURABLENAME2 selector="(id - 2 * (id / 2)) = 1"

The selector is just a modulo so half the messages will go on one durable, and half on the other.

Outras dicas

With EMS 8.0 new concept shared subscription is added with these only one subscription receives messages with the same subscription name go through the EMS user guide docs it may help you.

While both previous answers are valid, however the most natural approach would be to not use topics at all.

Using queues instead pf topics does the whole job (loadbalancing in round robin fashion).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top