Download the PHP package eislambey/rsmq without Composer
On this page you can find all versions of the php package eislambey/rsmq. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package rsmq
Redis Simple Message Queue
A lightweight message queue for PHP that requires no dedicated queue server. Just a Redis server.
PHP implementation of smrchy/rsmq
Installation
composer require eislambey/rsmq
Methods
Construct
Creates a new instance of RSMQ.
Parameters:
$redis
(Redis): *required The Redis instance$ns
(string): optional (Default: "rsmq") The namespace prefix used for all keys created by RSMQ$realtime
(Boolean): optional (Default: false) Enable realtime PUBLISH of new messages
Example:
Queue
createQueue
Create a new queue.
Parameters:
$name
(string): The Queue name. Maximum 160 characters; alphanumeric characters, hyphens (-), and underscores (_) are allowed.$vt
(int): optional (Default: 30) The length of time, in seconds, that a message received from a queue will be invisible to other receiving components when they ask to receive messages. Allowed values: 0-9999999 (around 115 days)$delay
(int): optional (Default: 0) The time in seconds that the delivery of all new messages in the queue will be delayed. Allowed values: 0-9999999 (around 115 days)$maxsize
(int): optional (Default: 65536) The maximum message size in bytes. Allowed values: 1024-65536 and -1 (for unlimited size)
Returns:
true
(Bool)
Throws:
\Islambey\RSMQ\Exception
Example:
listQueues
List all queues
Returns an array:
["qname1", "qname2"]
Example:
deleteQueue
Deletes a queue and all messages.
Parameters:
$name
(string): The Queue name.
Returns:
true
(Bool)
Throws:
\Islambey\RSMQ\Exception
Example:
getQueueAttributes
Get queue attributes, counter and stats
Parameters:
$queue
(string): The Queue name.
Returns an associative array:
vt
(int): The visibility timeout for the queue in secondsdelay
(int): The delay for new messages in secondsmaxsize
(int): The maximum size of a message in bytestotalrecv
(int): Total number of messages received from the queuetotalsent
(int): Total number of messages sent to the queuecreated
(float): Timestamp (epoch in seconds) when the queue was createdmodified
(float): Timestamp (epoch in seconds) when the queue was last modified withsetQueueAttributes
msgs
(int): Current number of messages in the queuehiddenmsgs
(int): Current number of hidden / not visible messages. A message can be hidden while "in flight" due to avt
parameter or when sent with adelay
Example:
setQueueAttributes
Sets queue parameters.
Parameters:
$queue
(string): The Queue name.$vt
(int): optional * The length of time, in seconds, that a message received from a queue will be invisible to other receiving components when they ask to receive messages. Allowed values: 0-9999999 (around 115 days)$delay
(int): optional The time in seconds that the delivery of all new messages in the queue will be delayed. Allowed values: 0-9999999 (around 115 days)$maxsize
(int): optional The maximum message size in bytes. Allowed values: 1024-65536 and -1 (for unlimited size)
Note: At least one attribute (vt, delay, maxsize) must be supplied. Only attributes that are supplied will be modified.
Returns an associative array:
vt
(int): The visibility timeout for the queue in secondsdelay
(int): The delay for new messages in secondsmaxsize
(int): The maximum size of a message in bytestotalrecv
(int): Total number of messages received from the queuetotalsent
(int): Total number of messages sent to the queuecreated
(float): Timestamp (epoch in seconds) when the queue was createdmodified
(float): Timestamp (epoch in seconds) when the queue was last modified withsetQueueAttributes
msgs
(int): Current number of messages in the queuehiddenmsgs
(int): Current number of hidden / not visible messages. A message can be hidden while "in flight" due to avt
parameter or when sent with adelay
Throws:
\Islambey\RSMQ\Exception
Example:
Messages
sendMessage
Sends a new message.
Parameters:
$queue
(string)$message
(string)$delay
(int): optional (Default: queue settings) The time in seconds that the delivery of the message will be delayed. Allowed values: 0-9999999 (around 115 days)
Returns:
$id
(string): The internal message id.
Throws:
\Islambey\RSMQ\Exception
Example:
receiveMessage
Receive the next message from the queue.
Parameters:
$queue
(string): The Queue name.$vt
(int): optional (Default: queue settings) The length of time, in seconds, that the received message will be invisible to others. Allowed values: 0-9999999 (around 115 days)
Returns an associative array:
message
(string): The message's contents.id
(string): The internal message id.sent
(int): Timestamp of when this message was sent / created.fr
(int): Timestamp of when this message was first received.rc
(int): Number of times this message was received.
Note: Will return an empty array if no message is there
Throws:
\Islambey\RSMQ\Exception
Example:
deleteMessage
Parameters:
$queue
(string): The Queue name.$id
(string): message id to delete.
Returns:
true
if successful,false
if the message was not found (bool).
Throws:
\Islambey\RSMQ\Exception
Example:
popMessage
Receive the next message from the queue and delete it.
Important: This method deletes the message it receives right away. There is no way to receive the message again if something goes wrong while working on the message.
Parameters:
$queue
(string): The Queue name.
Returns an associvative array:
message
(string): The message's contents.id
(string): The internal message id.sent
(int): Timestamp of when this message was sent / created.fr
(int): Timestamp of when this message was first received.rc
(int): Number of times this message was received.
Note: Will return an empty object if no message is there
Throws:
\Islambey\RSMQ\Exception
Example:
changeMessageVisibility
Change the visibility timer of a single message.
The time when the message will be visible again is calculated from the current time (now) + vt
.
Parameters:
qname
(string): The Queue name.id
(string): The message id.vt
(int): The length of time, in seconds, that this message will not be visible. Allowed values: 0-9999999 (around 115 days)
Returns:
true
if successful,false
if the message was not found (bool).
Throws:
\Islambey\RSMQ\Exception
Example:
LICENSE
The MIT LICENSE. See LICENSE
All versions of rsmq with dependencies
ext-mbstring Version *