ActiveMQ - client already connected with same clientId error

4.1k Views Asked by At

We have a setup of JBoss EAP 7.0.0.GA connecting to ActivMQ apache-activemq-5.14.3. We are trying to setup a durable subscriber with the following configuration:

@MessageDriven(
      name = "TestListener",
      activationConfig = {
        @ActivationConfigProperty(propertyName  = "destinationType",
                                      propertyValue = "javax.jms.Topic"),

        @ActivationConfigProperty(propertyName  = "subscriptionDurability",
                                      propertyValue = "Durable"),

        @ActivationConfigProperty(propertyName  = "subscriptionName",
              propertyValue = "subscriptionNameTest"),

        @ActivationConfigProperty(propertyName  = "clientId",
                                      propertyValue = "2"),

        @ActivationConfigProperty(propertyName  = "destination",
                                      propertyValue = "jms/testTopic")
      }
)
@PermitAll
@ResourceAdapter(value="activemq-rar.rar")

However, we are getting the following exception in the JBoss server console

ERROR [org.apache.activemq.ra.ActiveMQEndpointWorker] (default-threads - 4) Failed to connect to broker [tcp://127.0.0.1:61616?jms.rmIdFromConnectionId=true]: Broker: TestBroker    - Client: 2 already connected from tcp://127.0.0.1:64246: javax.jms.InvalidClientIDException: Broker: TestBroker - Client: 2 already connected from tcp://127.0.0.1:64246

At the same time if we see the following logs at the activmq :

WARN  | Failed to add Connection ID: 40600-51:1 due to javax.jms.InvalidClientIDException: Broker: TestBroker - Client: 2 already connected from tcp://127.0.0.1:64246 | org.apache.activemq.broker.TransportConnection | ActiveMQ Transport: tcp:///127.0.0.1:50170@61616

The ActiveMQManagedConnectionFactory settings are as follows (tried setting the max-pool-size to 1, but to no effect):

/subsystem=resource-adapters/resource-adapter=activemq-rar.rar/connection-definitions=ConnectionFactory:add(class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory", jndi-name="java:/MyConnectionFactory", enabled=true, min-pool-size=1, max-pool-size=20, pool-prefill=false, same-rm-override=false, recovery-username=ejb_user, recovery-password=xxxxx)

Request help from AMQ experts please.

2

There are 2 best solutions below

1
Yogesh King On

Perhaps, changing your property/configuration would solve your issue. Try for example to change your client id by using the following configuration:

@ActivationConfigProperty(propertyName="clientId", propertyValue = "2-${jboss.node.name}")

This will ensure that your clientId is unique

2
FredsterL On

only way I have been able to get AMQ and jboss to behave without a thousand threads doing stupid things is to setup the RAR with an embedded broker and then network connect the embedded broker with your external broker.