xmlBlaster 2.2.0 API

org.xmlBlaster.contrib
Class MomEventEngine

java.lang.Object
  extended by org.xmlBlaster.contrib.MomEventEngine
All Implemented Interfaces:
java.util.EventListener, I_Callback, I_ChangePublisher, I_ContribPlugin

public class MomEventEngine
extends java.lang.Object
implements I_Callback, I_ChangePublisher


Field Summary
private  int compressSize
           
protected  I_XmlBlasterAccess con
           
protected  ConnectQos connectQos
           
protected  I_Update eventHandler
           
protected  Global glob
           
private static java.util.logging.Logger log
           
protected  java.lang.String loginName
           
protected  java.lang.String password
           
protected  boolean shutdownMom
           
protected  java.util.List subscribeKeyList
           
protected  java.util.List subscribeQosList
           
 
Constructor Summary
MomEventEngine()
           
 
Method Summary
static byte[] compress(byte[] buffer, java.util.Map props, int compressSizeLimit, java.lang.String zipType)
          Compresses the message if needed.
static byte[] compressOLD(byte[] buffer, java.util.Map props, int compressSizeLimit, java.lang.String zipType)
          Deprecated.  
static java.io.InputStream decompress(java.io.InputStream is, java.util.Map clientProperties)
           
static byte[] decompressXX(byte[] buffer, java.util.Map clientProperties)
          Deprecated. you should use the one with InputStream instead since less memory hungry (for big messages)
private static java.lang.String dumpProps(java.util.Map clientProperties)
           
 XBSession getJmsSession()
          Only used in replication, can return null if not used.
 java.util.Set getUsedPropertyKeys()
          Gets all property keys which may be used by this object.
 void init(I_Info info)
          After creation this method is called.
 java.lang.String publish(java.lang.String oid, byte[] message, java.util.Map attrMap)
          Send the message to the MoM.
 boolean registerAlertListener(I_Update update, java.util.Map attrs)
          Register for alerts when the data source has changed.
 void shutdown()
          Cleanup resources.
 java.lang.String update(java.lang.String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos)
          This is the callback method invoked from I_XmlBlasterAccess informing the client in an asynchronous mode about a new message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static java.util.logging.Logger log

glob

protected Global glob

con

protected I_XmlBlasterAccess con

loginName

protected java.lang.String loginName

password

protected java.lang.String password

subscribeKeyList

protected java.util.List subscribeKeyList

subscribeQosList

protected java.util.List subscribeQosList

connectQos

protected ConnectQos connectQos

eventHandler

protected I_Update eventHandler

shutdownMom

protected boolean shutdownMom

compressSize

private int compressSize
Constructor Detail

MomEventEngine

public MomEventEngine()
Method Detail

getUsedPropertyKeys

public java.util.Set getUsedPropertyKeys()
Description copied from interface: I_ContribPlugin
Gets all property keys which may be used by this object.

Specified by:
getUsedPropertyKeys in interface I_ContribPlugin
Returns:
See Also:
I_ContribPlugin.getUsedPropertyKeys()

init

public void init(I_Info info)
          throws java.lang.Exception
Description copied from interface: I_ChangePublisher
After creation this method is called. The plugin must register itself into global scope with info.setObject("org.xmlBlaster.contrib.dbwatcher.mom.I_ChangePublisher", this) to be available for others.

Specified by:
init in interface I_ChangePublisher
Specified by:
init in interface I_ContribPlugin
Parameters:
info - The configuration environment
Throws:
java.lang.Exception - MoM specific

update

public java.lang.String update(java.lang.String cbSessionId,
                               UpdateKey updateKey,
                               byte[] content,
                               UpdateQos updateQos)
                        throws XmlBlasterException
Description copied from interface: I_Callback
This is the callback method invoked from I_XmlBlasterAccess informing the client in an asynchronous mode about a new message.

So you should implement in your client code the I_Callback interface - suppling the update() method where you can do with the message whatever you want.

The raw protocol driver specific update() method (e.g. CORBA-BlasterCallback.update()) is unpacked and for each arrived message this update is called.

Specified by:
update in interface I_Callback
Parameters:
cbSessionId - The session ID specified by the client which registered the callback. You can specify a cbSessionId during connection (with ConnectQos) and this is bounced back here so you can authenticate the message.
updateKey - The arrived key containing the topic name
content - The arrived message content. This is your payload.
Throws:
XmlBlasterException
See Also:
I_XmlBlasterAccess

publish

public java.lang.String publish(java.lang.String oid,
                                byte[] message,
                                java.util.Map attrMap)
                         throws java.lang.Exception
Description copied from interface: I_ChangePublisher
Send the message to the MoM.

Specified by:
publish in interface I_ChangePublisher
Parameters:
changeKey - The topic of the message as a string.
message - the content of the message to publish.
Returns:
the PublishQos as a string.
Throws:
java.lang.Exception - On sending problems

registerAlertListener

public boolean registerAlertListener(I_Update update,
                                     java.util.Map attrs)
                              throws java.lang.Exception
Description copied from interface: I_ChangePublisher
Register for alerts when the data source has changed.

This funtionality is plugin depending, for example the xmlBlaster plugin has a configuration option to subscribe on a alert topic and listens if somebody publishes a message to it. If such a message arrives we trigger a new database poll.

Specified by:
registerAlertListener in interface I_ChangePublisher
Parameters:
update - The callback interface to receive the notification
attrs - extra parameters to pass for the registration. For example if one implementation wants to do a specific extra subscription it would pass the quality of service in the attributes.
Returns:
true if a notification is available (is configured)
Throws:
java.lang.Exception - The MoM specific exception

shutdown

public void shutdown()
Description copied from interface: I_ChangePublisher
Cleanup resources.

Can be called multiple times if instance is reused from different plugins.

Specified by:
shutdown in interface I_ChangePublisher
Specified by:
shutdown in interface I_ContribPlugin
See Also:
I_Plugin

getJmsSession

public XBSession getJmsSession()
Description copied from interface: I_ChangePublisher
Only used in replication, can return null if not used.

Specified by:
getJmsSession in interface I_ChangePublisher
Returns:
See Also:
I_ChangePublisher.getJmsSession()

compressOLD

public static byte[] compressOLD(byte[] buffer,
                                 java.util.Map props,
                                 int compressSizeLimit,
                                 java.lang.String zipType)
Deprecated. 

Compresses the message if needed.

Parameters:
buffer - The buffer to compress
props - The properties to update with the compressed flag (uncompressed size)
compressSizeLimit - The limit for compression. If less than one no compression is done. If the size of the buffer is less than this limit it is not compressed either.
Returns:
the compressed buffer or the input buffer if no compression was needed.

compress

public static byte[] compress(byte[] buffer,
                              java.util.Map props,
                              int compressSizeLimit,
                              java.lang.String zipType)
Compresses the message if needed.

Parameters:
buffer - The buffer to compress
props - The properties to update with the compressed flag (uncompressed size)
compressSizeLimit - The limit for compression. If less than one no compression is done. If the size of the buffer is less than this limit it is not compressed either.
Returns:
the compressed buffer or the input buffer if no compression was needed.

dumpProps

private static final java.lang.String dumpProps(java.util.Map clientProperties)

decompressXX

public static byte[] decompressXX(byte[] buffer,
                                  java.util.Map clientProperties)
Deprecated. you should use the one with InputStream instead since less memory hungry (for big messages)

Parameters:
buffer -
clientProperties -
Returns:

decompress

public static java.io.InputStream decompress(java.io.InputStream is,
                                             java.util.Map clientProperties)

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.