Download the PHP package m6web/redis-message-broker without Composer
On this page you can find all versions of the php package m6web/redis-message-broker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package redis-message-broker
RedisMessageBroker
This component will help you to build a messages brocker system over a redis backend. It will take advantage of the redis cluster capabilities with the possibility to shard messages into several redis lists while producing messages. Consumer, in no auto-ack mode, implements a working list to be sure not to loose any messages when processing fail.
By design, producing is super fast (one Redis command) and consuming can be slow if you want to ack messages manually.
You should use it with Redis >= 2.8.
usage
producer
consumer
Consumer should be wrapped in a worker. A unique Id should be pass to the consumer constructor. If you work with a worker, uniqId has to be constant per worker.
inspector
Inspector methods allow you to count the messages in ready or processing in a queue.
cleanup
Cleanup methods let you perform a cleanup in the message queue. Cleanup is very slow as all the message in the queue will be scanned.
queue option
To avoid hotpsots you can shard a queue on several lists :
In this mode, messages will be written and read among the 10 lists. FIFO is no more guaranteed.
consumer options
manual message acknowledgment
with setNoAutoAck()
look for old messages not acked by consumers
Each consumer got an unique Id defined during the construction of the object. This Id allow the consumer to define a unique working list where a message is stored between the getMessage
and the ack
.
Is it possible to use LostMessageConsumer class to look on consumer working lists and move message more than x second old (messageTtl
parameter) from those lists to a queue list.
The maxRetry
parameter will put a message in a dead letter list when the retry number is reached.
messageTtl
parameter need to be superior of your max time to process a message. (Otherwise it will consider a message old when its processing)