[rabbitmq-discuss] subscriptions after .NET upgrade

Emile Joubert emile at rabbitmq.com
Thu Nov 11 09:30:44 GMT 2010


Hi Isaac,

On 11/11/10 09:04, Isaac Cambron wrote:
> I have an older application that I'm trying to get onto the latest and
> greatest version of Rabbit and the .NET client. I'm having a bit of a
> problem getting it to work the same way across the API changes.
> 
> In my old app, I had a simple piece that broadcast to all of my
> consumers who happen to be listening. Let's say they print the message's
> content to the console when they get it. It was pretty simple. Each
> consumer just creates a subscription:
> 
> Subscription sub = new Subscription(ch, someExchange,
> ExchangeType.Topic, someTopic);
> 
> and listened to it. The broadcaster just did this:
> 
> ch.BasicPublish(someExchange, someTopic, null, someBytes);
> 
> Now, that signature for Subscription no longer exists. I've tried stuff
> like this (which matches the old implementation from Subscription.cs):
> 
> ch.ExchangeDeclare(EXCHANGE, ExchangeType.Topic);
> ch.QueueDeclare(STATUS_QUEUE);
> ch.QueueBind(STATUS_QUEUE, EXCHANGE, TOPIC, false, null);
> Subscription sub = new Subscription(ch, STATUS_QUEUE, true);
> 
> But the behavior I'm seeing is totally different:
> 
> 1. Only one of the consumers gets the message and prints something. It's
> round-robin instead of broadcast.
> 2. When a new consumer is created and subscribes, it gets all of the
> messages I've ever put in the queue and prints them to the console.
> 
> I'm able to fix #2 by changing noAck to true, but not #1, and I suspect
> I have something very wrong. Any ideas?

Subscriptions have indeed been simplified for release version 2.0.0.
Preceding the use of Subscription with declarations and the binding, as
you have done, is correct.

If only one consumer gets messages then try setting the channel prefetch
to a small number (e.g. 1) by calling ch.BasicQos() before creating the
subscription.

Regards


Emile


More information about the rabbitmq-discuss mailing list