Package: redismq
RedisMQDescriptionRedisMQ uses the redis stream data structure to effect a message queue. The stream key name is the id of the message queue.It provides support for confirmed and unconfirmed guaranteed message queuing. Guaranteed messages will remain in the queue (as unread or pending messages in the redis stream) until they are read and acknowledged by exactly one consumer. Confirmed producers will get a response only when the message is received and processed by a consumer. Unconfirmed (but guaranteed) still means only a single consumer will process the message, but no response is sent.RedisMQ also provides support for fan-out (pub/sub) messaging when zero or more subscribers should receive the message.RedisMQ libraries for Python and Javascript are available.RequirementsThe RedisMQ module requires Python 3.8 or higher.PrerequisitesInstall Python development headersOn Ubuntu/Debian systems or Microsoft Windows:apt-get install python-devOn Redhat/Fedora systems, install them with:yum install python-develOn Mac OSX:xcode-select --installInstallationTo install RedisMQ:$pipinstallredismqor from source:$pythonsetup.pyinstalltesting:pipenv install --devpipenv run pytestdebugging:export REDISMQ=DEBUG...Getting StartedRedisMQ needs to connect to an existing redis server, so you will need the address and port of the server you want to use. RedisMQ also stores global state in the redis server. By default the namespace used for global keys is rmq:*. If you need to change this so it does not conflict with other data stored in redis, the configuration parameter redismq_namespace should be set to something different.ExamplesHere are some examples of using the pyredismq module. Seemore exampleshere.Sending an unconfirmed messageFrom a Python shell we send an unconfirmed message:>>>importasyncio>>>fromredismqimportClient>>>asyncdefsendAMessage():...mq_connection=awaitClient.connect('redis://127.0.0.1')...my_producer=awaitmq_connection.producer('mystream')...print(awaitmy_producer.addUnconfirmedMessage('Hello there!'))...>>>asyncio.run(sendAMessage())"1601460642682-0"Sending a confirmed messageFrom a Python shell we send a confirmed message:>>>importasyncio>>>fromredismqimportClient>>>asyncdefsendAConfirmedMessage():...mq_connection=awaitClient.connect('redis://127.0.0.1')...my_producer=awaitmq_connection.producer('mystream')...response=awaitmy_producer.addConfirmedMessage('Hello there! Let me know when you get this.')...print('Got confirmation',response)...>>>asyncio.run(sendAConfirmedMessage())Consuming a messageFrom a Python shell we consume a message:>>>fromredismqimportClient>>>asyncdefreadAndConfirmMessage():>>>mq_connection=awaitClient.connect('redis://127.0.0.1')>>>my_consumer=awaitmq_connection.consumer('mystream','mygroup','consumer1')>>>payload=awaitmy_consumer.read()>>>print('Got message',payload.message)>>># here you can do something with the message>>># the response passed to ack() is optional,>>># and ignored if the original message was unconfirmed:>>>resp='I got your message'ifpayload.responseChannelelse''>>>awaitpayload.ack(resp)More InformationRedisMQ is free software under the New BSD license, see LICENSE.txt for
details.