org.addsimplicity.anicetus.io.jms
Class JMSDeliveryAdapter

java.lang.Object
  extended by org.addsimplicity.anicetus.io.jms.JMSDeliveryAdapter
All Implemented Interfaces:
DeliveryAdapter, org.springframework.beans.factory.InitializingBean

public class JMSDeliveryAdapter
extends java.lang.Object
implements DeliveryAdapter, org.springframework.beans.factory.InitializingBean

The JMS delivery adapter publishes telemetry to a JMS topic or queue. The delivery is done using Spring's JMS templates. Telemetry is published on a separate thread, asynchronously to the primary application flows. This is done to minimize any overhead that may be introduced into the main application processing. Telemetry artifacts are queued and delivered by worker threads. The application can control the number of worker threads as well as the size of the queue. Additionally, the behavior if the queue overruns can be controlled. Telemetry can either be discarded if there is no further queue space or the calling thread will be used to delivery the artifact. Messages are converted to the desired format using a Spring message converter implementation.

Author:
Dan Pritchett (driveawedge@yahoo.com)

Constructor Summary
JMSDeliveryAdapter()
           
 
Method Summary
 void afterPropertiesSet()
          Called by Spring once all properties have been set.
 javax.jms.ConnectionFactory getConnectionFactory()
          Get the current connection factory used to connect to the JMS broker.
 javax.jms.Destination getDestination()
          Get the current destination.
 boolean getDiscardOverrun()
          Get the current policy for queue overruns.
 int getMaxDeliveryQueue()
          Get the maximum size of the delivery queue.
 int getMaxDeliveryThreads()
          Get the maximum number of delivery threads.
 org.springframework.jms.support.converter.MessageConverter getMessageConverter()
          Get the current message converter.
 void sendTelemetry(GlobalInfo telemetry)
          Send the telemetry to the JMS topic.
 void setConnectionFactory(javax.jms.ConnectionFactory connectionFactory)
          Set the JMS connection factory that will be used to connect to the broker.
 void setDestination(javax.jms.Destination destination)
          Set the destination topic or queue for delivering telemetry.
 void setDiscardOverrun(boolean discard)
          Setting discard to true will cause telemetry to be dropped if the delivery queue is full.
 void setExceptionHandler(ExceptionHandler handler)
          The exception handler that will be invoked if a delivery error occurs.
 void setMaxDeliveryQueue(int maxDeliveryQueue)
          The delivery queue holds telemetry to be delivered.
 void setMaxDeliveryThreads(int maxDeliveryThreads)
          Delivery threads publish events to the JMS topic.
 void setMessageConverter(org.springframework.jms.support.converter.MessageConverter messageConverter)
          The message converter is responsible for translating the telemetry artifact to the JMS message structure.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JMSDeliveryAdapter

public JMSDeliveryAdapter()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Called by Spring once all properties have been set. This method will establish the connection to the JMS broker.

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

getConnectionFactory

public javax.jms.ConnectionFactory getConnectionFactory()
Get the current connection factory used to connect to the JMS broker.

Returns:
the connection factory.

getDestination

public javax.jms.Destination getDestination()
Get the current destination.

Returns:
the current destination.

getDiscardOverrun

public boolean getDiscardOverrun()
Get the current policy for queue overruns.

Returns:
the current overrun policy.

getMaxDeliveryQueue

public int getMaxDeliveryQueue()
Get the maximum size of the delivery queue.

Returns:
the maximum queue size.

getMaxDeliveryThreads

public int getMaxDeliveryThreads()
Get the maximum number of delivery threads.

Returns:
the maximum number of delivery threads

getMessageConverter

public org.springframework.jms.support.converter.MessageConverter getMessageConverter()
Get the current message converter.

Returns:
the message converter.

sendTelemetry

public void sendTelemetry(GlobalInfo telemetry)
Send the telemetry to the JMS topic. The telemetry is queued for delivery and this method will return immediately unless discarding messages is disabled and the queue is full.

Specified by:
sendTelemetry in interface DeliveryAdapter
Parameters:
telemetry - The telemetry to send.

setConnectionFactory

public void setConnectionFactory(javax.jms.ConnectionFactory connectionFactory)
Set the JMS connection factory that will be used to connect to the broker.

Parameters:
connectionFactory - The factory used to connect to the broker.

setDestination

public void setDestination(javax.jms.Destination destination)
Set the destination topic or queue for delivering telemetry.

Parameters:
destination - The topic for publishing messages.

setDiscardOverrun

public void setDiscardOverrun(boolean discard)
Setting discard to true will cause telemetry to be dropped if the delivery queue is full. This is the default setting.

Parameters:
discard - True to discard telemetry if the queue is full.

setExceptionHandler

public void setExceptionHandler(ExceptionHandler handler)
The exception handler that will be invoked if a delivery error occurs. Note that the handler may be called on a different thread from the thread that sets it.

Specified by:
setExceptionHandler in interface DeliveryAdapter
Parameters:
handler - The exception handler.
See Also:
org.addsimplicity.aniticus.support.DeliveryAdapter#setExceptionHandler(org.addsimplicity.aniticus.support.ExceptionHandler)

setMaxDeliveryQueue

public void setMaxDeliveryQueue(int maxDeliveryQueue)
The delivery queue holds telemetry to be delivered. By default the queue size is unlimited.

Parameters:
maxDeliveryQueue - The maximum number of telemetry events that will be queued.

setMaxDeliveryThreads

public void setMaxDeliveryThreads(int maxDeliveryThreads)
Delivery threads publish events to the JMS topic. By default a maximum of 2 threads are used.

Parameters:
maxDeliveryThreads - The maximum threads that will be used for delivering telemetry.

setMessageConverter

public void setMessageConverter(org.springframework.jms.support.converter.MessageConverter messageConverter)
The message converter is responsible for translating the telemetry artifact to the JMS message structure.

Parameters:
messageConverter - The message converter.


Copyright © 2009 Add Simplicity. All Rights Reserved.