You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Sebastian Gomez <sa...@gmail.com> on 2008/03/26 20:45:11 UTC

Connect to ServiceMix JMS Topic Remotely using ActiveMQ

Hello.

I've found a new obstacle in my project using ServiceMix: I am trying
to read the messages sent to an ActiveMQ Topic defined in ServiceMix
from a remote machine. I've tried looking for the messages using the
ActiveMQ WebBrowser and the JConsole, but it seems the topics don't
receive any messages (although the topic does appear, empty). In my
machine executing ServiceMix I am able to see the messages perfectly
stored in the queue, so the problem comes when connecting remotely,
not when persisting. I've tried connecting to the ServiceMix queue
before, during, and after message persistence in case I was not
receiving the messages because of subscribing too late to the topic,
but whatever the scenario my queue in the remote machine is blank.

I've tried various configuration in the activemq.xml file of the
remote machine, but without success. Maybe the problem is there, I am
quite new to ActiveMQ, I have read a few guides already, but maybe my
knowledge is insufficient yet.

I've run out of ideas, so I'm willing to try out anything that you
think could work.

Looking forward for your answers. Best regards.

Sebastian Gomez.

Re: Connect to ServiceMix JMS Topic Remotely using ActiveMQ

Posted by Bruce Snyder <br...@gmail.com>.
On Thu, Mar 27, 2008 at 11:48 AM, Sebastian Gomez <sa...@gmail.com> wrote:
> I've been having a look at configuring the jms endpoint to make the
>  subscription durable, but I think the one who has to make it durable
>  should be the consumer, who will live in machine B without ServiceMix,
>  so I don't think the endpoint configuration is the problem.

Yes, this is correct. This is why I asked if you were using durable
subscriptions as the subscription is made from the client side as
durability is  specified when creating the subscription. See the
following Javadocs:

JMS API:
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/jms/TopicSession.html#createDurableSubscriber(javax.jms.Topic,%20java.lang.String)
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/jms/TopicSession.html#createDurableSubscriber(javax.jms.Topic,%20java.lang.String,%20java.lang.String,%20boolean)

ActiveMQ API:
http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/ActiveMQSession.html#createDurableSubscriber(javax.jms.Topic,%20java.lang.String)
http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/ActiveMQSession.html#createDurableSubscriber(javax.jms.Topic,%20java.lang.String,%20java.lang.String,%20boolean)

>  Something strange is happening:
>  - On machine A's jConsole, I see there is just 1 consumer (that I know
>  is the one on machine A), so the one on machine B doesn't appear,
>  while machine B's jConsole says my topic has 2 consumers.
>  - On machines A and B, I can read the messages sent from machine B,
>  but the messages sent from machine A are only seen on A's jConsole.
>
>  Any idea why these inconsistencies occur?

I'm not sure why you're seeing this exactly. What I recommend you do
is download ActiveMQ so you can use the examples to test your
environment. The ActiveMQ examples contain a simple consumer and
producer that contain many options. Here's a doc to get you started
with them:

http://activemq.apache.org/examples.html

Take a look at all the options available in the build.xml or even the
src directory at the ConsumerTool and ProducerTool. I have used the
ActiveMQ examples to test many different ActiveMQ broker topologies in
many different customer environments and I find them extremely useful.
Use these examples to do some simple testing so you can understand how
topics and queues should work. Then apply what you learn to your
situation.

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache ActiveMQ - http://activemq.org/
Apache Camel - http://activemq.org/camel/
Apache ServiceMix - http://servicemix.org/
Apache Geronimo - http://geronimo.apache.org/

Blog: http://bruceblog.org/

Re: Connect to ServiceMix JMS Topic Remotely using ActiveMQ

Posted by Sebastian Gomez <sa...@gmail.com>.
I've been having a look at configuring the jms endpoint to make the
subscription durable, but I think the one who has to make it durable
should be the consumer, who will live in machine B without ServiceMix,
so I don't think the endpoint configuration is the problem.

Something strange is happening:
- On machine A's jConsole, I see there is just 1 consumer (that I know
is the one on machine A), so the one on machine B doesn't appear,
while machine B's jConsole says my topic has 2 consumers.
- On machines A and B, I can read the messages sent from machine B,
but the messages sent from machine A are only seen on A's jConsole.

Any idea why these inconsistencies occur?

Sebastian Gomez.

