You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by huntc <hu...@mac.com> on 2010/06/19 04:24:48 UTC

Problem with maintaining a JMS subscription after waking from sleep

Hi there,

I think this may be an Active/MQ issue, but I'm posting here too as it is
the Camel ActiveMQComponent that I'm using.


I have a broker on machine A that publishes a topic for machine B to
subscribe to. Machine A shuts down each night at 12am and powers up at 5am.
Machine B sleeps at 12am and wakes up at 5am (as distinct from powering
down/up; just in case this is relevant).

What I'm finding is that when machine B sleeps/wakes it does not appear to
be connected to the topic any longer. I have verified this by observing that
there is no ActiveMQ.Advisory.Consumer.Topic.&lt;topicname&gt; after about
12am (my Hyperic monitoring tool confirms this). In addition when I look at
the AMQ console on machine A after 5am, there is no connection for machine B
(where there was one the night before).

If I restart my subscriber application on machine B then all is again well.

I'm using AMQ v.5.3.1. In addition here is my Spring configuration for
subscribing for the topic:

  &lt;bean id="activeMQConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory"&gt;
    &lt;property name="brokerURL"
      value="tcp://192.168.1.13:61616" /&gt;
  &lt;/bean&gt;
  &lt;bean id="jms-receiver"
class="org.apache.activemq.camel.component.ActiveMQComponent"&gt;
    &lt;property name="connectionFactory" ref="activeMQConnectionFactory"
/&gt;
  &lt;/bean&gt;


Any ideas on what I may be able to do to circumvent the issue I'm seeing?

Kind regards,
Christopher
-- 
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-maintaining-a-JMS-subscription-after-waking-from-sleep-tp510193p510193.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with maintaining a JMS subscription after waking from sleep

Posted by huntc <hu...@mac.com>.
Hi Willem,


Willem.Jiang wrote:
> 
> Hi,
> 
> As Camel is used within ActiveMQ and ServiceMix, we can't just upgrade 
> Spring version in Camel.
> But there is spring3 profile in camel parent/pom.xml, you can build 
> camel with spring 3.0.3.RELEASE with that profile if you like.
> 
> 

Sounds to me that a few Apache projects need a strategy to move toward
Spring 3. We've got to upgrade sometime. 

Given the build profile you mention, how about releasing Camel as Spring 3,
but require that slower moving projects build their own distribution based
on Spring 2?
-- 
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-maintaining-a-JMS-subscription-after-waking-from-sleep-tp510193p510985.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with maintaining a JMS subscription after waking from sleep

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jun 23, 2010 at 4:01 PM, Willem Jiang <wi...@gmail.com> wrote:
> Hi,
>
> As Camel is used within ActiveMQ and ServiceMix, we can't just upgrade
> Spring version in Camel.
> But there is spring3 profile in camel parent/pom.xml, you can build camel
> with spring 3.0.3.RELEASE with that profile if you like.
>
> If you are using OSGi, camel also has a feature file (features-spring3.xml)
> which depends on Spring 3.x.
>

Yeah I think we will wait for Camel 3.0 to be JDK 1.6+ Spring 3.0+ as min.


> Willem
> ----------------------------------
> Apache Camel, Apache CXF committer
> Open SOA http://www.fusesource.com
> Blog http://willemjiang.blogspot.com
> Tiwtter http://twitter.com/willemjiang
>
> huntc wrote:
>>
>> Claus Ibsen-2 wrote:
>>>
>>> No you can replace the spring jars.
>>>
>>
>> Upgrading to Spring 3.0.3.RELEASE fixes the problem.
>>
>> Should we move Camel to Spring 3?
>>
>> Kind regards,
>> Christopher
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Problem with maintaining a JMS subscription after waking from sleep

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

As Camel is used within ActiveMQ and ServiceMix, we can't just upgrade 
Spring version in Camel.
But there is spring3 profile in camel parent/pom.xml, you can build 
camel with spring 3.0.3.RELEASE with that profile if you like.

If you are using OSGi, camel also has a feature file 
(features-spring3.xml) which depends on Spring 3.x.

Willem
----------------------------------
Apache Camel, Apache CXF committer
Open SOA http://www.fusesource.com
Blog http://willemjiang.blogspot.com
Tiwtter http://twitter.com/willemjiang

huntc wrote:
> 
> Claus Ibsen-2 wrote:
>> No you can replace the spring jars.
>>
> 
> Upgrading to Spring 3.0.3.RELEASE fixes the problem.
> 
> Should we move Camel to Spring 3?
> 
> Kind regards,
> Christopher


