org.robokind.impl.messaging
Class JMSRecordSender<T extends org.apache.avro.generic.IndexedRecord>

java.lang.Object
  extended by org.robokind.impl.messaging.JMSRecordSender<T>
All Implemented Interfaces:
org.robokind.api.messaging.RecordSender<T>

public class JMSRecordSender<T extends org.apache.avro.generic.IndexedRecord>
extends Object
implements org.robokind.api.messaging.RecordSender<T>

Sends Avro Records over JMS (Qpid).

Author:
Matthew Stevenson

Field Summary
protected  Class<T> myClass
           
protected  javax.jms.Destination myDestination
           
protected  javax.jms.MessageProducer myMessageProducer
           
protected  javax.jms.Session mySession
           
 
Constructor Summary
JMSRecordSender(Class<T> clazz)
          Creates a new JMSRecordSender.
 
Method Summary
 void closeProducer()
          Closes the underlying JMS MessageProducer making it unable to send Records.
 void openProducer()
          Opens the underlying JMS MessageProducer, allowing it to begin sending Records.
 void sendRecord(T record)
          Serializes the given Avro Record to a byte array, packs it into a JMS BytesMessage, and sends it to the JMS Destination.
 void setDestination(javax.jms.Destination dest)
          Sets the JMS Destination to send to.
 void setSession(javax.jms.Session session)
          Sets the JMS Session to use for sending
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myClass

protected Class<T extends org.apache.avro.generic.IndexedRecord> myClass

mySession

protected javax.jms.Session mySession

myDestination

protected javax.jms.Destination myDestination

myMessageProducer

protected javax.jms.MessageProducer myMessageProducer
Constructor Detail

JMSRecordSender

public JMSRecordSender(Class<T> clazz)
Creates a new JMSRecordSender.

Parameters:
clazz - Class of the Avro Record to send
Method Detail

setSession

public void setSession(javax.jms.Session session)
Sets the JMS Session to use for sending

Parameters:
session -

setDestination

public void setDestination(javax.jms.Destination dest)
Sets the JMS Destination to send to.

Parameters:
dest - JMS Destination to send to

closeProducer

public void closeProducer()
Closes the underlying JMS MessageProducer making it unable to send Records.


openProducer

public void openProducer()
Opens the underlying JMS MessageProducer, allowing it to begin sending Records. This must be called before Records can be sent.


sendRecord

public void sendRecord(T record)
Serializes the given Avro Record to a byte array, packs it into a JMS BytesMessage, and sends it to the JMS Destination.

Specified by:
sendRecord in interface org.robokind.api.messaging.RecordSender<T extends org.apache.avro.generic.IndexedRecord>
Parameters:
record - the Avro Record to send


Copyright © 2011. All Rights Reserved.