Я сейчас прохожу похожие (http://activemq.2283324.n4.nabble.com/Sporadic-quot-Error-while-attempting-to-add-new-Connection-to-the-pool-nested-exception-is-javax-jms-td4741737.html) проблемы).
ActiveMQ version: 5.15.4
Environment: Windows
Karaf Version: 4.2.0
Я использую ActiveMQ и Apache Karaf с верблюдом и pax-jms. Несколько караф
экземпляры используют этот один экземпляр брокера. Мои экземпляры Карафа
установлен как сервис, как и ActiveMQ.
Вот так выглядит мой конфиг:
name=db-consumer
jms.url=tcp://localhost:61616
jms.username=<user>
jms.password=<password>
type=activemq
osgi.jndi.service.name=jms/consumer
Снова и снова, с высокой частотой данных, я получаю следующее
ошибка:
исключение без категории при обработке JMS; вложенными
исключение: javax.jms.JMSException: не удалось подключиться к URL-адресу брокера:
TCP: // локальный: 61616. Причина: java.net.BindException: Адрес уже
используется: подключите
Нужно ли настраивать что-то конкретное в брокере или в
Конфигурация для решения этой проблемы?
Я пытался pool=transx
, но голодает для транса.
Я видел, что есть похожая запись ( ActiveMQ выдает: «Не удалось подключиться к URL-адресу брокера: tcp: // localhost: 61616» после примерно 10 000 сообщений ) в stackoverflow, но это кажется быть проблемой весной. Я ищу решение в osgi с pax-jms.
- Обновление 1: добавлен дамп ошибки -
org.springframework.jms.UncategorizedJmsException: Uncategorized exception occurred during JMS processing; nested exception is javax.jms.JMSException: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.BindException: Address already in use: connect
at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:316) ~[115:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:169) ~[115:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:487) ~[115:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.send(JmsConfiguration.java:516) ~[52:org.apache.camel.camel-jms:2.20.3]
at org.apache.camel.component.jms.JmsProducer.doSend(JmsProducer.java:440) ~[52:org.apache.camel.camel-jms:2.20.3]
at org.apache.camel.component.jms.JmsProducer.processInOnly(JmsProducer.java:394) ~[52:org.apache.camel.camel-jms:2.20.3]
at org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:157) ~[52:org.apache.camel.camel-jms:2.20.3]
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148) ~[51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) ~[51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:138) ~[51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:101) [51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.FatalFallbackErrorHandler.process(FatalFallbackErrorHandler.java:82) [51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.RedeliveryErrorHandler.deliverToFailureProcessor(RedeliveryErrorHandler.java:1063) [51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:474) [51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:138) [51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:101) [51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62) [51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148) [51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) [51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:117) [51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) [51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:138) [51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:101) [51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) [51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97) [51:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:112) [52:org.apache.camel.camel-jms:2.20.3]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:719) [115:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:679) [115:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:649) [115:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:317) [115:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:255) [115:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1166) [115:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1158) [115:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1055) [115:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: javax.jms.JMSException: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.BindException: Address already in use: connect
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:36) ~[?:?]
at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:374) ~[?:?]
at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:304) ~[?:?]
at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:244) ~[?:?]
at org.ops4j.pax.jms.activemq.ActiveMQConnectionFactoryFactory$1.createConnection(ActiveMQConnectionFactoryFactory.java:52) ~[?:?]
at Proxy907e4baf_5e06_4932_b3c9_aebc6215955c.createConnection(Unknown Source) ~[?:?]
at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:180) ~[?:?]
at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:474) ~[?:?]
... 38 more
Caused by: java.net.BindException: Address already in use: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[?:?]
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) ~[?:?]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[?:?]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[?:?]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[?:?]
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) ~[?:?]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[?:?]
at java.net.Socket.connect(Socket.java:589) ~[?:?]
at org.apache.activemq.transport.tcp.TcpTransport.connect(TcpTransport.java:525) ~[?:?]
at org.apache.activemq.transport.tcp.TcpTransport.doStart(TcpTransport.java:488) ~[?:?]
at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:55) ~[?:?]
at org.apache.activemq.transport.AbstractInactivityMonitor.start(AbstractInactivityMonitor.java:169) ~[?:?]
at org.apache.activemq.transport.InactivityMonitor.start(InactivityMonitor.java:52) ~[?:?]
at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:64) ~[?:?]
at org.apache.activemq.transport.WireFormatNegotiator.start(WireFormatNegotiator.java:72) ~[?:?]
at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:64) ~[?:?]
at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:64) ~[?:?]
at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:354) ~[?:?]
at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:304) ~[?:?]
at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:244) ~[?:?]
at org.ops4j.pax.jms.activemq.ActiveMQConnectionFactoryFactory$1.createConnection(ActiveMQConnectionFactoryFactory.java:52) ~[?:?]
at Proxy907e4baf_5e06_4932_b3c9_aebc6215955c.createConnection(Unknown Source) ~[?:?]
at org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:180) ~[?:?]
at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:474) ~[?:?]
... 38 more
Обновление
Людям, которые могут столкнуться с этой проблемой, не забудьте использовать пул соединений на стороне клиента. Я использовал Camel Bundles. И переключение на пул соединений может не работать на лету. Перезапустите посредник и перезапустите экземпляры, чтобы увидеть эффект. Я предполагаю, что происходит какое-то кэширование соединения, из-за которого я не смог сразу увидеть изменения.
Версия конфигурации пула соединений pax-jms выглядит следующим образом:
name=db-consumer
jms.url=tcp://localhost:61616
jms.username=<user>
jms.password=<password>
type=activemq
pool=pooledjms
osgi.jndi.service.name=jms/consumer
Я мог бы также попробовать transx pool, но pooledjms был самым простым и он подходит для моих требований.