Re: Problem with maintaining a JMS subscription after waking from sleep

Posted by huntc <hu...@mac.com>.

Claus Ibsen-2 wrote:
> 
> No you can replace the spring jars.
> 

Upgrading to Spring 3.0.3.RELEASE fixes the problem.

Should we move Camel to Spring 3?

Kind regards,
Christopher
-- 
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-maintaining-a-JMS-subscription-after-waking-from-sleep-tp510193p510895.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with maintaining a JMS subscription after waking from sleep

Posted by huntc <hu...@mac.com>.
Hi Claus,

I'm not quite sure how creating a property in my pom file influences the
version of Spring that Camel depends on... did you mean a classifier on my
Camel dependency declarations?

Sorry if I'm missing something here...

Kind regards,
Christopher
-- 
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-maintaining-a-JMS-subscription-after-waking-from-sleep-tp510193p511279.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with maintaining a JMS subscription after waking from sleep

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jun 24, 2010 at 11:58 PM, huntc <hu...@mac.com> wrote:
>
>
> Claus Ibsen-2 wrote:
>>
>> I think we can fix the issue with a custom exceptionListener which
>> fixes the null message.
>>
>> Can you test it by creating a custom javax.jms.ExceptionListener class
>> and then set the message to a non null value.
>>
>> And in Camel you can register the listener using the
>> exceptionListener=#myListener configuration in the endpoint uri.
>>
>> If it fixes it we can create a listener to be shipped out of the box.
>>
>>
> Hi Claus,
>
> I can expend the effort to do this however I've now moved and tested my
> application in UAT based on Spring 3 (I had to move quickly). In addition an
> exception listener sounds like a hack. Can we not move to Spring  3 and
> provide a Spring 2 profile (swap the profile situation around?). That way
> any AMQ and SMX dependency issue is resolved as they can build their own
> distributions from source.
>
> BTW: I don't see much value in shipping Camel with AMQ nowadays; I
> appreciate the history, but they're really two very independent things. I
> can't imagine why someone would prefer to use an AMQ bundled Camel vs. the
> one generally available. Also, given SMX's relationship to OSGi and thus its
> great handling at dependencies I'm not sure I get why Camel needs to be
> strongly coupled there either.
>
> Let's not have other projects constrain what we do here.
> --

If you use maven in your project it should be just a matter of
changing the spring version in your pom.xml by adding a properties as
shown here:

    <properties>
       <spring-version>3.0.2.RELEASE</spring-version>
   </properties>




> View this message in context: http://camel.465427.n5.nabble.com/Problem-with-maintaining-a-JMS-subscription-after-waking-from-sleep-tp510193p511190.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Problem with maintaining a JMS subscription after waking from sleep

Posted by huntc <hu...@mac.com>.

Claus Ibsen-2 wrote:
> 
> I think we can fix the issue with a custom exceptionListener which
> fixes the null message.
> 
> Can you test it by creating a custom javax.jms.ExceptionListener class
> and then set the message to a non null value.
> 
> And in Camel you can register the listener using the
> exceptionListener=#myListener configuration in the endpoint uri.
> 
> If it fixes it we can create a listener to be shipped out of the box.
> 
> 
Hi Claus,

I can expend the effort to do this however I've now moved and tested my
application in UAT based on Spring 3 (I had to move quickly). In addition an
exception listener sounds like a hack. Can we not move to Spring  3 and
provide a Spring 2 profile (swap the profile situation around?). That way
any AMQ and SMX dependency issue is resolved as they can build their own
distributions from source.

BTW: I don't see much value in shipping Camel with AMQ nowadays; I
appreciate the history, but they're really two very independent things. I
can't imagine why someone would prefer to use an AMQ bundled Camel vs. the
one generally available. Also, given SMX's relationship to OSGi and thus its
great handling at dependencies I'm not sure I get why Camel needs to be
strongly coupled there either. 

Let's not have other projects constrain what we do here.
-- 
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-maintaining-a-JMS-subscription-after-waking-from-sleep-tp510193p511190.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with maintaining a JMS subscription after waking from sleep

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jun 23, 2010 at 1:57 PM, huntc <hu...@mac.com> wrote:
>
>
> Claus Ibsen-2 wrote:
>>
>> Can you post a bit more on the stacktrace? Maybe we can find a spot in
>> the camel-jms component to workaround this issue by setting an non
>> null message on the JmsException. This may help prevent this spring
>> bug.
>>
>
> Hi Claus,
>
> That was the entire stack trace I'm afraid!
>
> BTW: Is there a big issue with regards to upgrading Camel to Spring 3?
>