On Thu, Mar 27, 2008 at 12:40 AM, Sebastian Gomez <sa...@gmail.com> wrote:
> Thanks for the reply. You follow me 100% :)  I only want to emphasize
> that machine B doesn't have ServiceMix installed, in case it is not
> clear.
>
> Until now I didn't know you could configure the topics to be durable
> in ServiceMix, but I have just seen the new JMS endpoints section on
> the web and it seems it's not very complicated. I'll try it and see if
> it resolves my problem.
>
> The strange thing is that using JConsole on machine A, I can see the
> messages are being persisted, but on machine B I just get to see that
> the topic exists, but it seems to be empty. The Topic says it has 2
> consumers, so I understand both A and B should see the messages. Maybe
> I'm missing something out to make B subscribe to the Topic. How can I
> make sure it is subscribed?
>
> Thanks again.
>
> Sebastian Gomez.
>
>
> On 3/26/08, Bruce Snyder <br...@gmail.com> wrote:
> > On Wed, Mar 26, 2008 at 1:45 PM, Sebastian Gomez <sa...@gmail.com> wrote:
> > > Hello.
> > >
> > >  I've found a new obstacle in my project using ServiceMix: I am trying
> > >  to read the messages sent to an ActiveMQ Topic defined in ServiceMix
> > >  from a remote machine. I've tried looking for the messages using the
> > >  ActiveMQ WebBrowser and the JConsole, but it seems the topics don't
> > >  receive any messages (although the topic does appear, empty). In my
> > >  machine executing ServiceMix I am able to see the messages perfectly
> > >  stored in the queue, so the problem comes when connecting remotely,
> > >  not when persisting. I've tried connecting to the ServiceMix queue
> > >  before, during, and after message persistence in case I was not
> > >  receiving the messages because of subscribing too late to the topic,
> > >  but whatever the scenario my queue in the remote machine is blank.
> > >
> > >  I've tried various configuration in the activemq.xml file of the
> > >  remote machine, but without success. Maybe the problem is there, I am
> > >  quite new to ActiveMQ, I have read a few guides already, but maybe my
> > >  knowledge is insufficient yet.
> > >
> > >  I've run out of ideas, so I'm willing to try out anything that you
> > >  think could work.
> >
> > OK, I'm not sure I follow you 100%, so let ask some questions.
> >
> > So you are sending messages to an ActiveMQ topic inside of ServiceMix
> > on machine A. Then you try to read the messages from the same ActiveMQ
> > topic inside of ServiceMix from machine B and there are no messages.
> > Correct?
> >
> > First off, topics are not going to hold messages if there is no active
> > subscriber unless you configure the subscription to be durable. If the
> > subscription is durable, then the broker will hold all messages for a
> > given consumer while it is offline. That way when it comes back online
> > it will receive all the messages to the topic while it was gone. Are
> > you using durable subscriptions?
> >
> > The easiest way to see what's happening is via Jconsole on machine A.
> > Jconsole will display the consumerCount, the enqueueCount, the
> > dequeueCount, etc. This will tell you if any messages have flowed
> > through the topic.
> >
> > Bruce
> > --
> > perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
> > );'
> >
> > Apache ActiveMQ - http://activemq.org/
> > Apache Camel - http://activemq.org/camel/
> > Apache ServiceMix - http://servicemix.org/
> > Apache Geronimo - http://geronimo.apache.org/
> >
> > Blog: http://bruceblog.org/
> >
>

Re: Connect to ServiceMix JMS Topic Remotely using ActiveMQ

Posted by Sebastian Gomez <sa...@gmail.com>.
Thanks for the reply. You follow me 100% :)  I only want to emphasize
that machine B doesn't have ServiceMix installed, in case it is not
clear.

Until now I didn't know you could configure the topics to be durable
in ServiceMix, but I have just seen the new JMS endpoints section on
the web and it seems it's not very complicated. I'll try it and see if
it resolves my problem.

The strange thing is that using JConsole on machine A, I can see the
messages are being persisted, but on machine B I just get to see that
the topic exists, but it seems to be empty. The Topic says it has 2
consumers, so I understand both A and B should see the messages. Maybe
I'm missing something out to make B subscribe to the Topic. How can I
make sure it is subscribed?

Thanks again.

Sebastian Gomez.

