You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Christian Müller <ch...@gmail.com> on 2010/10/20 13:43:30 UTC
Camel-jms with ActiveMQ: loosing messages by using non persistent messaging
A few weeks ago, I started a thread on the Camel dev channel [1] about
loosing messages if I use non persistent messaging with ActiveMQ. The broker
shoot down, if the single, non persitent connection was closed and start the
broker again, if I open a new connection to it (I have to configure the
connection factory in another configuration file than the activeMQ
component, because this connection factory will be taken from the OSGI
registry in our deployment, but it not exist in our unit test):
{code:title=bundle-context.xml}
<bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="connectionFactory" ref="connectionFactory" />
</bean>
{code}
{code:title=bundle-context-test.xml}
<bean id="connectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL"
value="vm://localhost?broker.persistent=false&broker.useJmx=false" />
</bean>
{code}
{code}
2010-09-13 19:49:19,937 [main ] INFO BrokerService - ActiveMQ
5.3.1-fuse-02-00 JMS Message Broker (localhost) is starting
2010-09-13 19:49:20,234 [main ] INFO BrokerService - ActiveMQ
Message Broker (localhost,
ID:defm-ar063470-1372-1284400159969-0:0) is shutting down
...
2010-09-13 19:49:20,250 [main ] INFO BrokerService - ActiveMQ
5.3.1-fuse-02-00 JMS Message Broker (localhost) is starting
2010-09-13 19:49:20,281 [main ] INFO BrokerService - ActiveMQ
Message Broker (localhost,
ID:defm-ar063470-1372-1284400159969-0:1) is shutting down
{code}
I was wondering, because if I use the following configuration (only one
spring configuration file), it works:
{code:title=bundle-context.xml}
<bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL"
value="vm://localhost?broker.persistent=false&broker.useJmx=false" />
</bean>
{code}
So, I went a bit deeper in this and I realized, that in the first one use
the ActiveMQConnectionFactory and the second one the
PooledConnectionFactory. With this information, I changed my configuration
to also use the PooledConnectionFactory:
{code:title=bundle-context.xml}
<bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="connectionFactory" ref="connectionFactory" />
</bean>
{code}
{code:title=bundle-context-test.xml}
<bean id="connectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactory">
<constructor-arg
value="vm://localhost?broker.persistent=false&broker.useJmx=false"/>
</bean>
{code}
Yeah, and it works also... :-)
This means we can use non persistent messaging for our tests (with
exceptions for suspend-resume and durable topic tests).
I think this is also useful for the Camel tests, is it? I can do the
work....
[1]
http://camel.465427.n5.nabble.com/Camel-jms-and-ConsumerTemplate-cause-org-apache-activemq-transport-TransportDisposedIOException-Peerd-tp2838098p2838098.html
Regards,
Christian
Re: Camel-jms with ActiveMQ: loosing messages by using non persistent messaging
Posted by Christian Müller <ch...@gmail.com>.
Hello Willem,
thanks for sharing this.
Christian
Re: Camel-jms with ActiveMQ: loosing messages by using non persistent
messaging
Posted by Willem Jiang <wi...@gmail.com>.
Hi Christian,
Thanks for sharing this with the camel community.
It just rang the bell to remind me there is an explanation[1] for your
issue :)
BTW, for most camel jms test, we don't depends on the activemq-camel
component, I will give the CachingConnectionFactory a try.
[1]http://activemq.apache.org/jmstemplate-gotchas.html
On 10/20/10 7:43 PM, Christian Müller wrote:
> A few weeks ago, I started a thread on the Camel dev channel [1] about
> loosing messages if I use non persistent messaging with ActiveMQ. The broker
> shoot down, if the single, non persitent connection was closed and start the
> broker again, if I open a new connection to it (I have to configure the
> connection factory in another configuration file than the activeMQ
> component, because this connection factory will be taken from the OSGI
> registry in our deployment, but it not exist in our unit test):
>
> {code:title=bundle-context.xml}
> <bean id="activemq"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
> <property name="connectionFactory" ref="connectionFactory" />
> </bean>
> {code}
>
> {code:title=bundle-context-test.xml}
> <bean id="connectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">
> <property name="brokerURL"
> value="vm://localhost?broker.persistent=false&broker.useJmx=false" />
> </bean>
> {code}
>
> {code}
> 2010-09-13 19:49:19,937 [main ] INFO BrokerService - ActiveMQ
> 5.3.1-fuse-02-00 JMS Message Broker (localhost) is starting
> 2010-09-13 19:49:20,234 [main ] INFO BrokerService - ActiveMQ
> Message Broker (localhost,
> ID:defm-ar063470-1372-1284400159969-0:0) is shutting down
> ...
> 2010-09-13 19:49:20,250 [main ] INFO BrokerService - ActiveMQ
> 5.3.1-fuse-02-00 JMS Message Broker (localhost) is starting
> 2010-09-13 19:49:20,281 [main ] INFO BrokerService - ActiveMQ
> Message Broker (localhost,
> ID:defm-ar063470-1372-1284400159969-0:1) is shutting down
> {code}
>
> I was wondering, because if I use the following configuration (only one
> spring configuration file), it works:
>
> {code:title=bundle-context.xml}
> <bean id="activemq"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
> <property name="brokerURL"
> value="vm://localhost?broker.persistent=false&broker.useJmx=false" />
> </bean>
> {code}
>
> So, I went a bit deeper in this and I realized, that in the first one use
> the ActiveMQConnectionFactory and the second one the
> PooledConnectionFactory. With this information, I changed my configuration
> to also use the PooledConnectionFactory:
>
> {code:title=bundle-context.xml}
> <bean id="activemq"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
> <property name="connectionFactory" ref="connectionFactory" />
> </bean>
> {code}
>
> {code:title=bundle-context-test.xml}
> <bean id="connectionFactory"
> class="org.apache.activemq.pool.PooledConnectionFactory">
> <constructor-arg
> value="vm://localhost?broker.persistent=false&broker.useJmx=false"/>
> </bean>
> {code}
>
> Yeah, and it works also... :-)
> This means we can use non persistent messaging for our tests (with
> exceptions for suspend-resume and durable topic tests).
>
> I think this is also useful for the Camel tests, is it? I can do the
> work....
>
> [1]
> http://camel.465427.n5.nabble.com/Camel-jms-and-ConsumerTemplate-cause-org-apache-activemq-transport-TransportDisposedIOException-Peerd-tp2838098p2838098.html
>
> Regards,
> Christian
>
--
Willem
----------------------------------
Open Source Integration: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: http://twitter.com/willemjiang