No you can replace the spring jars.


> Kind regards,
> Christopher
> --
> View this message in context: http://camel.465427.n5.nabble.com/Problem-with-maintaining-a-JMS-subscription-after-waking-from-sleep-tp510193p510888.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Problem with maintaining a JMS subscription after waking from sleep

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jun 23, 2010 at 1:57 PM, huntc <hu...@mac.com> wrote:
>
>
> Claus Ibsen-2 wrote:
>>
>> Can you post a bit more on the stacktrace? Maybe we can find a spot in
>> the camel-jms component to workaround this issue by setting an non
>> null message on the JmsException. This may help prevent this spring
>> bug.
>>
>
> Hi Claus,
>
> That was the entire stack trace I'm afraid!
>
> BTW: Is there a big issue with regards to upgrading Camel to Spring 3?
>

I think we can fix the issue with a custom exceptionListener which
fixes the null message.

Can you test it by creating a custom javax.jms.ExceptionListener class
and then set the message to a non null value.

And in Camel you can register the listener using the
exceptionListener=#myListener configuration in the endpoint uri.

If it fixes it we can create a listener to be shipped out of the box.



> Kind regards,
> Christopher
> --
> View this message in context: http://camel.465427.n5.nabble.com/Problem-with-maintaining-a-JMS-subscription-after-waking-from-sleep-tp510193p510888.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Problem with maintaining a JMS subscription after waking from sleep

Posted by huntc <hu...@mac.com>.

Claus Ibsen-2 wrote:
> 
> Can you post a bit more on the stacktrace? Maybe we can find a spot in
> the camel-jms component to workaround this issue by setting an non
> null message on the JmsException. This may help prevent this spring
> bug.
> 

Hi Claus,

That was the entire stack trace I'm afraid!

BTW: Is there a big issue with regards to upgrading Camel to Spring 3?

Kind regards,
Christopher
-- 
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-maintaining-a-JMS-subscription-after-waking-from-sleep-tp510193p510888.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with maintaining a JMS subscription after waking from sleep

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jun 23, 2010 at 11:53 AM, huntc <hu...@mac.com> wrote:
>
> After a little more research, I think its because the version of Spring we're
> using has this bug:
>
> https://jira.springsource.org/browse/SPR-5275
>
> Any recommendations?
>

Can you post a bit more on the stacktrace? Maybe we can find a spot in
the camel-jms component to workaround this issue by setting an non
null message on the JmsException. This may help prevent this spring
bug.



> Kind regards,
> Christopher
> --
> View this message in context: http://camel.465427.n5.nabble.com/Problem-with-maintaining-a-JMS-subscription-after-waking-from-sleep-tp510193p510849.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Problem with maintaining a JMS subscription after waking from sleep

Posted by huntc <hu...@mac.com>.
After a little more research, I think its because the version of Spring we're
using has this bug:

https://jira.springsource.org/browse/SPR-5275

Any recommendations?

Kind regards,
Christopher
-- 
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-maintaining-a-JMS-subscription-after-waking-from-sleep-tp510193p510849.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with maintaining a JMS subscription after waking from sleep

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jun 23, 2010 at 11:47 AM, huntc <hu...@mac.com> wrote:
>
> I've just made a discovery on my own machine. Looks as though this issue may
> actually be related to Spring. What I did was start up a broker, start up my
> application that subscribes to a topic, shutdown the broker and:
>
>
> Exception in thread "DefaultMessageListenerContainer-1"
> java.lang.NullPointerException
>        at java.lang.String.indexOf(String.java:1733)
>        at java.lang.String.indexOf(String.java:1715)
>        at
> org.springframework.jms.support.JmsUtils.buildExceptionMessage(JmsUtils.java:255)
>        at
> org.springframework.jms.listener.DefaultMessageListenerContainer.handleListenerSetupFailure(DefaultMessageListenerContainer.java:745)
>        at
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:897)
>        at java.lang.Thread.run(Thread.java:637)
>
>
> The line in question is:
>
>
>        public static String buildExceptionMessage(JMSException ex) {
>                String message = ex.getMessage();
>                Exception linkedEx = ex.getLinkedException();
>                if (linkedEx != null && message.indexOf(linkedEx.getMessage()) == -1) {
> // <----
>                        message = message + "; nested exception is " + linkedEx;
>                }
>                return message;
>        }
>
>
> Any thoughts? Have we started using some later version of Spring?
>

Ah that is a rather famous bug in Spring 2.5.6 which they did not want
to fix in the 2.5.x line.
So its only fixed in Spring 3.0 onwards.



