You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by hayden74 <hd...@gmail.com> on 2015/04/14 15:13:51 UTC
Virtual Topic isn't working
Hi guys,
I am having trouble consuming messages from a Virtual Topic.
Basically I want messages from FOO queue to be published to
VirtualTopic.BAR. Here is what I have so far:
Camel side
from("jms:queue:FOO").to("activemq:topic:VirtualTopic.BAR");
Consumer side:
ConsumerTemplate consumerTemplate = context.getBean("consumerTemplate",
ConsumerTemplate.class);
String msg =
consumerTemplate.receiveBody("activemq:topic:Consumer.BAR.MEMBERSHIPS",
String.class);
According to the documentation, the above should work. However, messages
aren't received by the consumer.
A side note: activemq.xml (ActiveMQ version is 5.11.1) doesn't include
entries for destinationInterceptors which ActiveMQ documentation
<http://activemq.apache.org/virtual-destinations.html> states that this
entry is there by default.
--
View this message in context: http://camel.465427.n5.nabble.com/Virtual-Topic-isn-t-working-tp5765762.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Virtual Topic isn't working
Posted by Paul Gale <pa...@gmail.com>.
>Do I also need to change the Camel side to publish to a queue instead of a
topic?
No you do not.
Seems perhaps that you're confused. The fact that you're using a virtual
topic, rather than a durable topic subscription, doesn't change the fact
that messages should still be published to a topic. After all, it's still
pub-sub semantics that you're looking for, albeit achieved using virtual
topics. If pub-sub semantics are not what you want then don't bother with
either virtual topics or durable topic subscriptions and just use queues.
Thanks,
Paul
On Tue, Apr 14, 2015 at 9:37 PM, hayden74 <hd...@gmail.com> wrote:
> Thanks Paul, I will give it another go when I get home.
> Do I also need to change the Camel side to publish to a queue instead of a
> topic?
>
> eg:change Camel side from
> from("jms:queue:foo").to("activemq:topic:VirtualTopic.bar");
>
> to
> from("jms:queue:foo").to("activemq:queue:VirtualTopic.bar");
>
> Thanks again for your help
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Virtual-Topic-isn-t-working-tp5765762p5765795.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Re: Virtual Topic isn't working
Posted by hayden74 <hd...@gmail.com>.
Thanks Paul, I will give it another go when I get home.
Do I also need to change the Camel side to publish to a queue instead of a
topic?
eg:change Camel side from
from("jms:queue:foo").to("activemq:topic:VirtualTopic.bar");
to
from("jms:queue:foo").to("activemq:queue:VirtualTopic.bar");
Thanks again for your help
--
View this message in context: http://camel.465427.n5.nabble.com/Virtual-Topic-isn-t-working-tp5765762p5765795.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Virtual Topic isn't working
Posted by hayden74 <hd...@gmail.com>.
Many thanks Paul, it turned up that I was using older version of Camel &
ActiveMQ. it worked fine when I've upgraded the pom to use 2.15.1 & 5.11.1
respectively.
--
View this message in context: http://camel.465427.n5.nabble.com/Virtual-Topic-isn-t-working-tp5765762p5765857.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Virtual Topic isn't working
Posted by Paul Gale <pa...@gmail.com>.
There's still a problem with your code. This:
String number =
consumerTemplate.receiveBody("activemq:topic:Consumer.A.VirtualTopic.bar",
String.class);
must be changed to this:
String number =
consumerTemplate.receiveBody("activemq:queue:Consumer.A.VirtualTopic.bar",
String.class);
Despite being called a virtual 'topic' it's actually a _queue_ that you're
consuming from.
You can remove the virtual destination interceptor definition from your
activemq.xml as it's adding no value.
Thanks,
Paul
On Tue, Apr 14, 2015 at 5:32 PM, hayden74 <hd...@gmail.com> wrote:
> Thanks Paul,
> That was a typo, the code now looks like:
>
> Camel side:
> from("jms:queue:foo").to("activemq:topic:VirtualTopic.bar");
>
> onsumerTemplate consumerTemplate = context.getBean("consumerTemplate",
> ConsumerTemplate.class);
> String number =
> consumerTemplate.receiveBody("activemq:topic:Consumer.A.VirtualTopic.bar",
> String.class);
>
>
> I've also added the below to the activemq.xml but still didn't help
>
> <destinationInterceptors>
> <virtualDestinationInterceptor>
> <virtualDestinations>
> <virtualTopic name="VirtualTopic.>"
> prefix="Consumer.*.VirtualTopic.>" selectorAware="false"/>
> </virtualDestinations>
> </virtualDestinationInterceptor>
> </destinationInterceptors>
>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Virtual-Topic-isn-t-working-tp5765762p5765791.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Re: Virtual Topic isn't working
Posted by hayden74 <hd...@gmail.com>.
Thanks Paul,
That was a typo, the code now looks like:
Camel side:
from("jms:queue:foo").to("activemq:topic:VirtualTopic.bar");
onsumerTemplate consumerTemplate = context.getBean("consumerTemplate",
ConsumerTemplate.class);
String number =
consumerTemplate.receiveBody("activemq:topic:Consumer.A.VirtualTopic.bar",
String.class);
I've also added the below to the activemq.xml but still didn't help
<destinationInterceptors>
<virtualDestinationInterceptor>
<virtualDestinations>
<virtualTopic name="VirtualTopic.>"
prefix="Consumer.*.VirtualTopic.>" selectorAware="false"/>
</virtualDestinations>
</virtualDestinationInterceptor>
</destinationInterceptors>
--
View this message in context: http://camel.465427.n5.nabble.com/Virtual-Topic-isn-t-working-tp5765762p5765791.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Virtual Topic isn't working
Posted by Paul Gale <pa...@gmail.com>.
I believe your client should look like this:
String msg =
consumerTemplate.receiveBody("activemq:queue:Consumer.blah.VirtualTopic.BAR",
String.class);
...where 'blah' is replaced with an identifier (that does not contain
period characters) of your choosing.
Thanks,
Paul
On Tue, Apr 14, 2015 at 9:13 AM, hayden74 <hd...@gmail.com> wrote:
> Hi guys,
> I am having trouble consuming messages from a Virtual Topic.
> Basically I want messages from FOO queue to be published to
> VirtualTopic.BAR. Here is what I have so far:
>
> Camel side
> from("jms:queue:FOO").to("activemq:topic:VirtualTopic.BAR");
>
> Consumer side:
> ConsumerTemplate consumerTemplate = context.getBean("consumerTemplate",
> ConsumerTemplate.class);
> String msg =
> consumerTemplate.receiveBody("activemq:topic:Consumer.BAR.MEMBERSHIPS",
> String.class);
>
> According to the documentation, the above should work. However, messages
> aren't received by the consumer.
>
> A side note: activemq.xml (ActiveMQ version is 5.11.1) doesn't include
> entries for destinationInterceptors which ActiveMQ documentation
> <http://activemq.apache.org/virtual-destinations.html> states that this
> entry is there by default.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Virtual-Topic-isn-t-working-tp5765762.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>