xmlBlaster 2.2.0 client API

org.xmlBlaster.client
Class StreamingCallback

java.lang.Object
  extended by org.xmlBlaster.client.StreamingCallback
All Implemented Interfaces:
I_Callback, I_ConnectionStateListener, I_Timeout

public class StreamingCallback
extends java.lang.Object
implements I_Callback, I_Timeout, I_ConnectionStateListener

StreamingCallback

Author:
Michele Laghi

Field Summary
static java.lang.String ENTRY_CB_SESSION_ID
           
 
Constructor Summary
StreamingCallback(Global global, I_StreamingCallback callback)
           
StreamingCallback(Global global, I_StreamingCallback callback, long waitForChunksTimeout, long waitForClientReturnTimeout, boolean useQueue)
           
 
Method Summary
 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.
 int sendInitialQueueEntries()
           
 void timeout(java.lang.Object userData)
          It is used here to inform the user update method that a timeout occured, it will throw an IOException when reading the in stream of the update method.
 java.lang.String update(java.lang.String cbSessId, UpdateKey updKey, byte[] cont, UpdateQos updQos)
          This is the callback method invoked from I_XmlBlasterAccess informing the client in an asynchronous mode about a new message.
 java.lang.String updateNewMessage(java.lang.String cbSessId, UpdateKey updKey, byte[] cont, UpdateQos updQos)
           
 java.lang.String updateStraight(java.lang.String cbSessId, UpdateKey updKey, byte[] cont, UpdateQos updQos)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENTRY_CB_SESSION_ID

public static final java.lang.String ENTRY_CB_SESSION_ID
See Also:
Constant Field Values
Constructor Detail

StreamingCallback

public StreamingCallback(Global global,
                         I_StreamingCallback callback)
                  throws XmlBlasterException
Throws:
XmlBlasterException

StreamingCallback

public StreamingCallback(Global global,
                         I_StreamingCallback callback,
                         long waitForChunksTimeout,
                         long waitForClientReturnTimeout,
                         boolean useQueue)
                  throws XmlBlasterException
Parameters:
callback -
Throws:
XmlBlasterException
Method Detail

sendInitialQueueEntries

public final int sendInitialQueueEntries()
                                  throws XmlBlasterException
Returns:
the number of delivered entries from local client update queue.
Throws:
XmlBlasterException

updateStraight

public java.lang.String updateStraight(java.lang.String cbSessId,
                                       UpdateKey updKey,
                                       byte[] cont,
                                       UpdateQos updQos)
                                throws XmlBlasterException,
                                       java.io.IOException
Throws:
XmlBlasterException
java.io.IOException
See Also:
I_Callback.update(java.lang.String, org.xmlBlaster.client.key.UpdateKey, byte[], org.xmlBlaster.client.qos.UpdateQos)

updateNewMessage

public java.lang.String updateNewMessage(java.lang.String cbSessId,
                                         UpdateKey updKey,
                                         byte[] cont,
                                         UpdateQos updQos)
                                  throws XmlBlasterException,
                                         java.io.IOException
Throws:
XmlBlasterException
java.io.IOException
See Also:
I_Callback.update(java.lang.String, org.xmlBlaster.client.key.UpdateKey, byte[], org.xmlBlaster.client.qos.UpdateQos)

update

public java.lang.String update(java.lang.String cbSessId,
                               UpdateKey updKey,
                               byte[] cont,
                               UpdateQos updQos)
                        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:
cbSessId - 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.
updKey - The arrived key containing the topic name
cont - The arrived message content. This is your payload.
Throws:
XmlBlasterException
See Also:
I_Callback.update(java.lang.String, org.xmlBlaster.client.key.UpdateKey, byte[], org.xmlBlaster.client.qos.UpdateQos)

timeout

public void timeout(java.lang.Object userData)
It is used here to inform the user update method that a timeout occured, it will throw an IOException when reading the in stream of the update method.

Specified by:
timeout in interface I_Timeout
Parameters:
userData - You get bounced back your userData which you passed with Timeout.addTimeoutListener()
See Also:
I_Timeout.timeout(java.lang.Object)

reachedAlive

public void reachedAlive(ConnectionStateEnum oldState,
                         I_XmlBlasterAccess connection)
Description copied from interface: I_ConnectionStateListener
This is the callback method invoked from XmlBlasterAccess notifying the client that a connection has been established and that its status is now ALIVE.

Note 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.

Specified by:
reachedAlive in interface I_ConnectionStateListener
Parameters:
oldState - The previous state of the connection.
See Also:
I_ConnectionStateListener.reachedAlive(org.xmlBlaster.util.dispatch.ConnectionStateEnum, org.xmlBlaster.client.I_XmlBlasterAccess)

reachedAliveSync

public void reachedAliveSync(ConnectionStateEnum oldState,
                             I_XmlBlasterAccess connection)
Description copied from interface: I_ConnectionStateListener
Invoked when the dispatcher goes to synch again after having delivered entries which where in the queue when the state changed to ALIVE. Note that this could take some time or in the worst case it could never been invoked if the queue is never completely processed.

Specified by:
reachedAliveSync in interface I_ConnectionStateListener
Parameters:
oldState - is always ALIVE.
See Also:
I_ConnectionStateListener.reachedAlive(org.xmlBlaster.util.dispatch.ConnectionStateEnum, org.xmlBlaster.client.I_XmlBlasterAccess)

reachedDead

public void reachedDead(ConnectionStateEnum oldState,
                        I_XmlBlasterAccess connection)
Description copied from interface: I_ConnectionStateListener
This is the callback method invoked from XmlBlasterAccess informing the client that the connection was lost (i.e. when the state of the connection has gone to DEAD).

Specified by:
reachedDead in interface I_ConnectionStateListener
Parameters:
oldState - The previous state of the connection.

reachedPolling

public void reachedPolling(ConnectionStateEnum oldState,
                           I_XmlBlasterAccess connection)
Description copied from interface: I_ConnectionStateListener
This is the callback method invoked from XmlBlasterAccess informing the client that the connection state has changed to POLLING.

Specified by:
reachedPolling in interface I_ConnectionStateListener
Parameters:
oldState - The previous state of the connection.

xmlBlaster 2.2.0 client API

Copyright © 1999-2014 The xmlBlaster.org contributers.