|
xmlBlaster 2.1.0 API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xmlBlaster.contrib.dbwatcher.mom.XmlBlasterPublisher
public class XmlBlasterPublisher
Implementation to send change events to xmlBlaster.
This plugin plays two roles, first it is the gateway to xmlBlaster and second if can be configured to listen on a alert topic and use incoming messages as alerts to check the database again.
Supported configuration:
| Field Summary | |
|---|---|
private java.lang.String |
adminKey
|
protected java.lang.String |
alertSubscribeKey
|
protected java.lang.String |
alertSubscribeQos
|
protected java.lang.String |
alertSubscriptionId
|
protected I_ChangeDetector |
changeDetector
|
private int |
compressSize
|
protected I_XmlBlasterAccess |
con
|
private I_ConnectionStateListener |
connectionStateListener
Can be null, taken out of the info object if the owner of this object has set the parameter _connectionStateListener. |
protected ConnectQos |
connectQos
|
private I_Update |
defaultUpdate
|
protected boolean |
eraseOnDelete
|
protected boolean |
eraseOnDrop
|
protected Global |
glob
|
private int |
initCount
|
private long |
lastPublishTime
|
private static java.util.logging.Logger |
log
|
protected java.lang.String |
loginName
|
protected java.lang.String |
password
|
protected java.lang.String |
publishKey
|
protected java.lang.String |
publishQos
|
private boolean |
throwAwayMessages
|
protected java.lang.String |
topicNameTemplate
|
| Fields inherited from interface org.xmlBlaster.contrib.dbwatcher.DbWatcherConstants |
|---|
_COMPRESSION_TYPE, _UNCOMPRESSED_SIZE, COMPRESSION_TYPE_GZIP, COMPRESSION_TYPE_ZIP, MOM_ALERT_SUBSCRIBE_KEY, MOM_ALERT_SUBSCRIBE_QOS, MOM_COMPRESS_SIZE, MOM_CONNECT_QOS, MOM_ERASE_ON_DELETE, MOM_ERASE_ON_DROP, MOM_LOGIN_NAME, MOM_MAX_SESSIONS, MOM_PASSWORD, MOM_PROPS_TO_ADD_TO_CONNECT, MOM_PUBLISH_KEY, MOM_PUBLISH_QOS, MOM_STATUS_TOPIC_NAME, MOM_TOPIC_NAME |
| Constructor Summary | |
|---|---|
XmlBlasterPublisher()
Default constructor. |
|
| Method Summary | |
|---|---|
private void |
addStringPropToQos(java.util.Map attrMap,
MsgQosData qos)
|
protected java.util.Map |
clientPropertiesToMap(java.util.Map clp)
Copy a map |
java.lang.String |
getAdminKey()
|
java.lang.String |
getAlertSubscribeKey()
|
java.lang.String |
getAlertSubscribeQos()
|
java.lang.String |
getAlertSubscriptionId()
|
int |
getCompressSize()
|
java.lang.String |
getConnectQos()
|
XBSession |
getJmsSession()
Only used in replication, can return null if not used. |
long |
getLastPublishTime()
Returns the time in ms it took for the last real publish. |
java.lang.String |
getLoginName()
|
java.lang.String |
getPublishKey()
|
java.lang.String |
getPublishQos()
|
java.lang.String |
getTopicNameTemplate()
|
java.util.Set |
getUsedPropertyKeys()
Gets all property keys which may be used by this object. |
void |
init(I_Info info)
If a global is passed with info.getObject("org.xmlBlaster.engine.Global") we take a clone and reuse it. |
void |
init(I_Info info,
I_ChangeDetector changeDetector)
If called we shall subcribe to xmlBlaster for alert messages which notifies us that there may be new changes available, we call I_ChangeDetector.checkAgain(java.util.Map) in such a case. |
void |
initWithExistingGlob(Global global,
java.lang.String pubKey,
java.lang.String pubQos,
int compressionSize)
|
boolean |
isEraseOnDelete()
|
boolean |
isEraseOnDrop()
|
boolean |
isThrowAwayMessages()
|
java.lang.String |
publish(java.lang.String changeKey,
byte[] out,
java.util.Map attrMap)
The send message is configured with mom.publishKey and mom.publishQos. |
void |
reachedAlive(ConnectionStateEnum oldState,
I_XmlBlasterAccess connection)
This is the callback method invoked from XmlBlasterAccess notifying the client that a connection has been established and that its status is now ALIVE. |
void |
reachedAliveSync(ConnectionStateEnum oldState,
I_XmlBlasterAccess connection)
Invoked when the dispatcher goes to synch again after having delivered entries which where in the queue when the state changed to ALIVE. |
void |
reachedDead(ConnectionStateEnum oldState,
I_XmlBlasterAccess connection)
This is the callback method invoked from XmlBlasterAccess informing the client that the connection was lost (i.e. |
void |
reachedPolling(ConnectionStateEnum oldState,
I_XmlBlasterAccess connection)
This is the callback method invoked from XmlBlasterAccess informing the client that the connection state has changed to POLLING. |
boolean |
registerAlertListener(I_Update momCb,
java.util.Map attrs)
Subscribes on the alert topic as configured with mom.alertSubscribeKey. |
void |
setAdminKey(java.lang.String adminKey)
|
void |
setAlertSubscribeKey(java.lang.String alertSubscribeKey)
|
void |
setAlertSubscribeQos(java.lang.String alertSubscribeQos)
|
void |
setAlertSubscriptionId(java.lang.String alertSubscriptionId)
|
void |
setCompressSize(int compressSize)
|
void |
setEraseOnDelete(boolean eraseOnDelete)
|
void |
setEraseOnDrop(boolean eraseOnDrop)
|
void |
setPublishKey(java.lang.String publishKey)
|
void |
setPublishQos(java.lang.String publishQos)
|
void |
setThrowAwayMessages(boolean throwAwayMessages)
|
void |
setTopicNameTemplate(java.lang.String topicNameTemplate)
|
void |
shutdown()
Stop producing alerts and cleanup resources. |
void |
startProducing()
Subscribes on the alert topic as configured with mom.alertSubscribeKey. |
void |
stopProducing()
Unsubscribes from the alert topic. |
java.lang.String |
subscribe(java.lang.String topic,
I_Update momCb)
Not available via interface, used by test suite only. |
java.lang.String |
update(java.lang.String s,
UpdateKey k,
byte[] content,
UpdateQos q)
Dummy implementation, PtP messages could arrive here which are ignored. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static java.util.logging.Logger log
protected I_ChangeDetector changeDetector
protected Global glob
protected I_XmlBlasterAccess con
protected java.lang.String topicNameTemplate
protected java.lang.String loginName
protected java.lang.String password
protected java.lang.String publishKey
protected java.lang.String publishQos
protected java.lang.String alertSubscribeKey
protected java.lang.String alertSubscribeQos
protected java.lang.String alertSubscriptionId
protected ConnectQos connectQos
protected boolean eraseOnDrop
protected boolean eraseOnDelete
private int initCount
private I_Update defaultUpdate
private java.lang.String adminKey
private int compressSize
private boolean throwAwayMessages
private long lastPublishTime
private I_ConnectionStateListener connectionStateListener
| Constructor Detail |
|---|
public XmlBlasterPublisher()
init(I_Info) thereafter.
| Method Detail |
|---|
public void init(I_Info info,
I_ChangeDetector changeDetector)
throws java.lang.Exception
I_ChangeDetector.checkAgain(java.util.Map) in such a case.
init in interface I_AlertProducerinfo - The configuration environment
java.lang.Exception - Can be any plugin specific exceptionI_AlertProducer.init(I_Info,I_ChangeDetector)
public void startProducing()
throws java.lang.Exception
startProducing in interface I_AlertProducerjava.lang.Exception - of any typeI_AlertProducer.startProducing()
public void stopProducing()
throws java.lang.Exception
stopProducing in interface I_AlertProducerjava.lang.Exception - of any typeI_AlertProducer.stopProducing()public java.util.Set getUsedPropertyKeys()
I_ContribPlugin
getUsedPropertyKeys in interface I_ContribPluginI_ContribPlugin.getUsedPropertyKeys()
public void initWithExistingGlob(Global global,
java.lang.String pubKey,
java.lang.String pubQos,
int compressionSize)
public void init(I_Info info)
throws java.lang.Exception
init in interface I_ChangePublisherinit in interface I_ContribPlugininfo - The configuration environment
java.lang.Exception - MoM specificorg.xmlBlaster.contrib.dbwatcher.mom.I_ChangePublisher#init(I_Info)public void shutdown()
I_AlertProducer
shutdown in interface I_AlertProducershutdown in interface I_ChangePublishershutdown in interface I_ContribPluginorg.xmlBlaster.contrib.dbwatcher.mom.I_ChangePublisher#shutdown
private void addStringPropToQos(java.util.Map attrMap,
MsgQosData qos)
public java.lang.String publish(java.lang.String changeKey,
byte[] out,
java.util.Map attrMap)
throws java.lang.Exception
publish in interface I_ChangePublisherchangeKey - Can be used to create the topic nameout - The message content to sendattrMap - An optional map with attributes or null
java.lang.Exception - On sending problemsorg.xmlBlaster.contrib.dbwatcher.mom.I_ChangePublisher#publish(String, String, Map)
public boolean registerAlertListener(I_Update momCb,
java.util.Map attrs)
throws java.lang.Exception
registerAlertListener in interface I_ChangePublisherattrs - it currently accepts a null (old behaviour) or if it is not null, then
the attribute ptp must be set (does not matter to what).momCb - The callback interface to receive the notification
java.lang.Exception - Typically a XmlBlasterExceptionorg.xmlBlaster.contrib.dbwatcher.mom.I_ChangePublisher#registerAlertListener(I_Update)
public java.lang.String subscribe(java.lang.String topic,
I_Update momCb)
throws java.lang.Exception
topic - If the topic starts with "XPATH:" the prefix will be stripped
and an Xpath subscription is done.momCb - Incoming messages are forwarded to this interface
java.lang.Exception - Typically a XmlBlasterException
public java.lang.String update(java.lang.String s,
UpdateKey k,
byte[] content,
UpdateQos q)
throws XmlBlasterException
update in interface I_Callbacks - The sessionIdk - The xml keyc - The message contentq - The message QoS
XmlBlasterExceptionI_Callback.update(java.lang.String, org.xmlBlaster.client.key.UpdateKey, byte[], org.xmlBlaster.client.qos.UpdateQos)protected java.util.Map clientPropertiesToMap(java.util.Map clp)
clp - The xmlBlaster ClientProperties
public XBSession getJmsSession()
I_ChangePublisher
getJmsSession in interface I_ChangePublisherI_ChangePublisher.getJmsSession()
public void reachedAlive(ConnectionStateEnum oldState,
I_XmlBlasterAccess connection)
I_ConnectionStateListenerNote that this method is invoked also when the connection has been established the first time. In this case the connection is fully operational but your connect() call has not yet returned. You can access the returned connect QoS in this case with connect.getConnectReturnQos().
You can erase all entries of the queue manually or add others before you return and in this way control the behavior. During you have control in reachedAlive() the client side queue is blocked and does not accept publish or request messages from other threads. So you can do peacefully your work (your thread is allowed to modify the queue exclusively).
If you send messages during this method invocation they are queued only and are sent as soon as this method returns.
This method is invoked by the login polling thread from I_XmlBlasterAccess in which case it is a physical Alive, and by the connect method on successful login in which case it is a logical Alive.
reachedAlive in interface I_ConnectionStateListeneroldState - The previous state of the connection.I_ConnectionStateListener.reachedAlive(org.xmlBlaster.util.dispatch.ConnectionStateEnum, org.xmlBlaster.client.I_XmlBlasterAccess)
public void reachedAliveSync(ConnectionStateEnum oldState,
I_XmlBlasterAccess connection)
I_ConnectionStateListener
reachedAliveSync in interface I_ConnectionStateListeneroldState - is always ALIVE.
public void reachedDead(ConnectionStateEnum oldState,
I_XmlBlasterAccess connection)
I_ConnectionStateListener
reachedDead in interface I_ConnectionStateListeneroldState - The previous state of the connection.I_ConnectionStateListener.reachedDead(org.xmlBlaster.util.dispatch.ConnectionStateEnum, org.xmlBlaster.client.I_XmlBlasterAccess)
public void reachedPolling(ConnectionStateEnum oldState,
I_XmlBlasterAccess connection)
I_ConnectionStateListener
reachedPolling in interface I_ConnectionStateListeneroldState - The previous state of the connection.I_ConnectionStateListener.reachedPolling(org.xmlBlaster.util.dispatch.ConnectionStateEnum, org.xmlBlaster.client.I_XmlBlasterAccess)public java.lang.String getAdminKey()
getAdminKey in interface XmlBlasterPublisherMBeanpublic void setAdminKey(java.lang.String adminKey)
setAdminKey in interface XmlBlasterPublisherMBeanpublic java.lang.String getAlertSubscribeKey()
getAlertSubscribeKey in interface XmlBlasterPublisherMBeanpublic void setAlertSubscribeKey(java.lang.String alertSubscribeKey)
setAlertSubscribeKey in interface XmlBlasterPublisherMBeanpublic java.lang.String getAlertSubscribeQos()
getAlertSubscribeQos in interface XmlBlasterPublisherMBeanpublic void setAlertSubscribeQos(java.lang.String alertSubscribeQos)
setAlertSubscribeQos in interface XmlBlasterPublisherMBeanpublic java.lang.String getAlertSubscriptionId()
getAlertSubscriptionId in interface XmlBlasterPublisherMBeanpublic void setAlertSubscriptionId(java.lang.String alertSubscriptionId)
setAlertSubscriptionId in interface XmlBlasterPublisherMBeanpublic int getCompressSize()
getCompressSize in interface XmlBlasterPublisherMBeanpublic void setCompressSize(int compressSize)
setCompressSize in interface XmlBlasterPublisherMBeanpublic java.lang.String getConnectQos()
getConnectQos in interface XmlBlasterPublisherMBeanpublic boolean isEraseOnDelete()
isEraseOnDelete in interface XmlBlasterPublisherMBeanpublic void setEraseOnDelete(boolean eraseOnDelete)
setEraseOnDelete in interface XmlBlasterPublisherMBeanpublic boolean isEraseOnDrop()
isEraseOnDrop in interface XmlBlasterPublisherMBeanpublic void setEraseOnDrop(boolean eraseOnDrop)
setEraseOnDrop in interface XmlBlasterPublisherMBeanpublic java.lang.String getPublishKey()
getPublishKey in interface XmlBlasterPublisherMBeanpublic void setPublishKey(java.lang.String publishKey)
setPublishKey in interface XmlBlasterPublisherMBeanpublic java.lang.String getPublishQos()
getPublishQos in interface XmlBlasterPublisherMBeanpublic void setPublishQos(java.lang.String publishQos)
setPublishQos in interface XmlBlasterPublisherMBeanpublic boolean isThrowAwayMessages()
isThrowAwayMessages in interface XmlBlasterPublisherMBeanpublic void setThrowAwayMessages(boolean throwAwayMessages)
setThrowAwayMessages in interface XmlBlasterPublisherMBeanpublic java.lang.String getTopicNameTemplate()
getTopicNameTemplate in interface XmlBlasterPublisherMBeanpublic void setTopicNameTemplate(java.lang.String topicNameTemplate)
setTopicNameTemplate in interface XmlBlasterPublisherMBeanpublic java.lang.String getLoginName()
getLoginName in interface XmlBlasterPublisherMBeanpublic long getLastPublishTime()
getLastPublishTime in interface XmlBlasterPublisherMBean
|
xmlBlaster 2.1.0 API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||