You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by k....@gmail.com on 2019/12/16 12:10:50 UTC

sjms2 + OSGi ConnectionFactory

Hi!

On camel-3.0.0 + karaf 4.2.7 + artemis 2.10.1
JMS ConnectionFactory is registered as a service
(javax.jms.ConnectionFactory) without pooling and passed as a blueprint
proxy into the sjms2 component.

XML:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
    <reference id="jms" interface="javax.jms.ConnectionFactory"
filter="(osgi.jndi.service.name=jmslocal)"/>
    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
        <route>
            <from uri="timer:example?period=10000" />
            <setBody><constant>Hello, world</constant></setBody>
            <to uri="sjms2:queue:example?connectionFactory=#jms" />
        </route>
    </camelContext>
</blueprint> 

And everything is fine, until the ConnectionFactory is unregistered and
registered again (due to configuration change, for example).
After that, following exception is thrown:
19:03:42.372 WARN [Camel (camel-47) thread #185 - timer://example] Error
processing exchange. Exchange[ID-KJCHERNOV-WIN-1576168069058-51-2]. Caused
by: [org.apache.camel.CamelExchangeException - Unable to complete sending
the JMS message. Exchange[ID-KJCHERNOV-WIN-1576168069058-51-2]. Caused by:
[javax.jms.IllegalStateException - Session is closed]]
org.apache.camel.CamelExchangeException: Unable to complete sending the JMS
message. Exchange[ID-KJCHERNOV-WIN-1576168069058-51-2]. Caused by:
[javax.jms.IllegalStateException - Session is closed]
        at
org.apache.camel.component.sjms.producer.InOnlyProducer.sendMessage(InOnlyPr
oducer.java:53) ~[!/:3.0.0]
        at
org.apache.camel.component.sjms.SjmsProducer.process(SjmsProducer.java:261)
~[!/:3.0.0]
        at
org.apache.camel.processor.SendProcessor.process(SendProcessor.java:134)
~[!/:3.0.0]
        at
org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$RedeliverySta
te.run(RedeliveryErrorHandler.java:476) ~[!/:3.0.0]
        at
org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(Default
ReactiveExecutor.java:185) [!/:3.0.0]
        at
org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultRea
ctiveExecutor.java:59) [!/:3.0.0]
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:87)
[!/:3.0.0]
        at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProce
ssor.java:228) [!/:3.0.0]
        at
org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsum
er.java:193) [!/:3.0.0]
        at
org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:75)
[!/:3.0.0]
        at java.util.TimerThread.mainLoop(Timer.java:556) [?:?]
        at java.util.TimerThread.run(Timer.java:506) [?:?]
Caused by: javax.jms.IllegalStateException: Session is closed
        at
org.apache.activemq.artemis.jms.client.ActiveMQSession.checkClosed(ActiveMQS
ession.java:1251) ~[!/:?]
        at
org.apache.activemq.artemis.jms.client.ActiveMQSession.createTextMessage(Act
iveMQSession.java:233) ~[!/:?]
        at
org.apache.camel.component.sjms.jms.JmsBinding.createJmsMessageForType(JmsBi
nding.java:530) ~[!/:3.0.0]
        at
org.apache.camel.component.sjms.jms.JmsBinding.createJmsMessage(JmsBinding.j
ava:470) ~[!/:3.0.0]
        at
org.apache.camel.component.sjms.jms.JmsBinding.makeJmsMessage(JmsBinding.jav
a:285) ~[!/:3.0.0]
        at
org.apache.camel.component.sjms.jms.JmsBinding.makeJmsMessage(JmsBinding.jav
a:226) ~[!/:3.0.0]
        at
org.apache.camel.component.sjms.producer.InOnlyProducer.sendMessage(InOnlyPr
oducer.java:50) ~[!/:3.0.0]
        ... 11 more

And it will never recover until restart of a bundle, as it caches the
Session object.

Is there anything I can do about it?

P.S.> camel-jms does not handle this either, though it's complaining about
closed service locator, which was probably garbage collected.

Thanks in advance,
Konstantin J. Chernov.