Errai 3.0.1-SNAPSHOT

org.jboss.errai.bus.server
Class MessageQueueImpl

java.lang.Object
  extended by org.jboss.errai.bus.server.MessageQueueImpl
All Implemented Interfaces:
MessageQueue

public class MessageQueueImpl
extends Object
implements MessageQueue

A message queue is keeps track of which messages need to be sent outbound. It keeps track of the amount of messages that can be stored, transmitted and those which timeout. The MessageQueue is implemented using a LinkedBlockingQueue to store the messages, and a ServerMessageBus to send the messages.


Constructor Summary
MessageQueueImpl(TransmissionBuffer buffer, QueueSession session, int timeoutSecs)
           
 
Method Summary
 void discard()
           
 void finishInit()
           
 void fireActivationCallback()
           
 QueueActivationCallback getActivationCallback()
          Returns the current activation callback function
 Object getActivationLock()
           
 Buffer getBuffer()
           
 BufferColor getBufferColor()
           
 long getCurrentBufferSequenceNumber()
           
 MessageDeliveryHandler getDeliveryHandler()
           
 long getLastTransmissionTime()
           
 Object getPageLock()
           
 QueueSession getSession()
           
 void heartBeat()
          Fakes a transmission, shows life with a heartbeat
 int incrementMessageCount()
           
 boolean isInitialized()
           
 boolean isPaged()
           
 boolean isStale()
          Returns true if the queue is not running, or it has timed out
 boolean messagesWaiting()
           
 boolean offer(Message message)
          Inserts the specified message into the queue, and returns true if it was successful
 boolean poll(ByteWriteAdapter stream)
           
 boolean poll(TimeUnit timeUnit, int time, ByteWriteAdapter stream)
           
 void resetMessageCount()
           
 void setActivationCallback(QueueActivationCallback activationCallback)
          Sets the activation callback function which is called when the queue is scheduled for activation
 void setDeliveryHandler(MessageDeliveryHandler handler)
           
 void setDeliveryHandlerToDefault()
           
 void setPaged(boolean pagedOut)
           
 void setTimeout(long timeout)
           
 void stopQueue()
          Stops the queue, closes it on the bus and clears it completely
 String toString()
           
 void wake()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MessageQueueImpl

public MessageQueueImpl(TransmissionBuffer buffer,
                        QueueSession session,
                        int timeoutSecs)
Method Detail

poll

public boolean poll(ByteWriteAdapter stream)
             throws IOException
Specified by:
poll in interface MessageQueue
Throws:
IOException

poll

public boolean poll(TimeUnit timeUnit,
                    int time,
                    ByteWriteAdapter stream)
             throws IOException
Specified by:
poll in interface MessageQueue
Throws:
IOException

offer

public boolean offer(Message message)
              throws IOException
Inserts the specified message into the queue, and returns true if it was successful

Specified by:
offer in interface MessageQueue
Parameters:
message - - the message to insert into the queue
Returns:
true if insertion was successful
Throws:
IOException

getCurrentBufferSequenceNumber

public long getCurrentBufferSequenceNumber()
Specified by:
getCurrentBufferSequenceNumber in interface MessageQueue

wake

public void wake()
Specified by:
wake in interface MessageQueue

setActivationCallback

public void setActivationCallback(QueueActivationCallback activationCallback)
Sets the activation callback function which is called when the queue is scheduled for activation

Specified by:
setActivationCallback in interface MessageQueue
Parameters:
activationCallback - - new activation callback function

fireActivationCallback

public void fireActivationCallback()
Specified by:
fireActivationCallback in interface MessageQueue

getActivationCallback

public QueueActivationCallback getActivationCallback()
Returns the current activation callback function

Specified by:
getActivationCallback in interface MessageQueue
Returns:
the current activation callback function

getSession

public QueueSession getSession()
Specified by:
getSession in interface MessageQueue

isStale

public boolean isStale()
Returns true if the queue is not running, or it has timed out

Specified by:
isStale in interface MessageQueue
Returns:
true if the queue is stale

isInitialized

public boolean isInitialized()
Specified by:
isInitialized in interface MessageQueue

messagesWaiting

public boolean messagesWaiting()
Specified by:
messagesWaiting in interface MessageQueue

heartBeat

public void heartBeat()
Fakes a transmission, shows life with a heartbeat

Specified by:
heartBeat in interface MessageQueue

finishInit

public void finishInit()
Specified by:
finishInit in interface MessageQueue

isPaged

public boolean isPaged()
Specified by:
isPaged in interface MessageQueue

setPaged

public void setPaged(boolean pagedOut)
Specified by:
setPaged in interface MessageQueue

discard

public void discard()
Specified by:
discard in interface MessageQueue

stopQueue

public void stopQueue()
Stops the queue, closes it on the bus and clears it completely

Specified by:
stopQueue in interface MessageQueue

getActivationLock

public Object getActivationLock()
Specified by:
getActivationLock in interface MessageQueue

getPageLock

public Object getPageLock()
Specified by:
getPageLock in interface MessageQueue

getDeliveryHandler

public MessageDeliveryHandler getDeliveryHandler()
Specified by:
getDeliveryHandler in interface MessageQueue

setDeliveryHandler

public void setDeliveryHandler(MessageDeliveryHandler handler)
Specified by:
setDeliveryHandler in interface MessageQueue

setDeliveryHandlerToDefault

public void setDeliveryHandlerToDefault()
Specified by:
setDeliveryHandlerToDefault in interface MessageQueue

getBufferColor

public BufferColor getBufferColor()
Specified by:
getBufferColor in interface MessageQueue

getBuffer

public Buffer getBuffer()
Specified by:
getBuffer in interface MessageQueue

incrementMessageCount

public int incrementMessageCount()
Specified by:
incrementMessageCount in interface MessageQueue

resetMessageCount

public void resetMessageCount()
Specified by:
resetMessageCount in interface MessageQueue

getLastTransmissionTime

public long getLastTransmissionTime()
Specified by:
getLastTransmissionTime in interface MessageQueue

setTimeout

public void setTimeout(long timeout)
Specified by:
setTimeout in interface MessageQueue

toString

public String toString()
Overrides:
toString in class Object

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.