JBoss Community Archive (Read Only)


RHQ Messaging Framework

Below discusses the prototype for an RHQ Messaging Framework (aka rhq-msg). This work is currently being done in the rhq-audit repo: https://github.com/rhq-project/rhq-audit

The backbone is currently ActiveMQ. Messages flowing via the RHQ Messaging Framework will be JSON encoded so clients of different flavors can be used (Python, Ruby, etc).

There is are three main Maven modules that utilize this ActiveMQ backbone to send async messages:


This is essentially a standalone maven module. It provides an embedded ActiveMQ message broker that can be used by unit or integration tests and can be used by production code to launch a broker. You provide xml (or .properties) configuration for the broker. You usually use .xml configuration since it is more robust and appears to support more features than the simple .properties configuration. .properties can be used to set up a minimal broker, typically for tests.

See the Javadoc for org.rhq.msg.broker.EmbeddedBroker for details.


This provides a common API that both consumers and producers of messages can use. These help abstract away some of the tediousness of coding in JMS.

The main message object is BasicMessage (org.rhq.msg.common.BasicMessage). All messages that RHQ components send and receive should be of this type or a subclass of that type. BasicMessage provides JSON encoding and decoding. It also provides transient storage of its own message ID (encapsulated in the class org.rhq.msg.common.MessageId) as well as a message ID of a message it is correlated with (called a correlation ID but also of type org.rhq.msg.common.MessageId).

Producers send messages and consumers listen for messages on specific endpoints (encapsulated in org.rhq.msg.common.Endpoint). This is nothing more than a named topic or named queue.

Each connection in the RHQ Messaging Framework has an associated ConnectionContext whether used by a producer or consumer (org.rhq.msg.common.ConnectionContext) - producers will use the subclass org.rhq.msg.common.producer.ProducerConnectionContext and consumers will use the subclass org.rhq.msg.common.consumer.ConsumerConnectionContext.

ConnectionContext instances are passed to message processors (subclasses of the type org.rhq.msg.common.AbstractMessageProcessor). Message processors connect to the appropriate endpoint and process accordingly (either sending messages or listening for messages).

Consumers and Producers use instances of org.rhq.msg.common.MessageProcessor or one of its subclasses to process messages.

Consumers pass instaces of org.rhq.msg.common.consumer.BasicMessageListener<T> or one of its subclasses to a message processor to listen for messages. Consumers implement org.rhq.msg.common.consumer.BasicMessageListener.onBasicMessage(T).

Producers call send() on a message processor to send messages.


This provides a test API to more easily write tests where producers and consumers can send and receive messages.

There are test classes that let you quickly and easily setup and start an embedded broker (like org.rhq.msg.common.test.VMEmbeddedBrokerWrapper which starts a broker that only sends and receives messages via producers and consumers running in the same VM - there is an analogou TCPEmbeddedBrokerWrapper that will listen to a tcp port for remote clients).

There are test connection objects (org.rhq.msg.common.test.ProducerConnection and ConsumerConnection) that lets you quickly setup producers and consumers. And there is a test message listener that helps setup a listener that can be used to consume messages and log them in memory for the tests to examine.

Tests can subclass these classes in order to provide their own functionality.

For examples on how to use these test objects, see org.rhq.msg.common.test.EmbeddedBrokerTest for the test that rhq-msg-test-common uses to test itself.

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-11 12:57:41 UTC, last content change 2014-08-08 13:54:48 UTC.