org.yajul.jms
Class MessageReceiver

java.lang.Object
  extended by org.yajul.jms.Endpoint
      extended by org.yajul.jms.MessageReceiver
All Implemented Interfaces:
java.lang.Runnable

public class MessageReceiver
extends Endpoint
implements java.lang.Runnable

Generic message receiver. Creates a thread.
User: Joshua Davis Date: Sep 18, 2007 Time: 6:17:07 AM


Constructor Summary
MessageReceiver(javax.naming.InitialContext ic, java.lang.String factoryJndiName, java.lang.String destinationName, javax.jms.MessageListener listener, java.lang.String messageSelector)
           
 
Method Summary
static
<T> java.util.List<T>
filterByMessageObjectClass(java.util.List<javax.jms.Message> messages, java.lang.Class<T> clazz)
          Returns a list of message objects of a particular class.
 javax.jms.Message peek()
           
 java.util.List<javax.jms.Message> receiveSync(long timeout)
           
 void run()
          Runs the JMS message consumer.
 void shutdown()
           
 void start(java.lang.Runnable idleAction, java.lang.String threadName)
           
 
Methods inherited from class org.yajul.jms.Endpoint
close, finalize, getConnection, getConsumer, getDestination, getProducer, getSession, hasConsumer, isQueueEndpoint, onConnectionCreated, receive, receiveNowait, setQueueEndpoint, startConsumer
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageReceiver

public MessageReceiver(javax.naming.InitialContext ic,
                       java.lang.String factoryJndiName,
                       java.lang.String destinationName,
                       javax.jms.MessageListener listener,
                       java.lang.String messageSelector)
Method Detail

shutdown

public void shutdown()

receiveSync

public java.util.List<javax.jms.Message> receiveSync(long timeout)

filterByMessageObjectClass

public static <T> java.util.List<T> filterByMessageObjectClass(java.util.List<javax.jms.Message> messages,
                                                               java.lang.Class<T> clazz)
Returns a list of message objects of a particular class. Messages that are not of class ObjectMessage will be ignored.

Parameters:
messages - The list of JMS messages.
clazz - the class to filter by
Returns:
a list of all message objects of the specified class.

start

public void start(java.lang.Runnable idleAction,
                  java.lang.String threadName)

run

public void run()
Runs the JMS message consumer.

Specified by:
run in interface java.lang.Runnable

peek

public javax.jms.Message peek()
                       throws javax.jms.JMSException
Throws:
javax.jms.JMSException


Copyright © 2008. All Rights Reserved.