|
xmlBlaster 2.2.0 client API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xmlBlaster.client.protocol.AbstractCallbackExtended org.xmlBlaster.client.XmlBlasterAccess
public class XmlBlasterAccess
This is the default implementation of the java client side remote access to xmlBlaster.
It hides a client side queue, the client side dispatcher framework for polling or pinging the server and some more features.
The interface I_CallbackRaw/I_Callback/I_CallbackExtenden are enforced by AbstractCallbackExtended.
Field Summary |
---|
Fields inherited from class org.xmlBlaster.client.protocol.AbstractCallbackExtended |
---|
glob, updateBulkAck |
Constructor Summary | |
---|---|
XmlBlasterAccess(Global glob)
Create an xmlBlaster accessor. |
|
XmlBlasterAccess(java.lang.String[] args)
Create an xmlBlaster accessor. |
Method Summary | |
---|---|
ConnectReturnQos |
connect(ConnectQos qos,
I_Callback updateListener)
Login to xmlBlaster. |
ConnectReturnQos |
connect(ConnectQos qos,
I_StreamingCallback streamingUpdateListener,
boolean withQueue)
|
StorageId |
createStorageId(java.lang.String relating)
The storageId must remain the same after a client restart |
SynchronousCache |
createSynchronousCache(int size)
Setup the cache mode. |
PublishReturnQos |
createTemporaryTopic(long destroyDelay,
int historyMaxMsg)
|
PublishReturnQos |
createTemporaryTopic(java.lang.String uniqueTopicId,
long destroyDelay,
int historyMaxMsg)
|
PublishReturnQos |
createTemporaryTopic(TopicProperty topicProperty)
Create a temporay topic. |
boolean |
disconnect(DisconnectQos disconnectQos)
Logout from the server. |
java.lang.String |
disconnect(java.lang.String disconnectQos)
|
EraseReturnQos[] |
erase(EraseKey eraseKey,
EraseQos eraseQos)
|
EraseReturnQos[] |
erase(java.lang.String xmlKey,
java.lang.String qos)
|
boolean |
forcePollingForTesting()
|
MsgUnit[] |
get(GetKey getKey,
GetQos getQos)
Get synchronous messages. |
MsgUnit[] |
get(java.lang.String xmlKey,
java.lang.String qos)
|
java.lang.String |
getBuildJavaVendor()
The java vendor of the compiler. |
java.lang.String |
getBuildJavaVersion()
The compiler java version. |
java.lang.String |
getBuildTimestamp()
Returns the date when xmlBlaster client library was compiled. |
MsgUnit[] |
getCached(GetKey getKey,
GetQos getQos)
Access synchronously messages. |
I_CallbackServer |
getCbServer()
Access the callback server. |
java.lang.String |
getConnectionQueueId()
Access the unique id of my client side queue. |
long |
getConnectionQueueMaxMsgs()
How many messages are max. |
long |
getConnectionQueueNumMsgs()
How many messages are in this client side queue |
java.lang.String |
getConnectionState()
Get the connection state. |
ConnectQos |
getConnectQos()
Access the current ConnectQos |
ConnectReturnQos |
getConnectReturnQos()
Access the returned QoS of a connect() call. |
ContextNode |
getContextNode()
The unique name of this session instance. |
boolean |
getDispatcherActive()
Access the dispatcher state. |
DispatchStatistic |
getDispatchStatistic()
Access the statistic holder. |
FileDumper |
getFileDumper()
|
Global |
getGlobal()
Access the environment settings of this connection. |
java.lang.String |
getId()
Create a descriptive ME, for logging only |
java.lang.String |
getLogId()
Useful as a logging prefix. |
java.lang.String |
getLoginDate()
Get date when client logged in. |
java.lang.String |
getLoginName()
Access the login name. |
long |
getNumErase()
How many subscribe requests where send by this clients login session |
long |
getNumGet()
How many get requests where send by this clients login session |
long |
getNumPublish()
How many messages where send by this clients login session |
long |
getNumSubscribe()
How many subscribe requests where send by this clients login session |
long |
getNumUnSubscribe()
How many unsubscribe requests where send by this clients login session |
long |
getNumUpdate()
How many messages where received by this clients login session |
long |
getNumUpdateOneway()
How many oneway messages where received by this clients login session |
long |
getPingRoundTripDelay()
Measures the round trip for the last ping() invocation in milli seconds. |
static java.lang.String |
getPluginUsage(java.lang.String clazzName)
Access plugin specific usage() |
long |
getPublicSessionId()
Get the sessions public session id. |
I_Queue |
getQueue()
Enforced by interface I_ConnectionHandler |
java.lang.String |
getRevisionNumber()
Returns the xmlBlaster client library SVN version control revision number. |
long |
getRoundTripDelay()
Measures the round trip for the last remote method invocation in milli seconds. |
org.xmlBlaster.authentication.plugins.I_ClientPlugin |
getSecurityPlugin()
Access the client side security plugin. |
java.lang.String |
getServerNodeId()
The cluster node id (name) to which we want to connect. |
SessionName |
getSessionName()
The public session ID of this login session. |
ConnectionStateEnum |
getState()
Enforced by interface I_ConnectionHandler |
java.lang.String |
getStorageIdStr()
|
XmlBlasterException |
getToDeadXmlBlasterException()
Workaround to transport the reason for the toDead() transition as the interface {@link I_ConnectionStateListener#reachedDead(ConnectionStateEnum, I_XmlBlasterAccess) is missing to pass the exception to the client. |
I_Callback |
getUpdateListener()
The implementation which receives the callback messages. |
long |
getUptime()
Uptime in seconds |
java.lang.Object |
getUserObject()
Can be freely used by client code to store an object and later retrieve it. |
java.lang.String |
getVersion()
Get the xmlBlaster client library version number. |
I_CallbackServer |
initCbServer(java.lang.String loginName,
CallbackAddress callbackAddress)
Create a new instance of the desired protocol driver like CORBA or RMI driver using the plugin loader. |
java.lang.String[] |
invokeErase(java.lang.String url,
java.lang.String qos)
JMX |
java.lang.String[] |
invokeGet(java.lang.String url,
java.lang.String qos)
JMX |
java.lang.String |
invokePublish(java.lang.String key,
java.lang.String content,
java.lang.String qos)
JMX |
java.lang.String |
invokeSubscribe(java.lang.String url,
java.lang.String qos)
JMX |
java.lang.String[] |
invokeUnSubscribe(java.lang.String url,
java.lang.String qos)
JMX |
boolean |
isAlive()
Enforced by interface I_ConnectionHandler |
boolean |
isCallbackConfigured()
Check if a callback was configured, if client has passed a callback address on connect. |
boolean |
isCallbackDispatcherActive()
|
boolean |
isConnected()
Has the connect() method successfully passed? |
boolean |
isDead()
Enforced by interface I_ConnectionHandler |
boolean |
isPolling()
Enforced by interface I_ConnectionHandler |
boolean |
isShutdown()
|
java.lang.String |
leaveServer()
|
void |
leaveServer(java.util.Map map)
Leaves the connection to the server and cleans up the client side resources without making a server side disconnect. |
void |
lostConnection(XmlBlasterException xmlBlasterException)
For example called by SOCKET layer (SocketCallbackImpl.java) on EOF. |
static void |
main(java.lang.String[] args)
For testing invoke: java org.xmlBlaster.client.XmlBlasterAccess |
java.lang.String[] |
peekClientMessages(int numOfEntries)
Peek messages from client queue, they are not removed |
java.lang.String[] |
peekClientMessagesToFile(int numOfEntries,
java.lang.String path)
Peek messages from client queue and dump them to a file, they are not removed. |
void |
ping()
Force a async ping to re-check connection to server. |
void |
postSend(MsgQueueEntry[] entries)
Called after a messages is send from the client side queue, but not for oneway messages. |
PublishReturnQos |
publish(MsgUnit msgUnit)
|
PublishReturnQos[] |
publishArr(MsgUnit[] msgUnitArr)
|
void |
publishOneway(MsgUnit[] msgUnitArr)
Publish messages. |
PublishReturnQos[] |
publishStream(java.io.InputStream is,
MsgKeyData keyData,
MsgQosData qosData,
int maxBufSize,
I_ReplaceContent contentReplacer)
Publishes one message in streaming manner, if the message content is too big to fit in one single chunk, the message is split in several smaller messages (called chunks) and these are published. |
MsgUnit[] |
receive(java.lang.String oid,
int maxEntries,
long timeout,
boolean consumable)
This method synchronously accesses maxEntries messages from any xmlBlaster server side queue. |
void |
refreshSession()
Send an event to xmlBlaster to refresh the login session life time. |
void |
registerConnectionListener(I_ConnectionStateListener connectionListener)
Register a listener to get events about connection status changes. |
I_PostSendListener |
registerPostSendListener(I_PostSendListener postSendListener)
Register a listener to get notifications when a messages is successfully send from the client side tail back queue. |
MsgUnit[] |
request(MsgUnit msgUnit,
long timeout,
int maxEntries)
Implements the blocking request/reply pattern. |
java.lang.String |
sendAdministrativeCommand(java.lang.String command)
Convenience method to send an administrative command to xmlBlaster. |
boolean |
sendingFailed(MsgQueueEntry[] entries,
XmlBlasterException exception)
Called if an asynchronous message is rejected by the server. |
void |
setCallbackDispatcherActive(boolean activate)
Switch callback dispatcher on/off. |
void |
setClientErrorHandler(I_MsgErrorHandler msgErrorHandler)
Use a specific error handler instead of the default one. |
void |
setDispatcherActive(boolean dispatcherActive)
Sets the DispachManager belonging to this session to active or inactive. |
void |
setServerNodeId(java.lang.String nodeId)
Allows to set the node name for nicer logging. |
void |
setStorageIdStr(java.lang.String prefix)
Allows to set a unique client side queue name (connection queue). |
void |
setUpdateListener(I_Callback updateListener)
Register a listener to receive the callback messages. |
void |
setUserObject(java.lang.Object userObject)
Can be freely used by client code to store an object and later retrieve it. |
SubscribeReturnQos |
subscribe(java.lang.String xmlKey,
java.lang.String qos)
|
SubscribeReturnQos |
subscribe(java.lang.String xmlKey,
java.lang.String qos,
I_Callback cb)
Subscribe to messages. |
SubscribeReturnQos |
subscribe(SubscribeKey subscribeKey,
SubscribeQos subscribeQos)
Subscribe to messages. |
SubscribeReturnQos |
subscribe(SubscribeKey subscribeKey,
SubscribeQos subscribeQos,
I_Callback cb)
This subscribe variant allows to specify a specialized callback for updated messages. |
void |
toAlive(I_DispatchManager dispatchManager,
ConnectionStateEnum oldState)
Call by DispatchManager on connection state transition. |
void |
toAliveSync(I_DispatchManager dispatchManager,
ConnectionStateEnum oldState)
|
void |
toDead(I_DispatchManager dispatchManager,
ConnectionStateEnum oldState,
XmlBlasterException xmlBlasterException)
Call by DispatchManager on connection state transition. |
void |
toPolling(I_DispatchManager dispatchManager,
ConnectionStateEnum oldState)
Call by DispatchManager on connection state transition. |
java.lang.String |
toXml()
Dump state of this object into a XML ASCII string. |
java.lang.String |
toXml(java.lang.String extraOffset)
Dump state of this object into a XML ASCII string. |
UnSubscribeReturnQos[] |
unSubscribe(java.lang.String xmlKey,
java.lang.String qos)
|
UnSubscribeReturnQos[] |
unSubscribe(UnSubscribeKey unSubscribeKey,
UnSubscribeQos unSubscribeQos)
Cancel subscription. |
java.lang.String |
update(java.lang.String cbSessionId,
UpdateKey updateKey,
byte[] content,
UpdateQos updateQos)
This is the callback method invoked from xmlBlaster delivering us a new asynchronous message. |
static java.lang.String |
usage(Global glob)
Command line usage. |
Methods inherited from class org.xmlBlaster.client.protocol.AbstractCallbackExtended |
---|
update, update, updateOneway, updateOneway |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XmlBlasterAccess(Global glob)
import org.xmlBlaster.util.Global; ... final Global glob = new Global(args); final I_XmlBlasterAccess xmlBlasterAccess = glob.getXmlBlasterAccess();
glob
- Your environment handle or null to use the default Global.instance()
You must use a cloned Global for each XmlBlasterAccess created.
engine.Global is not allowed here, only util.Global is supported
java.lang.IllegalArgumentException
- If engine.Global is used as parameterpublic XmlBlasterAccess(java.lang.String[] args)
final Global glob = new Global(args); final I_XmlBlasterAccess xmlBlasterAccess = glob.getXmlBlasterAccess();
args
- Your command line argumentsMethod Detail |
---|
public void registerConnectionListener(I_ConnectionStateListener connectionListener)
I_XmlBlasterAccess
registerConnectionListener
in interface I_XmlBlasterAccess
connectionListener
- null or your listener implementation on connection state changes (ALIVE | POLLING | DEAD)I_XmlBlasterAccess.registerConnectionListener(I_ConnectionStateListener)
public final I_PostSendListener registerPostSendListener(I_PostSendListener postSendListener)
registerPostSendListener
in interface I_XmlBlasterAccess
postSendListener
- The postSendListener to set.
public final void postSend(MsgQueueEntry[] entries)
postSend
in interface I_PostSendListener
msgQueueEntry,
- includes the returned QoS (e.g. PublisReturnQos)public boolean sendingFailed(MsgQueueEntry[] entries, XmlBlasterException exception)
I_PostSendListener
If the server e.g. throws an IllegalArgument back to the client the message will most probably never succeed and retrying to send the message makes no sense. You can intercept this case here and eliminate the message.
ErrorCodes of type "communication.*" are not reported here as the dispatcher framework automatically handles reconnect and retry.
NOTE: For ErrorCodes of type "authentication.*" the connection will go to DEAD and the connection queue entries remain for pubSessionId>0. For pubSessionId<0 (none fail safe) the queue entries are removed (to be implemented TODO).
sendingFailed
in interface I_PostSendListener
entries
- Each MsgQueueEntry includes the returned QoSexception
- The cause
public FileDumper getFileDumper() throws XmlBlasterException
XmlBlasterException
public SynchronousCache createSynchronousCache(int size)
I_XmlBlasterAccess
createSynchronousCache
in interface I_XmlBlasterAccess
size
- Size of the cache. This number specifies the count of subscriptions the cache
can hold. It specifies NOT the number of messages.
I_XmlBlasterAccess.getCached(GetKey, GetQos)
,
client.cache requirementpublic void setClientErrorHandler(I_MsgErrorHandler msgErrorHandler)
I_XmlBlasterAccess
setClientErrorHandler
in interface I_XmlBlasterAccess
msgErrorHandler
- Your implementation of the error handler.ClientErrorHandler
public java.lang.String getConnectionQueueId()
XmlBlasterAccessMBean
getConnectionQueueId
in interface XmlBlasterAccessMBean
public final ContextNode getContextNode()
public boolean forcePollingForTesting()
forcePollingForTesting
in interface XmlBlasterAccessMBean
public ConnectReturnQos connect(ConnectQos qos, I_StreamingCallback streamingUpdateListener, boolean withQueue) throws XmlBlasterException
XmlBlasterException
public StorageId createStorageId(java.lang.String relating)
relating
- xbType like Constants.RELATING_CLIENT
public ConnectReturnQos connect(ConnectQos qos, I_Callback updateListener) throws XmlBlasterException
I_XmlBlasterAccess
Connecting with the default configuration (which checks xmlBlaster.properties and your command line arguments):
import org.xmlBlaster.util.Global; ... I_XmlBlasterAccess xmlBlasterAccess = glob.getXmlBlasterAccess(); xmlBlasterAccess.connect(null, null);
The default behavior is to poll automatically for the server if it is not found. As we have not specified a listener for returned messages from the server there is no callback server created.
This example shows how to configure different behavior:
// Example how to configure fail safe settings ConnectQos connectQos = new ConnectQos(glob); Address address = new Address(glob); address.setDelay(4000L); // retry connecting every 4 sec address.setRetries(-1); // -1 == forever address.setPingInterval(0L); // switched off addr.setType("SOCKET"); // don't use CORBA protocol, but use SOCKET instead connectQos.setAddress(address); CallbackAddress cbAddress = new CallbackAddress(glob); cbAddress.setDelay(4000L); // retry connecting every 4 sec cbAddress.setRetries(-1); // -1 == forever cbAddress.setPingInterval(4000L); // ping every 4 seconds connectQos.addCallbackAddress(cbAddress); xmlBlasterAccess.connect(connectQos, new I_Callback() { public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) { if (updateKey.isInternal()) { return ""; } if (updateQos.isErased()) { return ""; } log.info(ME, "Receiving asynchronous message '" + updateKey.getOid() + "' state=" + updateQos.getState() + " in default handler"); return ""; } }); // Login to xmlBlaster, default handler for updates;
connect
in interface I_XmlBlasterAccess
qos
- Your configuration desireupdateListener
- If not null a callback server will be created and
callback messages will be routed to your updateListener.update() method.
XmlBlasterException
- only if connection state is DEAD, typically thrown on wrong configurations.
You must call connect again with different settings.I_XmlBlasterAccess.connect(ConnectQos, I_Callback)
public boolean isConnected()
I_XmlBlasterAccess
Note that this contains no information about the current connection state of the protocol layer.
isConnected
in interface I_XmlBlasterAccess
I_ConnectionHandler.isAlive()
,
I_ConnectionHandler.isPolling()
,
I_ConnectionHandler.isDead()
public void refreshSession() throws XmlBlasterException
I_XmlBlasterAccess
refreshSession
in interface I_XmlBlasterAccess
refreshSession
in interface XmlBlasterAccessMBean
XmlBlasterException
- like ErrorCode.USER_NOT_CONNECTED and othersI_XmlBlasterAccess.refreshSession()
public I_CallbackServer initCbServer(java.lang.String loginName, CallbackAddress callbackAddress) throws XmlBlasterException
I_XmlBlasterAccess
Note that the returned instance is of your control only, we don't cache it in any way, this method is only a helper hiding the plugin loading.
initCbServer
in interface I_XmlBlasterAccess
loginName
- A nice name for logging purposescallbackAddress
- The callback address configuration, contains for example
type like "IOR" or "RMI" and version of the driver, e.g. "1.0"
XmlBlasterException
I_XmlBlasterAccess.initCbServer(String, CallbackAddress)
public org.xmlBlaster.authentication.plugins.I_ClientPlugin getSecurityPlugin()
I_XmlBlasterAccess
getSecurityPlugin
in interface I_XmlBlasterAccess
getSecurityPlugin
in class AbstractCallbackExtended
public java.lang.String disconnect(java.lang.String disconnectQos)
disconnect
in interface XmlBlasterAccessMBean
XmlBlasterAccessMBean.disconnect(String)
public boolean disconnect(DisconnectQos disconnectQos)
I_XmlBlasterAccess
leaveServer(null)
and throw the xmlBlasterAccess instance away.
This is often the case if the client disappears and at a later point wants
to reconnect. On server side the queue for this session remains alive and
collects messages.
If '-dispatch/connection/doSendConnect false' was set call disconnect() nevertheless
to cleanup client side resources.
disconnect
in interface I_XmlBlasterAccess
disconnectQos
- Describe the desired behavior on disconnect
I_XmlBlasterAccess.disconnect(DisconnectQos)
,
interface.disconnect requirementpublic java.lang.String leaveServer()
leaveServer
in interface XmlBlasterAccessMBean
XmlBlasterAccessMBean.leaveServer()
public void leaveServer(java.util.Map map)
I_XmlBlasterAccess
As the login session on server side stays alive, all subscriptions stay valid and callback messages are queued by the server. If you connect at a later time the server sends us all queued messages.
Once you have called this method the I_XmlBlasterAccess becomes invalid and any further invocation results in an XmlBlasterException to be thrown.
leaveServer
in interface I_XmlBlasterAccess
map
- The properties to pass while leaving server.
Currently this argument has no effect. You can
pass null as a parameter.I_XmlBlasterAccess.leaveServer(Map)
public boolean isShutdown()
public I_CallbackServer getCbServer()
getCbServer
in interface I_XmlBlasterAccess
I_XmlBlasterAccess.connect(ConnectQos, I_Callback)
public java.lang.String getId()
getId
in interface I_XmlBlasterAccess
getId
in interface XmlBlasterAccessMBean
public java.lang.String getLogId()
public SessionName getSessionName()
getSessionName
in interface I_XmlBlasterAccess
public java.lang.String getStorageIdStr()
getStorageIdStr
in interface I_XmlBlasterAccess
I_XmlBlasterAccess.getStorageIdStr()
public void setStorageIdStr(java.lang.String prefix)
I_XmlBlasterAccess
setStorageIdStr
in interface I_XmlBlasterAccess
prefix
- For example "toserver1"+sessionName.getRelativeName()I_XmlBlasterAccess.setStorageIdStr(String)
public void setServerNodeId(java.lang.String nodeId)
setServerNodeId
in interface I_XmlBlasterAccess
serverNodeId
- For example "/node/heron/instanceId/1233435" or "/node/heron"public java.lang.String getServerNodeId()
getServerNodeId
in interface I_XmlBlasterAccess
getServerNodeId
in interface XmlBlasterAccessMBean
public SubscribeReturnQos subscribe(java.lang.String xmlKey, java.lang.String qos) throws XmlBlasterException
subscribe
in interface I_XmlBlaster
XmlBlasterException
I_XmlBlasterAccess.subscribe(SubscribeKey, SubscribeQos)
public SubscribeReturnQos subscribe(SubscribeKey subscribeKey, SubscribeQos subscribeQos) throws XmlBlasterException
I_XmlBlasterAccess
The messages are delivered asynchronous with the update() method.
subscribe
in interface I_XmlBlasterAccess
subscribeKey
- Which message topics to retrievesubscribeQos
- Control the behavior and further filter messages with mime based filter plugins
XmlBlasterException
- like ErrorCode.USER_NOT_CONNECTED and othersI_XmlBlasterAccess.subscribe(SubscribeKey, SubscribeQos)
public SubscribeReturnQos subscribe(java.lang.String xmlKey, java.lang.String qos, I_Callback cb) throws XmlBlasterException
I_XmlBlasterAccess
subscribe
in interface I_XmlBlasterAccess
xmlKey
- Which message topics to retrieveqos
- Control the behavior and further filter messages with mime based filter plugins
XmlBlasterException
- like ErrorCode.USER_NOT_CONNECTED and othersI_XmlBlasterAccess.subscribe(SubscribeKey, SubscribeQos, I_Callback)
public SubscribeReturnQos subscribe(SubscribeKey subscribeKey, SubscribeQos subscribeQos, I_Callback cb) throws XmlBlasterException
I_XmlBlasterAccess
XmlBlasterAccess con = ... // login etc. ... SubscribeKey key = new SubscribeKey(glob, "//stock", "XPATH"); SubscribeQos qos = new SubscribeQos(glob); try { con.subscribe(key, qos, new I_Callback() { public String update(String name, UpdateKey updateKey, byte[] content, UpdateQos updateQos) { System.out.println("Receiving message for '//stock' subscription ..."); return ""; } }); } catch(XmlBlasterException e) { System.out.println(e.getMessage()); }NOTE: You need to pass a callback handle on login as well (even if you never use it). It allows to setup the callback server and is the default callback deliver channel for PtP messages. NOTE: On logout we automatically unSubscribe() this subscription if not done before.
subscribe
in interface I_XmlBlasterAccess
cb
- Your callback handling implementation
XmlBlasterException
- like ErrorCode.USER_NOT_CONNECTED and othersI_XmlBlasterAccess.subscribe(SubscribeKey, SubscribeQos, I_Callback)
public MsgUnit[] get(java.lang.String xmlKey, java.lang.String qos) throws XmlBlasterException
get
in interface I_XmlBlaster
XmlBlasterException
I_XmlBlasterAccess.get(GetKey, GetQos)
public MsgUnit[] getCached(GetKey getKey, GetQos getQos) throws XmlBlasterException
I_XmlBlasterAccess
A typical use case is a servlet which receives many HTML requests and usually the message has not changed. This way we avoid asking xmlBlaster every time for the information but take it directly from the cache.
The cache is always up to date as it has subscribed on this topic
You need to call createSynchronousCache() before using getCached().
NOTE: Passing two similar getKey but with different getQos filters is currently not supported.
NOTE: GetKey requests with EXACT oid are automatically removed from cache when the topic with this oid is erased. XPATH queries are removed from cache when the last topic oid which matched the XPATH disappears.
getCached
in interface I_XmlBlasterAccess
getKey
- Which message topics to retrievegetQos
- Control the behavior and further filter messages with mime based filter plugins
XmlBlasterException
- if createSynchronousCache() was not used to establish a cache firstI_XmlBlasterAccess.getCached(GetKey, GetQos)
public MsgUnit[] get(GetKey getKey, GetQos getQos) throws XmlBlasterException
I_XmlBlasterAccess
get
in interface I_XmlBlasterAccess
getKey
- Which message topics to retrievegetQos
- Control the behavior and further filter messages with mime based filter plugins
XmlBlasterException
- like ErrorCode.USER_NOT_CONNECTED and othersI_XmlBlasterAccess.get(GetKey, GetQos)
public UnSubscribeReturnQos[] unSubscribe(UnSubscribeKey unSubscribeKey, UnSubscribeQos unSubscribeQos) throws XmlBlasterException
I_XmlBlasterAccess
unSubscribe
in interface I_XmlBlasterAccess
unSubscribeKey
- Which messages to cancelunSubscribeQos
- Control the behavior
XmlBlasterException
- like ErrorCode.USER_NOT_CONNECTED and othersI_XmlBlasterAccess.unSubscribe(UnSubscribeKey, UnSubscribeQos)
public UnSubscribeReturnQos[] unSubscribe(java.lang.String xmlKey, java.lang.String qos) throws XmlBlasterException
unSubscribe
in interface I_XmlBlaster
XmlBlasterException
I_XmlBlasterAccess.unSubscribe(UnSubscribeKey, UnSubscribeQos)
public PublishReturnQos publish(MsgUnit msgUnit) throws XmlBlasterException
publish
in interface I_XmlBlasterAccess
publish
in interface I_XmlBlaster
XmlBlasterException
I_XmlBlasterAccess.publish(MsgUnit)
public void publishOneway(MsgUnit[] msgUnitArr) throws XmlBlasterException
I_XmlBlasterAccess
publishOneway
in interface I_XmlBlasterAccess
publishOneway
in interface I_XmlBlaster
msgUnitArr
- The messages to send to the server
XmlBlasterException
- like ErrorCode.USER_NOT_CONNECTED and othersI_XmlBlasterAccess.publishOneway(MsgUnit[])
public PublishReturnQos[] publishArr(MsgUnit[] msgUnitArr) throws XmlBlasterException
publishArr
in interface I_XmlBlaster
XmlBlasterException
public EraseReturnQos[] erase(EraseKey eraseKey, EraseQos eraseQos) throws XmlBlasterException
erase
in interface I_XmlBlasterAccess
eraseKey
- The topics to eraseeraseQos
- Control the erase behavior
XmlBlasterException
- like ErrorCode.USER_NOT_CONNECTED and othersI_XmlBlasterAccess.erase(EraseKey, EraseQos)
public EraseReturnQos[] erase(java.lang.String xmlKey, java.lang.String qos) throws XmlBlasterException
erase
in interface I_XmlBlaster
XmlBlasterException
I_XmlBlasterAccess.erase(EraseKey, EraseQos)
public void lostConnection(XmlBlasterException xmlBlasterException)
lostConnection
in interface I_CallbackExtended
xmlBlasterException
- org.xmlBlaster.client.I_CallbackExtended#lostConnection(XmlBlasterException)
public void ping()
ping
in interface I_XmlBlasterAccess
public java.lang.String update(java.lang.String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) throws XmlBlasterException
update
in interface I_Callback
update
in class AbstractCallbackExtended
cbSessionId
- The session ID specified by the client which registered the callbackupdateKey
- The arrived key (as an xml-string)content
- The arrived message contentupdateQos
- Quality of Service of the MsgUnitRaw as an xml-string
XmlBlasterException
I_Callback.update(String, UpdateKey, byte[], UpdateQos)
public void toAlive(I_DispatchManager dispatchManager, ConnectionStateEnum oldState)
toAlive
in interface I_ConnectionStatusListener
public void toAliveSync(I_DispatchManager dispatchManager, ConnectionStateEnum oldState)
toAliveSync
in interface I_ConnectionStatusListener
public void toPolling(I_DispatchManager dispatchManager, ConnectionStateEnum oldState)
toPolling
in interface I_ConnectionStatusListener
public XmlBlasterException getToDeadXmlBlasterException()
Currently the client needs a downcast to XmlBlasterAccess (not in I_XmlBlasterAccess)
public void toDead(I_DispatchManager dispatchManager, ConnectionStateEnum oldState, XmlBlasterException xmlBlasterException)
Enforced by interface I_ConnectionStatusListener
toDead
in interface I_ConnectionStatusListener
xmlBlasterException
- Can be nullpublic Global getGlobal()
Enforced by interface I_XmlBlasterAccess
getGlobal
in interface I_XmlBlasterAccess
public I_Queue getQueue()
Enforced by interface I_ConnectionHandler
getQueue
in interface I_ConnectionHandler
public ConnectionStateEnum getState()
Enforced by interface I_ConnectionHandler
getState
in interface I_ConnectionHandler
public java.lang.String getConnectionState()
getConnectionState
in interface XmlBlasterAccessMBean
public boolean isAlive()
Enforced by interface I_ConnectionHandler
isAlive
in interface I_ConnectionHandler
public boolean isPolling()
Enforced by interface I_ConnectionHandler
isPolling
in interface I_ConnectionHandler
public boolean isDead()
Enforced by interface I_ConnectionHandler
isDead
in interface I_ConnectionHandler
public ConnectReturnQos getConnectReturnQos()
Enforced by interface I_XmlBlasterAccess
getConnectReturnQos
in interface I_XmlBlasterAccess
public ConnectQos getConnectQos()
Enforced by interface I_XmlBlasterAccess
getConnectQos
in interface I_XmlBlasterAccess
public final DispatchStatistic getDispatchStatistic()
AbstractCallbackExtended
getDispatchStatistic
in class AbstractCallbackExtended
public final java.lang.String getLoginName()
getLoginName
in interface XmlBlasterAccessMBean
public final boolean isCallbackConfigured()
XmlBlasterAccessMBean
isCallbackConfigured
in interface XmlBlasterAccessMBean
public final long getUptime()
XmlBlasterAccessMBean
getUptime
in interface XmlBlasterAccessMBean
public final java.lang.String getLoginDate()
XmlBlasterAccessMBean
getLoginDate
in interface XmlBlasterAccessMBean
public final long getPublicSessionId()
XmlBlasterAccessMBean
getPublicSessionId
in interface XmlBlasterAccessMBean
public final long getNumPublish()
XmlBlasterAccessMBean
getNumPublish
in interface XmlBlasterAccessMBean
public final long getNumSubscribe()
XmlBlasterAccessMBean
getNumSubscribe
in interface XmlBlasterAccessMBean
public final long getNumUnSubscribe()
XmlBlasterAccessMBean
getNumUnSubscribe
in interface XmlBlasterAccessMBean
public final long getNumGet()
XmlBlasterAccessMBean
getNumGet
in interface XmlBlasterAccessMBean
public final long getNumErase()
XmlBlasterAccessMBean
getNumErase
in interface XmlBlasterAccessMBean
public final long getNumUpdateOneway()
XmlBlasterAccessMBean
getNumUpdateOneway
in interface XmlBlasterAccessMBean
public final long getNumUpdate()
XmlBlasterAccessMBean
getNumUpdate
in interface XmlBlasterAccessMBean
public final long getConnectionQueueNumMsgs()
XmlBlasterAccessMBean
getConnectionQueueNumMsgs
in interface XmlBlasterAccessMBean
public final long getConnectionQueueMaxMsgs()
XmlBlasterAccessMBean
getConnectionQueueMaxMsgs
in interface XmlBlasterAccessMBean
public final long getPingRoundTripDelay()
XmlBlasterAccessMBean
getPingRoundTripDelay
in interface XmlBlasterAccessMBean
public final long getRoundTripDelay()
XmlBlasterAccessMBean
update(), publish(), subscribe()
getRoundTripDelay
in interface XmlBlasterAccessMBean
public java.lang.String invokePublish(java.lang.String key, java.lang.String content, java.lang.String qos) throws java.lang.Exception
invokePublish
in interface XmlBlasterAccessMBean
key
- The publish key (e.g. <key oid="Hello"><South/></key>)qos
- The qos XML string (e.g. "" or "<qos><persistent/></qos>")
java.lang.Exception
public java.lang.String[] invokeUnSubscribe(java.lang.String url, java.lang.String qos) throws java.lang.Exception
invokeUnSubscribe
in interface XmlBlasterAccessMBean
url
- The topic oid/xpath to unSubscribe (e.g. "Hello" or "xpath://key")qos
- The qos XML string (e.g. "" or "java.lang.Exception
public java.lang.String invokeSubscribe(java.lang.String url, java.lang.String qos) throws java.lang.Exception
invokeSubscribe
in interface XmlBlasterAccessMBean
url
- The topic oid/xpath to subscribe (e.g. "Hello" or "xpath://key")qos
- The qos XML string (e.g. "" or "java.lang.Exception
public java.lang.String[] invokeGet(java.lang.String url, java.lang.String qos) throws java.lang.Exception
invokeGet
in interface XmlBlasterAccessMBean
url
- The topic oid/xpath to retrieve (e.g. "Hello" or "xpath://key")qos
- The qos XML string (e.g. "" or "java.lang.Exception
public java.lang.String[] invokeErase(java.lang.String url, java.lang.String qos) throws java.lang.Exception
invokeErase
in interface XmlBlasterAccessMBean
url
- The topic oid/xpath to erase (e.g. "Hello" or "xpath://key")qos
- The qos XML string (e.g. "" or "java.lang.Exception
public void setDispatcherActive(boolean dispatcherActive)
setDispatcherActive
in interface XmlBlasterAccessMBean
dispatchActive
- public boolean getDispatcherActive()
XmlBlasterAccessMBean
getDispatcherActive
in interface XmlBlasterAccessMBean
public void setCallbackDispatcherActive(boolean activate) throws XmlBlasterException
I_XmlBlasterAccess
setCallbackDispatcherActive
in interface I_XmlBlasterAccess
activate
- true: XmlBlaster server delivers callback messages
false: XmlBlaster server keeps messages for this client in the callback queue
XmlBlasterException
public boolean isCallbackDispatcherActive() throws XmlBlasterException
XmlBlasterException
public java.lang.String sendAdministrativeCommand(java.lang.String command) throws XmlBlasterException
I_XmlBlasterAccess
sendAdministrativeCommand
in interface I_XmlBlasterAccess
command
- for example "client/joe/?dispatcherActive" (a getter) or "client/joe/?dispatcherActive=false" (a setter).
The "__cmd:" is added by us
To enforce a getter or setter you can write "get client/joe/?dispatcherActive" or
"set client/joe/?dispatcherActive=false"
XmlBlasterException
- on problemspublic java.lang.String[] peekClientMessages(int numOfEntries) throws java.lang.Exception
XmlBlasterAccessMBean
peekClientMessages
in interface XmlBlasterAccessMBean
numOfEntries
- The number of messages to peek, taken from the front
java.lang.Exception
public java.lang.String[] peekClientMessagesToFile(int numOfEntries, java.lang.String path) throws java.lang.Exception
peekClientMessagesToFile
in interface XmlBlasterAccessMBean
numOfEntries
- The number of messages to peek, taken from the frontpath
- The path to dump the messages to, it is automatically created if missing.
java.lang.Exception
public static java.lang.String usage(Global glob)
public static java.lang.String getPluginUsage(java.lang.String clazzName)
public final java.lang.String toXml()
toXml
in interface I_XmlBlasterAccess
public final java.lang.String toXml(java.lang.String extraOffset)
extraOffset
- indenting of tags for nice output
public static void main(java.lang.String[] args)
public I_Callback getUpdateListener()
public void setUpdateListener(I_Callback updateListener)
updateListener
- The updateListener to set.public java.lang.String getVersion()
XmlBlasterAccessMBean
getVersion
in interface XmlBlasterAccessMBean
public java.lang.String getRevisionNumber()
XmlBlasterAccessMBean
getRevisionNumber
in interface XmlBlasterAccessMBean
public java.lang.String getBuildTimestamp()
XmlBlasterAccessMBean
getBuildTimestamp
in interface XmlBlasterAccessMBean
public java.lang.String getBuildJavaVendor()
XmlBlasterAccessMBean
getBuildJavaVendor
in interface XmlBlasterAccessMBean
public java.lang.String getBuildJavaVersion()
XmlBlasterAccessMBean
getBuildJavaVersion
in interface XmlBlasterAccessMBean
public PublishReturnQos createTemporaryTopic(TopicProperty topicProperty) throws XmlBlasterException
topicProperty
- Can be null (the default is no DOM entry)
XmlBlasterException
public PublishReturnQos createTemporaryTopic(long destroyDelay, int historyMaxMsg) throws XmlBlasterException
XmlBlasterException
public PublishReturnQos createTemporaryTopic(java.lang.String uniqueTopicId, long destroyDelay, int historyMaxMsg) throws XmlBlasterException
uniqueTopicId
- Usually null, can be used to force a topicId.
e.g. topicIdPrefix="device.joe.request" -> the topic is something like "device.joe.request135823058558"destroyDelay
- historyMaxMsg
-
XmlBlasterException
public MsgUnit[] request(MsgUnit msgUnit, long timeout, int maxEntries) throws XmlBlasterException
I_XmlBlasterAccess
The msgUnit should contain a PublishQos which routes the request
to the desired client, for example sending it to client joe
and its login session 1
or sending it to a topic which was subscribed
by the destination client:
import org.xmlBlaster.util.qos.address.Destination; import org.xmlBlaster.client.qos.PublishQos; ... Global glob = ...; ... PublishQos pq = new PublishQos(glob); Destination dest = new Destination(glob, new SessionName(glob, "joe/1")); dest.forceQueuing(true); pq.addDestination(dest);
This receiver needs to send the response to the topic oid as passed with the client property "__jms:JMSReplyTo":
String tempTopicOid = updateQos.getClientProperty(Constants.JMS_REPLY_TO, ""); // Send reply back ... PublishKey pk = new PublishKey(glob, tempTopicOid); ...
This approach is similar to the JMS approach for request/reply (TopicRequestor.java) but we have the choice to send the msgUnit directly to another client or to a topic (as JMS), and we can handle multiple replies for one request.
The feature is implemented on client side with a temporary response topic and a receive()
call.
The temporary response topic is erased after the response has arrived.
You can optionally add a clientProperty "__responseTopicIdPrefix", this topicId is
used as a prefix for the temporary response topicId. the given prefix must be unique
between clients. This is thread safe.
A use case could be to simplify detecting the topic for an authorizer plugin.
You can optionally add a clientProperty "__responseTopicId" with a unique topicId
to avoid the creation of temporary response topics, note that this feature
is NOT thread safe, the client may only send one request() at a time.
The response topic will live for one day after last usage.
A reason to do so could be the better performance (avoid short living temporary response topics).
Please note the timeout limitation as described at
I_XmlBlasterAccess.receive(String, int, long, boolean)
)
request
in interface I_XmlBlasterAccess
msgUnit
- The request to send. The topicId may be any you wish for the receiver to recognize.
If the receiver has not subsribed on this topicId you need to send it PtP (add the Destination client).timeout
- The milliseconds to block, 0 is none blocking, -1 blocks forevermaxEntries
- The maximum number of entries to deliver or return with less after timeout
XmlBlasterException
org.xmlBlaster.test.client.TestRequestResponse
public MsgUnit[] receive(java.lang.String oid, int maxEntries, long timeout, boolean consumable) throws XmlBlasterException
I_XmlBlasterAccess
This is a convenience method which uses get() with a specific Qos.
Important note:
Currently you shouldn't use unlimited timeout==-1 as this could
lead to a server side thread leak on client disconnect.
As a workaround please use a loop and a timeout of for example 60000
and just ignore returned arrays of length 0.
receive
in interface I_XmlBlasterAccess
oid
- The identifier like
"topic/hello" to access a history queue,
"client/joe" to access a subject queue or
"client/joe/session/1"
to access a callback queue.
The string must follow the formatting rule of ContextNode.javamaxEntries
- The maximum number of entries to retrievetimeout
- The time to wait until return.
If you choose a negative value it will block until the maxEntries
has been reached.
If the value is '0' (i.e. zero) it will not wait and will correspond to a non-blocking get.
If the value is positive it will block until the specified amount in milliseconds
has elapsed or when the maxEntries has been reached (whichever comes first).consumable
- Expressed with 'true' or 'false'.
If true the entries returned are deleted from the queue
XmlBlasterException
ContextNode
,
engine.qos.queryspec.QueueQuery requirement,
MessageConsumer.receive()
public PublishReturnQos[] publishStream(java.io.InputStream is, MsgKeyData keyData, MsgQosData qosData, int maxBufSize, I_ReplaceContent contentReplacer) throws XmlBlasterException
I_XmlBlasterAccess
publishStream
in interface I_XmlBlasterAccess
is
- The input stream from which to read the input data.keyData
- The key for the message (same for all chunks)qosData
- The qos for all messages (same for all chunks besides internal stuff added in this method)maxBufSize
- The maximum content size of each chunk.contentReplacer
- an optional content replacer (i.e. a modifier of the content) can be null.
XmlBlasterException
public java.lang.Object getUserObject()
I_XmlBlasterAccess
getUserObject
in interface I_XmlBlasterAccess
public void setUserObject(java.lang.Object userObject)
I_XmlBlasterAccess
setUserObject
in interface I_XmlBlasterAccess
userObject
- any user object
|
xmlBlaster 2.2.0 client API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |