spring持久jms订阅服务器(不允许在已用连接上设置clientid)

mo49yndu  于 2021-07-14  发布在  Java
关注(0)|答案(1)|浏览(281)

我正在更新一个运行在tomee7到tomee8上的应用程序,在这个过程中,我们开始收到关于spring消息侦听器容器的错误。tomee 8运行apache active mq 5.16,其中tomee 7运行apache active mq 5.15.13。
在spring中,我们通过jndi查找获得连接工厂,jndi查找在tomee.xml中定义如下

<tomee>

  <Connector id="resources/jms/ConnectionFactory" type="javax.jms.ConnectionFactory">
      ResourceAdapter=ActiveMQResourceAdapter
      TransactionSupport xa
      PoolMaxSize 10
      PoolMinSize 0
      ConnectionMaxWaitMilliseconds 15000
      ConnectionMaxIdleMinutes 15
      MaxSessions=5
  </Connector>

  <Resource id="ActiveMQResourceAdapter" type="ActiveMQResourceAdapter">
      BrokerXmlConfig=xbean:file:conf/activemq.xml
      ServerUrl=tcp://localhost:61616
  </Resource>

</tomee>

在spring中,我们得到如下连接工厂

<jee:jndi-lookup id="jmsFactory" jndi-name="jms/ConnectionFactory" expected-type="javax.jms.ConnectionFactory" />

defaultmessagelistenercontainers配置如下

<jms:listener-container container-type="default" connection-factory="jmsFactory" client-id="clientId" cache="connection" destination-type="durableTopic" transaction-manager="transactionManager">
        <jms:listener id="responses" destination="response" ref="msgHandler" />
    </jms:listener-container>

在Tomee7上,所有这些都能正常工作,但是,现在我们已经移动到Tomee8,我们的defaultmessagelistenercontainers抛出了以下异常

[org.springframework.jms.listener.DefaultMessageListenerContainer] - Could not refresh JMS Connection for destination 'response' - retrying using FixedBackOff{interval=5000, currentAttempts=9, maxAttempts=unlimited}. Cause: Setting clientID on a used Connection is not allowed

很明显,我们正在做的更新是不正确的,用jta管理的事务配置具有持久主题的dmlc的正确方法是什么?

unguejic

unguejic1#

在进一步测试之后,我发现问题与tomee.xml中连接工厂配置的最大池大小有关。把这个数字提高一点,我就能克服这个问题。

相关问题