org.robokind.impl.messaging
Class JMSAvroMessageSender<Msg,Rec extends org.apache.avro.generic.IndexedRecord>

java.lang.Object
  extended by org.robokind.api.messaging.DefaultMessageSender<Msg,Rec>
      extended by org.robokind.impl.messaging.JMSAvroMessageSender<Msg,Rec>
Type Parameters:
Msg - type of Message the sender accepts
Rec - type of Avro Record to be sent
L - type of listener to notify when sending a Message
All Implemented Interfaces:
org.jflux.api.core.Listener<Msg>, org.jflux.api.core.Notifier<Msg>, org.robokind.api.messaging.MessageSender<Msg>

public class JMSAvroMessageSender<Msg,Rec extends org.apache.avro.generic.IndexedRecord>
extends org.robokind.api.messaging.DefaultMessageSender<Msg,Rec>

DefaultMessageSender for serializing Messages to Avro Records and sending them over JMS (Qpid).

Author:
Matthew Stevenson

Field Summary
 
Fields inherited from class org.robokind.api.messaging.DefaultMessageSender
myRecordSender
 
Constructor Summary
JMSAvroMessageSender(JMSBytesMessageSender sender)
          Creates a new JMSAvroMessageSender using the given sender for sending Records.
JMSAvroMessageSender(javax.jms.Session session, javax.jms.Destination destination)
          Creates a new JMSAvroMessageSender to send Records to the given destination using the given session.
 
Method Summary
 void notifyListeners(Msg message)
           
 void sendMessage(Msg message, String contentType)
          Adapts the given Message to an Avro Record and sends it via JMS with the given JMS header content type.
 void setDefaultContentType(String contentType)
           
 void start()
          Creates and opens a new JMSAvroRecordSender for sending the Avro Records.
 void stop()
          Closes the JMSRecordReceiver.
 
Methods inherited from class org.robokind.api.messaging.DefaultMessageSender
addListener, fireMessageEvent, getRecord, handleEvent, removeListener, setAdapter, setRecordSender
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JMSAvroMessageSender

public JMSAvroMessageSender(javax.jms.Session session,
                            javax.jms.Destination destination)
Creates a new JMSAvroMessageSender to send Records to the given destination using the given session.

Parameters:
session - JMS Session to use for sending
destination - JMS Destination to send to

JMSAvroMessageSender

public JMSAvroMessageSender(JMSBytesMessageSender sender)
Creates a new JMSAvroMessageSender using the given sender for sending Records.

Parameters:
sender - used for sending AvroRecords
Method Detail

start

public void start()
Creates and opens a new JMSAvroRecordSender for sending the Avro Records.

Specified by:
start in interface org.robokind.api.messaging.MessageSender<Msg>
Overrides:
start in class org.robokind.api.messaging.DefaultMessageSender<Msg,Rec extends org.apache.avro.generic.IndexedRecord>

stop

public void stop()
Closes the JMSRecordReceiver.

Specified by:
stop in interface org.robokind.api.messaging.MessageSender<Msg>
Overrides:
stop in class org.robokind.api.messaging.DefaultMessageSender<Msg,Rec extends org.apache.avro.generic.IndexedRecord>

setDefaultContentType

public void setDefaultContentType(String contentType)

notifyListeners

public void notifyListeners(Msg message)
Specified by:
notifyListeners in interface org.jflux.api.core.Notifier<Msg>
Specified by:
notifyListeners in interface org.robokind.api.messaging.MessageSender<Msg>
Overrides:
notifyListeners in class org.robokind.api.messaging.DefaultMessageSender<Msg,Rec extends org.apache.avro.generic.IndexedRecord>

sendMessage

public void sendMessage(Msg message,
                        String contentType)
Adapts the given Message to an Avro Record and sends it via JMS with the given JMS header content type.

Parameters:
message - Message to adapt and send
contentType - content type to set in the JMS message header


Copyright © 2011-2013. All Rights Reserved.