|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xmlBlaster.client.StreamingCallback
public class StreamingCallback
StreamingCallback
Nested Class Summary | |
---|---|
(package private) class |
StreamingCallback.ExecutionThread
|
(package private) class |
StreamingCallback.Writer
Writer needed since the out stream must be written from a thread which does not die before the thread which reads the in counterpart. |
Field Summary | |
---|---|
private I_StreamingCallback |
callback
|
private java.lang.String |
cbSessionId
|
static java.lang.String |
ENTRY_CB_SESSION_ID
|
private XmlBlasterException |
ex
|
private Global |
global
|
private java.io.PipedInputStream |
in
|
private boolean |
initialized
|
private boolean |
lastMessageCompleted
|
private static java.util.logging.Logger |
log
|
private java.util.concurrent.locks.ReentrantLock |
mutex
|
private java.io.PipedOutputStream |
out
|
private I_Queue |
queue
|
private java.lang.String |
ret
|
private Timeout |
timer
|
private Timestamp |
timestamp
|
private boolean |
useQueue
|
private long |
waitForChunksTimeout
The time to wait in ms until returning when waiting (if zero or negative inifinite) |
private StreamingCallback.Writer |
writer
|
Constructor Summary | |
---|---|
StreamingCallback(Global global,
I_StreamingCallback callback)
|
|
StreamingCallback(Global global,
I_StreamingCallback callback,
long waitForChunksTimeout,
long waitForClientReturnTimeout,
boolean useQueue)
|
Method Summary | |
---|---|
private void |
clearQueue()
|
private void |
consumeExceptionIfNotNull()
returns the exception (if any) and resets it. |
private ClientProperty |
getProp(java.lang.String key,
UpdateQos qos)
|
private boolean |
isFirstChunk(UpdateQos qos)
|
private boolean |
isLastChunk(UpdateQos qos)
|
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. |
private void |
reset()
|
int |
sendInitialQueueEntries()
|
private void |
setException(java.lang.Throwable ex)
Always makes a USER_UPDATE_HOLDBACK Exception out of it, no matter what the original exception was. |
private void |
storeEntry(java.lang.String cbSessId,
UpdateKey key,
byte[] cont,
UpdateQos qos)
|
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. |
private java.lang.String |
updateInternal(java.lang.String cbSessId,
UpdateKey updKey,
byte[] cont,
UpdateQos updQos,
boolean isExternal)
|
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 |
---|
private static java.util.logging.Logger log
public static final java.lang.String ENTRY_CB_SESSION_ID
private I_StreamingCallback callback
private Global global
private java.io.PipedOutputStream out
private java.io.PipedInputStream in
private XmlBlasterException ex
private java.lang.String ret
private java.lang.String cbSessionId
private StreamingCallback.Writer writer
private long waitForChunksTimeout
private Timeout timer
private Timestamp timestamp
private I_Queue queue
private boolean useQueue
private boolean initialized
private boolean lastMessageCompleted
private final java.util.concurrent.locks.ReentrantLock mutex
Constructor Detail |
---|
public StreamingCallback(Global global, I_StreamingCallback callback) throws XmlBlasterException
XmlBlasterException
public StreamingCallback(Global global, I_StreamingCallback callback, long waitForChunksTimeout, long waitForClientReturnTimeout, boolean useQueue) throws XmlBlasterException
callback
-
XmlBlasterException
Method Detail |
---|
private void reset() throws XmlBlasterException
XmlBlasterException
public final int sendInitialQueueEntries() throws XmlBlasterException
XmlBlasterException
private final void storeEntry(java.lang.String cbSessId, UpdateKey key, byte[] cont, UpdateQos qos) throws XmlBlasterException
XmlBlasterException
public java.lang.String updateStraight(java.lang.String cbSessId, UpdateKey updKey, byte[] cont, UpdateQos updQos) throws XmlBlasterException, java.io.IOException
XmlBlasterException
java.io.IOException
I_Callback.update(java.lang.String, org.xmlBlaster.client.key.UpdateKey, byte[], org.xmlBlaster.client.qos.UpdateQos)
public java.lang.String updateNewMessage(java.lang.String cbSessId, UpdateKey updKey, byte[] cont, UpdateQos updQos) throws XmlBlasterException, java.io.IOException
XmlBlasterException
java.io.IOException
I_Callback.update(java.lang.String, org.xmlBlaster.client.key.UpdateKey, byte[], org.xmlBlaster.client.qos.UpdateQos)
private final boolean isFirstChunk(UpdateQos qos)
private final boolean isLastChunk(UpdateQos qos)
private final ClientProperty getProp(java.lang.String key, UpdateQos qos)
public java.lang.String update(java.lang.String cbSessId, UpdateKey updKey, byte[] cont, UpdateQos updQos) throws XmlBlasterException
I_Callback
update
in interface I_Callback
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 namecont
- The arrived message content. This is your payload.
XmlBlasterException
I_Callback.update(java.lang.String, org.xmlBlaster.client.key.UpdateKey, byte[], org.xmlBlaster.client.qos.UpdateQos)
private final java.lang.String updateInternal(java.lang.String cbSessId, UpdateKey updKey, byte[] cont, UpdateQos updQos, boolean isExternal) throws XmlBlasterException
XmlBlasterException
I_Callback.update(java.lang.String, org.xmlBlaster.client.key.UpdateKey, byte[], org.xmlBlaster.client.qos.UpdateQos)
public void timeout(java.lang.Object userData)
timeout
in interface I_Timeout
userData
- You get bounced back your userData which you passed
with Timeout.addTimeoutListener()I_Timeout.timeout(java.lang.Object)
private final void clearQueue()
private void setException(java.lang.Throwable ex)
ex
- private void consumeExceptionIfNotNull() throws XmlBlasterException
XmlBlasterException
public void reachedAlive(ConnectionStateEnum oldState, I_XmlBlasterAccess connection)
I_ConnectionStateListener
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.
reachedAlive
in interface I_ConnectionStateListener
oldState
- 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_ConnectionStateListener
oldState
- is always ALIVE.I_ConnectionStateListener.reachedAlive(org.xmlBlaster.util.dispatch.ConnectionStateEnum, org.xmlBlaster.client.I_XmlBlasterAccess)
public void reachedDead(ConnectionStateEnum oldState, I_XmlBlasterAccess connection)
I_ConnectionStateListener
reachedDead
in interface I_ConnectionStateListener
oldState
- The previous state of the connection.public void reachedPolling(ConnectionStateEnum oldState, I_XmlBlasterAccess connection)
I_ConnectionStateListener
reachedPolling
in interface I_ConnectionStateListener
oldState
- The previous state of the connection.
|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |