org.figure8.join.core.messaging
Class EchoJMSConsumerBean

java.lang.Object
  extended by org.figure8.join.core.messaging.EchoJMSConsumerBean
All Implemented Interfaces:
javax.jms.MessageListener, JMSConsumerBean

public class EchoJMSConsumerBean
extends java.lang.Object
implements JMSConsumerBean

This is a simple, dummy consumer that just echoes messages using commons logging and store processed messages into a list. List can be flushed using flushMessages() method. This implementation is suited for tests and debugging mainly.

Version:
$Revision: 1.3 $
Author:
Laurent Broudoux

Field Summary
protected static org.apache.commons.logging.Log log
          Commons logger.
 
Constructor Summary
EchoJMSConsumerBean()
           
 
Method Summary
 java.util.List flushMessages()
           
 java.lang.String getName()
          Retrieve the name of this consumer.
 boolean hasReceivedMessage()
           
 void onMessage(javax.jms.Message message)
          Just echo messages using commons logger and add them to messages list.
 void setName(java.lang.String name)
          Set the name identifying this consumer.
 void stop()
          Implement this method to stop current process and free resources.
 void waitForMessagesToArrive(int messageCount)
          Wait until messageCount messages have been received.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
Commons logger.

Constructor Detail

EchoJMSConsumerBean

public EchoJMSConsumerBean()
Method Detail

flushMessages

public java.util.List flushMessages()
Returns:
All the messages on the list so far, clearing the buffer.

hasReceivedMessage

public boolean hasReceivedMessage()
Returns:
true if consumer has received messages, false otherwise.

waitForMessagesToArrive

public void waitForMessagesToArrive(int messageCount)
Wait until messageCount messages have been received. This is useful when testing production and consumption of messages. The wait period is not infinite : it's 10 times 1 second.

Parameters:
messageCount - Number of message to wait for

onMessage

public void onMessage(javax.jms.Message message)
Just echo messages using commons logger and add them to messages list.

Specified by:
onMessage in interface javax.jms.MessageListener
Parameters:
message - JMS Message to process

getName

public java.lang.String getName()
Retrieve the name of this consumer.

Specified by:
getName in interface JMSConsumerBean
Returns:
The name identifying this consumer

setName

public void setName(java.lang.String name)
Set the name identifying this consumer.

Specified by:
setName in interface JMSConsumerBean
Parameters:
name - The name of this consumer

stop

public void stop()
Implement this method to stop current process and free resources. This method should not throw exceptions.

Specified by:
stop in interface JMSConsumerBean


Copyright © 2005-2008 Join. All Rights Reserved.