[rabbitmq-discuss] Subscription Pattern in .net

Emile Joubert emile at rabbitmq.com
Tue Mar 15 13:08:48 GMT 2011

Hi Steven,

Thanks for your message about the Subscription class in the .net client.

On 12/03/11 08:06, Steven Taylor wrote:
> Hi,
> I like the Consumer pattern, but I wanted a timed version of it.  FYI:
> the Consumer pattern is basically a message enumerator/iterator that you
> can use in a foreach statement.  i.e. when a message turns up, you get
> another pass through the loop during which your code can decide what to
> do with the message.  Consumer lives in the
> RabbitMQ.Client.MessagePatterns namespace.
> For me, Foreach is neat approach as It hides uneccessesary detail.

IEnumerator.MoveNext() currently waits an indefinite amount of time 
until a message arrives. If I understand correctly, you want a version 
of with a timeout, supplied in the constructor.

Would the enumeration need to be restartable? You may need a different 
implementation of Reset() in that case and this substantially changes 
the semantics of Subscription. I'm not sure how well this fits with 
IEnumerator. Your use-case appears to be reading messages until a large 
gap appears between message. At first glance that looks insufficiently 
general to justify changing the IEnumerator implementation.

The Next(TimeOut,out Msg) method was intended to meet your needs if you 
want a timeout. The example you provided using this looks fine.

> So what is the policy on updating the Mercurial repository?

You could also fork our github repository here:
This would be a way of building consensus for your proposal.

Code that you contribute that does get accepted in the main mercurial 
repository will need a signed contributor agreement.



More information about the rabbitmq-discuss mailing list