On 3/26/08, Bruce Snyder <br...@gmail.com> wrote:
> On Wed, Mar 26, 2008 at 1:45 PM, Sebastian Gomez <sa...@gmail.com> wrote:
> > Hello.
> >
> >  I've found a new obstacle in my project using ServiceMix: I am trying
> >  to read the messages sent to an ActiveMQ Topic defined in ServiceMix
> >  from a remote machine. I've tried looking for the messages using the
> >  ActiveMQ WebBrowser and the JConsole, but it seems the topics don't
> >  receive any messages (although the topic does appear, empty). In my
> >  machine executing ServiceMix I am able to see the messages perfectly
> >  stored in the queue, so the problem comes when connecting remotely,
> >  not when persisting. I've tried connecting to the ServiceMix queue
> >  before, during, and after message persistence in case I was not
> >  receiving the messages because of subscribing too late to the topic,
> >  but whatever the scenario my queue in the remote machine is blank.
> >
> >  I've tried various configuration in the activemq.xml file of the
> >  remote machine, but without success. Maybe the problem is there, I am
> >  quite new to ActiveMQ, I have read a few guides already, but maybe my
> >  knowledge is insufficient yet.
> >
> >  I've run out of ideas, so I'm willing to try out anything that you
> >  think could work.
>
> OK, I'm not sure I follow you 100%, so let ask some questions.
>
> So you are sending messages to an ActiveMQ topic inside of ServiceMix
> on machine A. Then you try to read the messages from the same ActiveMQ
> topic inside of ServiceMix from machine B and there are no messages.
> Correct?
>
> First off, topics are not going to hold messages if there is no active
> subscriber unless you configure the subscription to be durable. If the
> subscription is durable, then the broker will hold all messages for a
> given consumer while it is offline. That way when it comes back online
> it will receive all the messages to the topic while it was gone. Are
> you using durable subscriptions?
>
> The easiest way to see what's happening is via Jconsole on machine A.
> Jconsole will display the consumerCount, the enqueueCount, the
> dequeueCount, etc. This will tell you if any messages have flowed
> through the topic.
>
> Bruce
> --
> perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
> );'
>
> Apache ActiveMQ - http://activemq.org/
> Apache Camel - http://activemq.org/camel/
> Apache ServiceMix - http://servicemix.org/
> Apache Geronimo - http://geronimo.apache.org/
>
> Blog: http://bruceblog.org/
>

Re: Connect to ServiceMix JMS Topic Remotely using ActiveMQ

Posted by Bruce Snyder <br...@gmail.com>.
On Wed, Mar 26, 2008 at 1:45 PM, Sebastian Gomez <sa...@gmail.com> wrote:
> Hello.
>
>  I've found a new obstacle in my project using ServiceMix: I am trying
>  to read the messages sent to an ActiveMQ Topic defined in ServiceMix
>  from a remote machine. I've tried looking for the messages using the
>  ActiveMQ WebBrowser and the JConsole, but it seems the topics don't
>  receive any messages (although the topic does appear, empty). In my
>  machine executing ServiceMix I am able to see the messages perfectly
>  stored in the queue, so the problem comes when connecting remotely,
>  not when persisting. I've tried connecting to the ServiceMix queue
>  before, during, and after message persistence in case I was not
>  receiving the messages because of subscribing too late to the topic,
>  but whatever the scenario my queue in the remote machine is blank.
>
>  I've tried various configuration in the activemq.xml file of the
>  remote machine, but without success. Maybe the problem is there, I am
>  quite new to ActiveMQ, I have read a few guides already, but maybe my
>  knowledge is insufficient yet.
>
>  I've run out of ideas, so I'm willing to try out anything that you
>  think could work.

OK, I'm not sure I follow you 100%, so let ask some questions.

So you are sending messages to an ActiveMQ topic inside of ServiceMix
on machine A. Then you try to read the messages from the same ActiveMQ
topic inside of ServiceMix from machine B and there are no messages.
Correct?

First off, topics are not going to hold messages if there is no active
subscriber unless you configure the subscription to be durable. If the
subscription is durable, then the broker will hold all messages for a
given consumer while it is offline. That way when it comes back online
it will receive all the messages to the topic while it was gone. Are
you using durable subscriptions?

The easiest way to see what's happening is via Jconsole on machine A.
Jconsole will display the consumerCount, the enqueueCount, the
dequeueCount, etc. This will tell you if any messages have flowed
through the topic.

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache ActiveMQ - http://activemq.org/
Apache Camel - http://activemq.org/camel/
Apache ServiceMix - http://servicemix.org/
Apache Geronimo - http://geronimo.apache.org/

Blog: http://bruceblog.org/