communicating between two bus instances using loopback

407 views
Skip to first unread message

Avi Levi

unread,
Jul 25, 2012, 10:31:57 AM7/25/12
to masstrans...@googlegroups.com
Hi all, 

I'm playing around with masstransit and running into problems configuring two bus instances using the loopback transport,
as you can see from the posted code, bus2 is subscribing to the 'Request' message and request message is published using bus1.
what am I missing here?

code:
            var bus1 = ServiceBusFactory.New(c =>
            {
                c.ReceiveFrom("loopback://localhost/queue1");
            });
            
            IServiceBus bus2 = ServiceBusFactory.New(c =>
            {
                c.ReceiveFrom("loopback://localhost/queue2");
                c.Subscribe(sub=>sub.Handler<Request>(m=>Console.WriteLine(m.Input)));
            });

            Console.WriteLine("press to publish");
            Console.ReadKey();

            bus1.Publish(new Request("sss"));
            Console.ReadKey();

Chris Patterson

unread,
Jul 25, 2012, 10:55:57 AM7/25/12
to masstrans...@googlegroups.com
Loopback is difficult to deal with, and is really meant for unit testing only.

That being said, you can look here to see how to setup multiple bus instances that can share subscriptions via Loopback. It's a lot of internal wiring, but it's purpose built for fast in-memory unit tests only.


The key is the SubscriptionLoopback classes that are used to bind subscription events between the bus instances.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstrans...@googlegroups.com.
To unsubscribe from this group, send email to masstransit-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/_5hLWG3C3_MJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Henrik Feldt

unread,
Jul 25, 2012, 10:58:19 AM7/25/12
to masstrans...@googlegroups.com
Here's a sample of what you're looking for:

https://github.com/MassTransit/MassTransit/blob/master/src/MassTransit.Tests/TextFixtures/LoopbackLocalAndRemoteTestFixture.cs

The reason is that you aren't telling the buses that they should route messages to each other. Memory resident buses don't auto-discover each other.

--

Chris Patterson

unread,
Jul 25, 2012, 11:00:00 AM7/25/12
to masstrans...@googlegroups.com
Yeah, what he said.

Avi Levi

unread,
Jul 25, 2012, 11:12:06 AM7/25/12
to masstrans...@googlegroups.com
thanks for the fast reply guys, I'll take a look.

Chris - I believe there is great value in providing an in memory transport for production use and not just for testing purpose, 
some applications doesn't need durability but still want to leverage pub\sub and all the extras that comes with using a service bus - sagas\retries etc...

thanks again
Yeah, what he said.

To post to this group, send email to masstransit-discuss@googlegroups.com.
To unsubscribe from this group, send email to masstransit-discuss+unsub...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/_5hLWG3C3_MJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To unsubscribe from this group, send email to masstransit-discuss+unsub...@googlegroups.com.

Dru Sellers

unread,
Jul 25, 2012, 11:17:52 AM7/25/12
to masstrans...@googlegroups.com
Hi Avi,

I agree, an in-memory transport has been an oft asked feature, but its a low priority for Chris and I as we don't have a need for it. That said, its completely doable on our infrastructure, someone just needs to tackle it. I would definitely be interested in a ZeroMQ based solution as well. If its something you would like to take on, I would happily help you navigate the required interfaces.

-d

To post to this group, send email to masstrans...@googlegroups.com.
To unsubscribe from this group, send email to masstransit-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/Te26y2ekhO0J.

Avi Levi

unread,
Jul 25, 2012, 11:23:35 AM7/25/12
to masstrans...@googlegroups.com
I'll be happy to Dru, where do I start?
-d

Yeah, what he said.

To unsubscribe from this group, send email to masstransit-discuss+unsubscribe...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/_5hLWG3C3_MJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To unsubscribe from this group, send email to masstransit-discuss+unsubscribe...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To unsubscribe from this group, send email to masstransit-discuss+unsub...@googlegroups.com.

Dru Sellers

unread,
Jul 25, 2012, 11:24:18 AM7/25/12
to masstrans...@googlegroups.com
what are you going to use to build the inmemory bits?

-d

To post to this group, send email to masstrans...@googlegroups.com.
To unsubscribe from this group, send email to masstransit-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/_bWrhQnNGc4J.

Avi Levi

unread,
Jul 25, 2012, 11:29:23 AM7/25/12
to masstrans...@googlegroups.com
what do you mean by that?

Dru Sellers

unread,
Jul 25, 2012, 11:33:05 AM7/25/12
to masstrans...@googlegroups.com
the in-memory transport. are you writing it from the ground up by hand, on top of a third party queue lib???

-d

Avi Levi

unread,
Jul 25, 2012, 11:34:48 AM7/25/12
to masstrans...@googlegroups.com
I was thinking of using the loopback stuff that already exists and just wireup everything together, is that a bad idea?

Dru Sellers

unread,
Jul 25, 2012, 11:37:54 AM7/25/12
to masstrans...@googlegroups.com
what do you mean by 'wireup everything together'?
oh ok, so something like sbc.UseLoopbackSubscriptionRouter() or something eh?


-d

Avi Levi

unread,
Jul 25, 2012, 11:40:36 AM7/25/12
to masstrans...@googlegroups.com
yha, exactly.

Dru Sellers

unread,
Jul 25, 2012, 11:42:45 AM7/25/12
to masstrans...@googlegroups.com
ok, the big thing is just going to be how you 'share' that subscription thingy. I think if you just look at the existing configuration api code, you should be able to come up with a decent pull request.

once you have your PR in we can comment directly. :)

-d

Avi Levi

unread,
Jul 25, 2012, 11:46:33 AM7/25/12
to masstrans...@googlegroups.com
I was thinking of something like a static "queues manager" where all queues would register for subscription messages.

Dru Sellers

unread,
Jul 25, 2012, 11:48:02 AM7/25/12
to masstrans...@googlegroups.com
i would start there, give us a PR and lets see where the discussion goes. :)

-d

Avi Levi

unread,
Jul 25, 2012, 11:53:30 AM7/25/12
to masstrans...@googlegroups.com
sure, I'll do that.
Reply all
Reply to author
Forward
0 new messages