-
Notifications
You must be signed in to change notification settings - Fork 35
Message Publish Subscribe
regunathb edited this page Nov 2, 2012
·
14 revisions
The Trooper RabbitMQ library provides a convenient way to perform simple publish-subscribe operations.
| _. GroupID/Org | _. ArtifactID/Name | _. Description | | org.trpr | platform-core | The small set of core classes common to all of Trooper. | org.trpr | platform-integration | APIs and interface definitions common to integration needs. | org.trpr | integration-rabbitmq | An implementation of the messaging integration API using RabbitMQ.
The publisher interface offers these useful methods:
public void publish(Object message) throws MessagingException;
public void publishString(String message) throws MessagingException;
The consumer interface provides these methods:
public Object consume() throws MessagingException;
public String consumeString() throws MessagingException;
Common methods for both these interfaces are:
public int getQueueDepth() throws MessagingException;
public void closeConnections() throws MessagingException;
The Spring XML beans to create and use the Publisher may be defined as:
<bean id="greetingMessagePublisher" class="org.trpr.platform.integration.impl.messaging.RabbitMQMessagePublisherImpl">
<property name="rabbitMQConfigurations">
<list>
<ref bean="greetingQueueConfiguration" />
</list>
</property>
</bean>
<bean id="greetingQueueConfiguration" class="org.trpr.platform.integration.impl.messaging.RabbitMQConfiguration">
<property name="userName" value="guest" />
<property name="password" value="guest" />
<property name="hostName" value="localhost" />
<property name="virtualHost" value="/" />
<property name="exchangeName" value="myexchange" />
<property name="queueName" value="greetingInput" />
<property name="exchangeType" value="direct" />
<property name="routingKey" value="greetingInput" />
<property name="portNumber" value="5672" />
</bean>