Question

Is it possible to use an activemq consumer (in .NET) like this?

foreach (var msg in consumer) {

// process message

}

such that the enumeration loop stops, without consuming CPU, until a message is available? Effectively it would be an infinite loop unless something goes wrong.

Was it helpful?

Solution

You can perform a synchronous consume to achieve something like this with a while loop:

IMessage message = null;
while((message = consumer.Receive()) != null)
{
    //... process the message.
}

-Tim www.fusesource.com

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top