Publishing when there are no consumers (RabbitMQ)

8,688 views
Skip to first unread message

cocowalla

unread,
Dec 17, 2011, 4:16:47 PM12/17/11
to masstrans...@googlegroups.com
I'm testing MassTransit with RabbitMQ. When I publish a message and there are no subscribers, I never see the message in the RabbitMQ queue - is this by design? Are messages purposely discarded if there are no subscribers?

If so, is there any way to change this behaviour so that messages remain in the queue awaiting subsribers who will later consume them?

Vinay Manda

unread,
Dec 18, 2011, 9:52:39 PM12/18/11
to masstrans...@googlegroups.com
Each of the service bus needs to have its own end point. So your publisher might have an end point named Queue1 and might be publishing a message Message1 which might be intended for Queue2.
Unless you have the Queue2 created on the RabbitMQ you would not see the message in Queue2.

Association of the message to the queue happens automatically based on the definitions, and that's the reason you need not specify the queue name where the messages needs to go.
So if there is no subscriber which associates to the message type or if no particular destination uri was mentioned during publishing, the message would not be visible.

I hope that answers your question, else I will let the masters answer or correct me.

Dru Sellers

unread,
Dec 21, 2011, 8:47:04 PM12/21/11
to masstrans...@googlegroups.com
inline

On Sat, Dec 17, 2011 at 3:16 PM, cocowalla <colin.an...@gmail.com> wrote:
I'm testing MassTransit with RabbitMQ. When I publish a message and there are no subscribers, I never see the message in the RabbitMQ queue - is this by design?

yes, if there are no subscribers - there is no one to publish to. if there is no one to publish to there are no queues for the messages to go anywhere. 
 
Are messages purposely discarded if there are no subscribers?

yes. where else would they go? :)
 

If so, is there any way to change this behaviour so that messages remain in the queue awaiting subsribers who will later consume them?

remain in what queue? :)
 

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

cocowalla

unread,
Dec 22, 2011, 6:56:17 AM12/22/11
to masstrans...@googlegroups.com
I see your point :)

Here's the scenario:

A subscriber comes online, queue is created
A producer comes online and publishes a message, which the subscriber receives and processes

The subscribers goes offline

I don't want the producer to care if the subscriber is offline - I want it to send messages as usual, and for the subscriber to pick them up next time it comes online.

Is this possible? I've been able to get this behaviour using EasyNetQ, but haven't been able to figure it out with MassTransit

Dru Sellers

unread,
Dec 22, 2011, 8:33:46 AM12/22/11
to masstrans...@googlegroups.com
This is completely doable. You just want a 'permanent' subscription. These will stay around even if the subscriber goes off line.


-d

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.

Henrik Feldt

unread,
Dec 22, 2011, 8:51:34 AM12/22/11
to masstrans...@googlegroups.com
How would you configure a permanent consumer w/ an IoC container containing the consumers?

Attribute? Or would I have to go into the config part of the app to specify it there, like the docs show?

Henrik

Chris Patterson

unread,
Dec 22, 2011, 8:55:10 AM12/22/11
to masstrans...@googlegroups.com
If you're registering subscriptions in the .Subscribe(sc => {}) method of the ServiceBusFactory, they are permanent by default.


Otherwise, you need to just not call the UnsubscriptionAction returned by the Subscribe{Consumer|Instance|Handler|Saga} method on IServiceBus.

Henrik Feldt

unread,
Dec 22, 2011, 9:19:33 AM12/22/11
to masstrans...@googlegroups.com
OK, awesome.

Then, what if I want to make them ephemeral ;)? Is there an attribute for that?

Dru Sellers

unread,
Dec 22, 2011, 9:21:06 AM12/22/11
to masstrans...@googlegroups.com
There is no 'attribute'

cocowalla

unread,
Dec 22, 2011, 9:45:57 AM12/22/11
to masstrans...@googlegroups.com
Hmm, I'd read the docs but didn't see that - I'll try it out, thanks :)

Dru Sellers

unread,
Dec 22, 2011, 10:44:51 AM12/22/11
to masstrans...@googlegroups.com
no problem. there's a lot to read and I am still working on how best to present the material.

-d

On Thu, Dec 22, 2011 at 8:45 AM, cocowalla <colin.an...@gmail.com> wrote:
Hmm, I'd read the docs but didn't see that - I'll try it out, thanks :)

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.

Chris Patterson

