CSMessageQueue
in package
implements
IMessageProxy
Tags
Interfaces, Classes and Traits
- IMessageProxy
- This interface is a requirement for any class that acts as a message proxy, provided as an argument to CSMessageQueue::displatchMessageWithId.
Table of Contents
- acknowledge() : void
- IMessageProxy interface method
- addMessageToQueue() : bool
- Adds a message to the queue. Same as calling "queue()" on mesage API.
- addMessageWithArgumentsToQueue() : CSMessage
- Adds a new message to the queue based on the provided arguments.
- cleanupMessages() : void
- Does a cleanup on the message queue by deleting messages that are completed or were not able to get delivered. This method should be called once in a while to make sure the message table is not becoming too big.
- createMessage() : CSMessage
- Creates a new message instance based on the provided parameters.
- decline() : void
- IMessageProxy interface method
- dispatchMessageWithId() : void
- Dispatches the message with the specified id. This means that the target object of that message is instanciated and the "onMessage"-method gets called. Via the "IMessage" protocol the proxy is informed about the results.
- fail() : void
- IMessageProxy interface method
- getBatchIdsForStatus() : array<string|int, mixed>
- Returns a list of batch ids for the provided status
- getNextMessageBatch() : CSMessageQueueBatch
- Reserves and returns the next batch of messages. It is assumed that after calling this method the batch is processed and every single message id is dispatched via CSMessageQueue::dispatchMessageWithId.
- getNumberOfBatchesReadyToBeProcessed() : int
- getRemainingAttemptsForMessageWithId() : int
- Returns the number of remaining attempts for the message with the specified id.
- ignore() : void
- IMessageProxy interface method
- isBatchWithIdLocked() : bool
- Checks if the batch with the specified id is currently locked.
- lockBatchWithId() : bool
- Locks the batch with the specified id to indicate that it is currently processed
- logMessage() : void
- IMessageProxy interface method
- resetForBatchId() : void
- Resets a batch and sets it to "waiting" status. After the wait timeout is reached it is set back to "ready" so it can be picked up by other processes.
Methods
acknowledge()
IMessageProxy interface method
public
acknowledge(int $iMessageId) : void
Parameters
- $iMessageId : int
-
The id of the message that has been acknowledged
Tags
Return values
void —addMessageToQueue()
Adds a message to the queue. Same as calling "queue()" on mesage API.
public
static addMessageToQueue(CSMessage $oMessage) : bool
Parameters
- $oMessage : CSMessage
Tags
Return values
bool —True if message was added to queue successfully, otherwise false.
addMessageWithArgumentsToQueue()
Adds a new message to the queue based on the provided arguments.
public
static addMessageWithArgumentsToQueue(string $sName, int $iType, object $oTarget[, array<string|int, mixed> $aArguments = array() ]) : CSMessage
Parameters
- $sName : string
-
The name of the message.
- $iType : int
-
The type of the message as one of the CSMessageConst::TYPE_* constants
- $oTarget : object
-
The target object matching the type parameter
- $aArguments : array<string|int, mixed> = array()
-
The arguments for the message.
Tags
Return values
CSMessage —The newly created message.
cleanupMessages()
Does a cleanup on the message queue by deleting messages that are completed or were not able to get delivered. This method should be called once in a while to make sure the message table is not becoming too big.
public
static cleanupMessages() : void
Tags
Return values
void —createMessage()
Creates a new message instance based on the provided parameters.
public
static createMessage(string $sName, int $iType, object $oTarget) : CSMessage
Parameters
- $sName : string
-
The name of the message.
- $iType : int
-
The type of the message as one of the CSMessageConst::TYPE_* constants
- $oTarget : object
-
The target object matching the type parameter
Tags
Return values
CSMessage —The newly created message.
decline()
IMessageProxy interface method
public
decline(int $iMessageId) : void
Parameters
- $iMessageId : int
-
The id of the message that has been declined
Tags
Return values
void —dispatchMessageWithId()
Dispatches the message with the specified id. This means that the target object of that message is instanciated and the "onMessage"-method gets called. Via the "IMessage" protocol the proxy is informed about the results.
public
static dispatchMessageWithId(int $iMessageId, IMessageProxy $oMessageProxy[, bool $bAsync = false ]) : void
Parameters
- $iMessageId : int
-
The id of the message to be dispatched.
- $oMessageProxy : IMessageProxy
-
The proxy which will receive information about results.
- $bAsync : bool = false
Tags
Return values
void —fail()
IMessageProxy interface method
public
fail(int $iMessageId) : void
Parameters
- $iMessageId : int
-
The id of the message that failed
Tags
Return values
void —getBatchIdsForStatus()
Returns a list of batch ids for the provided status
public
static getBatchIdsForStatus(int $iStatus) : array<string|int, mixed>
Parameters
- $iStatus : int
-
The status to filter for as one of the CSMessageConst::STATUS_* constants.
Tags
Return values
array<string|int, mixed> —The list of batch ids with the provided status.
getNextMessageBatch()
Reserves and returns the next batch of messages. It is assumed that after calling this method the batch is processed and every single message id is dispatched via CSMessageQueue::dispatchMessageWithId.
public
static getNextMessageBatch() : CSMessageQueueBatch
Tags
Return values
CSMessageQueueBatch —The message batch object containing the batch id and messages belonging to it.
getNumberOfBatchesReadyToBeProcessed()
public
static getNumberOfBatchesReadyToBeProcessed() : int
Tags
Return values
int —getRemainingAttemptsForMessageWithId()
Returns the number of remaining attempts for the message with the specified id.
public
static getRemainingAttemptsForMessageWithId(int $iMessageId) : int
Parameters
- $iMessageId : int
-
The id of the message for which the remaining attempts should be calculated.
Tags
Return values
int —The number of remaining delivery attempts for the message with the specified id.
ignore()
IMessageProxy interface method
public
ignore(int $iMessageId) : void
Parameters
- $iMessageId : int
-
The id of the message that has been ignored
Tags
Return values
void —isBatchWithIdLocked()
Checks if the batch with the specified id is currently locked.
public
static isBatchWithIdLocked(string $sBatchId) : bool
Parameters
- $sBatchId : string
-
The batch id to check
Tags
Return values
bool —True if batch with specified id is locked, otherwise false
lockBatchWithId()
Locks the batch with the specified id to indicate that it is currently processed
public
static lockBatchWithId(string $sBatchId) : bool
Parameters
- $sBatchId : string
-
The batch id to lock
Tags
Return values
bool —True, if the batch has been locked, otherwise false
logMessage()
IMessageProxy interface method
public
logMessage(mixed $sMessage[, mixed $iType = CSMessageConst::LOG_TYPE_INFO ]) : void
Parameters
- $sMessage : mixed
-
The message to be logged
- $iType : mixed = CSMessageConst::LOG_TYPE_INFO
-
The message type as one of the CSMessageConst::LOG_TYPE_* constants
Tags
Return values
void —resetForBatchId()
Resets a batch and sets it to "waiting" status. After the wait timeout is reached it is set back to "ready" so it can be picked up by other processes.
public
static resetForBatchId(string $sBatchId) : void
Parameters
- $sBatchId : string
-
The batch id that should be reset.
