You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by nirro <st...@gmail.com> on 2012/02/15 12:54:32 UTC

VM queue for 2 camel context

Hello!
I'm trying to create multiple listeners to one vm queue in different camel
contexts. My code looks like this:

public class VMTest
{
    public static void main(String[] args) throws InterruptedException,
Exception
    {
        final CamelContext context = new DefaultCamelContext();
        context.addRoutes(new RouteBuilder()
        {
            @Override
            public void configure()
            {
               
from("vm:eventQueue?multipleConsumers=true").to("stream:out");
            }
        });
        context.start();

        final CamelContext context2 = new DefaultCamelContext();
        context2.addRoutes(new RouteBuilder()
        {
            @Override
            public void configure()
            {
               
from("vm:eventQueue?multipleConsumers=true").to("stream:out");
            }
        });
        context2.start();

        ProducerTemplate producerTemplate =
context.createProducerTemplate();
        producerTemplate.sendBody("vm:eventQueue?multipleConsumers=true",
"the message");

        Thread.sleep(5000);
    }
}

I expect message to be sent to each configured listeners. Unfortunately,
only one message is occurred in the console. Is it possible to consume a vm
queue from different contexts? Thanks!

--
View this message in context: http://camel.465427.n5.nabble.com/VM-queue-for-2-camel-context-tp5485770p5485770.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: VM queue for 2 camel context

Posted by nirro <st...@gmail.com>.
Babak, Ashwin, thanks for your reply.

As I understand, it is technically impossible to do publish/subscribe
messaging using VM component between different contexts, but possible within
one. And there are other preferable technics to do that, for example through
JMS, NMR, etc. Am I right?

--
View this message in context: http://camel.465427.n5.nabble.com/VM-queue-for-2-camel-context-tp5485770p5487311.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: VM queue for 2 camel context

Posted by Ashwin Karpe <ak...@fusesource.com>.
Hi,

As mentioned in the earlier message by Babak, you can achieve the same
effect by creating a single route with multipleConsumers in a single
context.

The Test you have created adds additional lifecycle management and
processing overhead for no good reason...

Cheers,

Ashwin... 

-----
---------------------------------------------------------
Ashwin Karpe
Apache Camel Committer & Sr Principal Consultant
FUSESource (a Progress Software Corporation subsidiary)
http://fusesource.com 

Blog: http://opensourceknowledge.blogspot.com 
---------------------------------------------------------
--
View this message in context: http://camel.465427.n5.nabble.com/VM-queue-for-2-camel-context-tp5485770p5486320.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: VM queue for 2 camel context

Posted by Raul Kripalani <ra...@evosent.com>.
Try setting the multipleConsumers=true option on all consumers.

This option is documented in the SEDA component page. The VM component
inherits all options from SEDA, so it should be possible to use it.

Let us know if it solved your case.

-- Raúl.

On 30 Jul 2013, at 07:09, keesvandieren <ke...@gmail.com> wrote:

> Have the same need here:
>
> We need to do transparent publish-subscribe from one producer to multiple
> consumers across multiple war applications in one container.
>
> The problem I am facing: only the consumers of one of the wars is notified,
> never consumers of both wars are notified.
>
> Is this supported by the VM component? If not, what alternate component is
> recommended to use?
>
> More details:
> I have created a test-project:
> https://github.com/keesvandieren/camel-wicket-atmosphere, which shows the
> problem. Readme.txt describes how to run the project and see only war being
> notified.
>
> Thanks in advance for your time.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/VM-queue-for-2-camel-context-tp5485770p5736464.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: VM queue for 2 camel context

Posted by nirro <st...@gmail.com>.
You can try embedded ActiveMQ broker with "VM connector" (i.e.vm://default)
to organize cross war communication. It's a heavier than VM component, but
much powerful solution.


2013/7/30 keesvandieren [via Camel] <ml-node+s465427n5736464h9@n5.nabble.com
>

> Have the same need here:
>
> We need to do transparent publish-subscribe from one producer to multiple
> consumers across multiple war applications in one container.
>
> The problem I am facing: only the consumers of one of the wars is
> notified, never consumers of both wars are notified.
>
> Is this supported by the VM component? If not, what alternate component is
> recommended to use?
>
> More details:
> I have created a test-project:
> https://github.com/keesvandieren/camel-wicket-atmosphere, which shows the
> problem. Readme.txt describes how to run the project and see only war being
> notified.
>
> Thanks in advance for your time.
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://camel.465427.n5.nabble.com/VM-queue-for-2-camel-context-tp5485770p5736464.html
>  To unsubscribe from VM queue for 2 camel context, click here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5485770&code=c3RhbmlzbGF2LnR5dXJpa292QGdtYWlsLmNvbXw1NDg1NzcwfC0xMzUzMDQwNDIx>
> .
> NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
С уважением,
Станислав Тюриков.




--
View this message in context: http://camel.465427.n5.nabble.com/VM-queue-for-2-camel-context-tp5485770p5736466.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: VM queue for 2 camel context

Posted by keesvandieren <ke...@gmail.com>.
Have the same need here:

We need to do transparent publish-subscribe from one producer to multiple
consumers across multiple war applications in one container.

The problem I am facing: only the consumers of one of the wars is notified,
never consumers of both wars are notified.

Is this supported by the VM component? If not, what alternate component is
recommended to use?

More details:
I have created a test-project:
https://github.com/keesvandieren/camel-wicket-atmosphere, which shows the
problem. Readme.txt describes how to run the project and see only war being
notified.

Thanks in advance for your time.



--
View this message in context: http://camel.465427.n5.nabble.com/VM-queue-for-2-camel-context-tp5485770p5736464.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: VM queue for 2 camel context

Posted by Babak Vahdat <ba...@swissonline.ch>.
Hi

Check the documentation for the *exact* semantics of the multipleConsumers
option. Given your example each of the given vm consumers (actually it's
SedaConsumer as "VmComponent extends SedaComponent") will *compete* for
getting that *single* exchange your're sending, and depending which one
get's it, the message will be consumed either inside your first or second
Camel context. This behaviour is intended, look at the *static* QUEUES field
of VMComponent.

For the behaviour you're looking for (publish/subscribe style of messaging)
just stick to one single Camel context and check the example [2] where using
[3] you could run it as well.

[1] http://camel.apache.org/seda.html#SEDA-Options
[2] http://camel.apache.org/seda.html#SEDA-UsingmultipleConsumers
[3]
https://svn.apache.org/repos/asf/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/FooEventRouteTest.java

Babak

--
View this message in context: http://camel.465427.n5.nabble.com/VM-queue-for-2-camel-context-tp5485770p5486115.html
Sent from the Camel - Users mailing list archive at Nabble.com.