Pavel Voronin
Pavel Voronin

Reputation: 14005

Is it possbile to have multiple instances of the service with the same clientId in ActiveMQ?

I've created a test with two consumers each using its own connection. I need to be sure that only one of them receives the message.

These consumers use the same clientId and name.

Whenever I set clientId for the second consumer I get the following exception:

Apache.NMS.InvalidClientIDException: Broker: localhost - Client: TwoDurableConsumers_SameConsumerNameAndCientId_OnlyOneReceivesMessageb9182d05-b1b4-46b0-afb0-074b52ad7071 already connected from tcp://0:0:0:0:0:0:0:1:58629 at Apache.NMS.ActiveMQ.Connection.CheckConnected() in c:\dev\NMS.ActiveMQ\src\main\csharp\Connection.cs:line 1041

TwoDurableConsumers_SameConsumerNameAndCientId_OnlyOneReceivesMessageb9182d05-b1b4-46b0-afb0-074b52ad7071 is both clientId and durable subscriber name.

Upvotes: 0

Views: 1105

Answers (1)

Tim Bish
Tim Bish

Reputation: 18376

You cannot have two clients with the same client ID which is what the error is telling you. The client ID is a unique identifier which works to prevent exactly what you are trying to do, so the answer is don't do that.

Upvotes: 1

Related Questions