unread,
Dec 22, 2011, 3:03:44 PM12/22/11
to masstrans...@googlegroups.com
If ephemoral means non-permanent, yes: Transient().

cocowalla

unread,
Dec 22, 2011, 5:06:18 PM12/22/11
to masstrans...@googlegroups.com
I've tried this, but I must still be missing something, because regardless of how I configure the bus, any messages the producer sends to RabbitMQ while the consumer is offline seem to disappear.

Here's the bus config from the consumer:

this.bus = ServiceBusFactory.New(sbc =>
{
    sbc.UseRabbitMq();
    sbc.UseRabbitMqRouting();
    sbc.ReceiveFrom("rabbitmq://192.168.1.125/MassTransitPoC");

    sbc.Subscribe(s =>
    {
        s.Consumer<RegistrationMessageConsumer>()
            .Permanent();
    });
});

And here's relevant code from the producer:

Bus.Initialize(sbc =>
{
    sbc.UseRabbitMq();
    sbc.UseRabbitMqRouting();
    sbc.ReceiveFrom("rabbitmq://192.168.1.125/MassTransitPoC");
});

Bus.Instance.Publish(
    new RegisterMessage { Id = Guid.NewGuid() }
);

Any idea where I might be going wrong?

Dru Sellers

unread,
Dec 22, 2011, 5:12:59 PM12/22/11
to masstrans...@googlegroups.com
Does it work when both are running?

-d
--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.

cocowalla

unread,
Dec 22, 2011, 5:45:19 PM12/22/11
to masstrans...@googlegroups.com
Yes, seems to work fine if the consumer and producer are running at the same time

Mick Delaney

unread,
Dec 23, 2011, 10:31:04 AM12/23/11
to masstrans...@googlegroups.com
in the management plugin ui can you find the relevant exchange? 
and if so is the exchange marked as durable?

cocowalla

unread,
Dec 23, 2011, 11:46:44 AM12/23/11
to masstrans...@googlegroups.com
Yes, there are relevant fanout exchanges marked as durable, as well as relevant queues marked as durable. The exchanges and queues remain visible in the RabbitMQ after closing the consumer and producer applications.

Chris Patterson

unread,
Dec 25, 2011, 9:57:11 PM12/25/11
to masstrans...@googlegroups.com
You are using the same input queue for each bus, which is a no-no. You need to have a separate queue for the ReceiveFrom for each application.


On Fri, Dec 23, 2011 at 10:46 AM, cocowalla <colin.an...@gmail.com> wrote:
Yes, there are relevant fanout exchanges marked as durable, as well as relevant queues marked as durable. The exchanges and queues remain visible in the RabbitMQ after closing the consumer and producer applications.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.

cocowalla

unread,
Dec 26, 2011, 11:41:28 AM12/26/11
to masstrans...@googlegroups.com
Seems I still have a lot to learn about MassTransit!

Should each producer and consumer have a seperate queue? (for example, stick a GUID at the end of the queue name for each producer and consumer instance?

Dru Sellers

unread,
Dec 26, 2011, 3:04:59 PM12/26/11
to masstrans...@googlegroups.com
Yes, each producer and consumer should have its own queue (where each consumer / producer is its own Process) - I prefer to make them unique by giving each process a unique name via a config file.

UNLESS

I am doing competing consumer in which case the guid approach might be better.

-d

On Mon, Dec 26, 2011 at 10:41 AM, cocowalla <colin.an...@gmail.com> wrote:
Seems I still have a lot to learn about MassTransit!

Should each producer and consumer have a seperate queue? (for example, stick a GUID at the end of the queue name for each producer and consumer instance?

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.

Dru Sellers

unread,
Dec 26, 2011, 3:05:37 PM12/26/11
to masstrans...@googlegroups.com
you may want to reread this section of the docs as well:

-d

Henrik Feldt

unread,
Jan 20, 2012, 5:44:00 AM1/20/12
to masstrans...@googlegroups.com
And how do you call that method from an IoC-instantiated service? This is what I mean by 'attribute' e.g. on a class that is stated to be a consumer. Otherwise, how does one make it transient?

Travis Smith

unread,
Jan 20, 2012, 9:19:37 AM1/20/12
to masstrans...@googlegroups.com
I'm not sure I understand what you're trying to do here. You need the
consumer to change data in a producer?

-Travis

Reply all
Reply to author
Forward
0 new messages