Similar to the producer code shown earlier, you first need to create an IConnectionFactory object and an IConnection. The connection.ClientId specifies a unique identity for this client. Save this value, because the client application must reuse that string to ensure that it receives the appropriate messages. Next, the call to connection.Start instructs the connection to be prepared to start receiving messages. Create an ISession object and an IMessageConsumer object. You can create two types of consumers: durable and non-durable. A non-durable consumer will receive all messages sent after the consumer is created. A durable consumer will receive all messages sent since the durable consumer was first created. For durable consumers, ActiveMQ holds all messages sent when the consumer was disconnected. Using a durable consumer is the way to go for most uses.

Conclusion

ActiveMQ provides excellent publish/subscribe capabilities and performs well under load. Adding Apache NMS makes it easy to incorporate ActiveMQ into .NET applications without the cost overhead of commercial solutions.

You've seen only very basic capabilities here, but be aware that ActiveMQ provides a wide range of configuration options, so it's well worth your time to read through the configuration documentation, so you can configure it correctly for your specific applications.