[rabbitmq-discuss] amq_client_session_wait in RabbitMQ .net API?

Tony Garnock-Jones tonyg at lshift.net
Thu Feb 28 08:01:58 GMT 2008


Hi Aamir,

Aamir_Mohammad at manulife.com wrote:
> In the OpenAMQ WireAPI there is a method called 
> amq_client_session_wait(session, timeout)  ... what is the equivalent 
> method in the RabitMQ .NET API?

There's no direct equivalent, because RabbitMQ's .NET client 
implementation uses a background thread to process packets arriving on 
the socket, and dispatches the resulting work to quite fine-grained 
IBasicConsumer instances that usually are running in application threads.

The recommended approach is to use either QueueingBasicConsumer, as per 
the example given in the documentation, http://tinyurl.com/2o7yen, or 
the higher-level convenience class Subscription, 
http://tinyurl.com/36xpmf. Here's the core of a Subscription-based receiver:

using (IConnection conn = new 
ConnectionFactory().CreateConnection(serverAddress))
{
     using (IModel ch = conn.CreateModel()) {
	Subscription sub;
	sub = new Subscription(ch, ticket, exchange, exchangeType,
				routingKey);
	foreach (BasicDeliverEventArgs e in sub) {
	    // ... handle the delivered message here, and send replies
	    // with ch.BasicPublish
	    sub.Ack(e);
	}
     }
}




More information about the rabbitmq-discuss mailing list