ActiveMQ - 客户端已连接相同的clientId错误

时间:2017-03-09 14:08:04

标签: jboss jms activemq message-driven-bean durable-subscription

我们设置了JBoss EAP 7.0.0.GA连接到ActivMQ apache-activemq-5.14.3。我们正尝试使用以下配置设置持久订户:

@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")

但是,我们在JBoss服务器控制台中得到以下异常

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

同时,如果我们在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

ActiveMQManagedConnectionFactory设置如下(尝试将max-pool-size设置为1,但没有效果):

/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)

请AMQ专家寻求帮助。

2 个答案:

答案 0 :(得分:0)

只有这样我才能让AMQ和jboss在没有一千个线程做蠢事的情况下运行,就是使用嵌入式代理设置RAR,然后将嵌入式代理与外部代理进行网络连接。

答案 1 :(得分:-1)

也许,更改您的属性/配置可以解决您的问题。 例如,尝试使用以下配置更改客户端ID:

<?php
include("functions/connect.php");

$db_conn = new Database();
if($db_conn->connect()) {
  echo "Database connected";
}

这将确保您的clientId是唯一的