0

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.

freddy smith
  • 3,347
  • 5
  • 24
  • 28

1 Answers1

0

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

Tim Bish
  • 17,475
  • 4
  • 32
  • 42