javax.jms.InvalidClientIDException: Broker: localhost - Client: FS_Proceduer 已经从 /127.0.0.1:port 连接

javax.jms.InvalidClientIDException: Broker: localhost - Client: FS_Proceduer already connected from /127.0.0.1:port

你如何解决这个 JMSException?谢谢!

代理:localhost - 客户端:FS_Proceduer 已连接

javax.jms.InvalidClientIDException: Broker: localhost - Client: FS_Proceduer already connected from /127.0.0.1:56556

这是通过这个方法触发的:

private void connectAndInitActiveMQ() throws JMSException{
        logger.debug("It's ready to connect to jms service");
        if(null != connection){
            try{
                logger.debug("Closing connection");
                connection.close();
            }catch(Exception e){
                logger.error(e.getMessage(), e);
            }
        }
        logger.debug("Creating a new connection");

        logger.debug("Is queueConnectionFactory null? "+(queueConnectionFactory==null));

        connection = queueConnectionFactory.createConnection();

        logger.debug("Is the new connection null? "+(connection==null));

        logger.debug("Starting the new connection");
        connection.start();

        logger.debug("Connected successfully: " + connection);

        session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
        queue = session.createQueue(queueName);
        messageProducer = session.createProducer(queue);
    }

是出厂问题吗?或者其他来源?

如果您将连接配置为具有相同的客户端 ID,则会出现此错误。 JMS 规范是明确的,在任何给定时间只有一个连接可以连接到具有相同客户端 ID 的远程,解析您的配置并且一切正常。