> Kind regards,
> Christopher
> --
> View this message in context: http://camel.465427.n5.nabble.com/Problem-with-maintaining-a-JMS-subscription-after-waking-from-sleep-tp510193p510846.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Problem with maintaining a JMS subscription after waking from sleep

Posted by huntc <hu...@mac.com>.
I've just made a discovery on my own machine. Looks as though this issue may
actually be related to Spring. What I did was start up a broker, start up my
application that subscribes to a topic, shutdown the broker and:


Exception in thread "DefaultMessageListenerContainer-1"
java.lang.NullPointerException
	at java.lang.String.indexOf(String.java:1733)
	at java.lang.String.indexOf(String.java:1715)
	at
org.springframework.jms.support.JmsUtils.buildExceptionMessage(JmsUtils.java:255)
	at
org.springframework.jms.listener.DefaultMessageListenerContainer.handleListenerSetupFailure(DefaultMessageListenerContainer.java:745)
	at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:897)
	at java.lang.Thread.run(Thread.java:637)


The line in question is:


	public static String buildExceptionMessage(JMSException ex) {
		String message = ex.getMessage();
		Exception linkedEx = ex.getLinkedException();
		if (linkedEx != null && message.indexOf(linkedEx.getMessage()) == -1) { 
// <----
			message = message + "; nested exception is " + linkedEx;
		}
		return message;
	}


Any thoughts? Have we started using some later version of Spring?

Kind regards,
Christopher
-- 
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-maintaining-a-JMS-subscription-after-waking-from-sleep-tp510193p510846.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with maintaining a JMS subscription after waking from sleep

Posted by huntc <hu...@mac.com>.
Just for the record, I've updated the broker to 5.3.2 as well. I'm now using
the latest of everything.

I shall now start looking at the Camel component...
-- 
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-maintaining-a-JMS-subscription-after-waking-from-sleep-tp510193p510824.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with maintaining a JMS subscription after waking from sleep

Posted by huntc <hu...@mac.com>.
OK, upgrading to AMQ 5.3.2 didn't help either.

Help!
-- 
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-maintaining-a-JMS-subscription-after-waking-from-sleep-tp510193p510536.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with maintaining a JMS subscription after waking from sleep

Posted by huntc <hu...@mac.com>.
Hi Willem,

Thanks for that. Just to note that upgrading to Camel 2.3.0 did not change
the outcome i.e. my application failed to re-connect to the topic upon
waking up.

I have now built and deployed a release using 5.3.2 AMQ artefacts so we'll
see if that makes any difference (I shall know in about 12 hours!).

Kind regards,
Christopher
-- 
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-maintaining-a-JMS-subscription-after-waking-from-sleep-tp510193p510394.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Problem with maintaining a JMS subscription after waking from sleep

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

I think it should be OK to use Camel 2.3.0 with ActiveMQ 5.3.x, as we 
ran the development tests of Camel with ActiveMQ 5.3.x.

Willem
huntc wrote:
> I was using Camel 2.2.0 so I've now upgraded to 2.3.0 in the hope that the
> problem may go away. 
> 
> My other thought is to upgrade the camel-activemq component. I noticed that
> I'm using activemq-camel:5.2.0 as per the doco. and that this brings in
> activemq-core:5.2.0 and activemq-pool:5.2.0. This is obviously behind the
> current release of AMQ which is 5.3.2, so I'm wondering if there have been
> fixes around that. If my Camel upgrade doesn't look to have effected the
> problem then I'll bring in activemq-*:5.3.2 and see if that makes a
> difference.
> 
> Any other pointers greatly appreciated of course.


Re: Problem with maintaining a JMS subscription after waking from sleep

Posted by huntc <hu...@mac.com>.
I was using Camel 2.2.0 so I've now upgraded to 2.3.0 in the hope that the
problem may go away. 

My other thought is to upgrade the camel-activemq component. I noticed that
I'm using activemq-camel:5.2.0 as per the doco. and that this brings in
activemq-core:5.2.0 and activemq-pool:5.2.0. This is obviously behind the
current release of AMQ which is 5.3.2, so I'm wondering if there have been
fixes around that. If my Camel upgrade doesn't look to have effected the
problem then I'll bring in activemq-*:5.3.2 and see if that makes a
difference.

Any other pointers greatly appreciated of course.
-- 
View this message in context: http://camel.465427.n5.nabble.com/Problem-with-maintaining-a-JMS-subscription-after-waking-from-sleep-tp510193p510288.html
Sent from the Camel - Users mailing list archive at Nabble.com.