RabbitMQ client library for R.
This package relies on the rabbitmq-c client. To install it run:
$ sudo apt-get install librabbitmq-dev
$ sudo yum install librabbitmq-devel
or, if you prefer, you can compile it yourself .
If you already installed the system dependencies, you can proceed to install the rabbitr R package.
devtools::install_github("lecardozo/rabbitr")
# connect to RabbitMQ server
conn <- rabbitr('localhost')
# create a channel
chan <- conn$channel()
# declare queue
chan$queue_declare('testing')
# publish message
chan$basic_publish(exchange='', routing_key='testing',
body='this is the message')
# connect to RabbitMQ server
conn <- rabbitr('localhost')
# create a channel
chan <- conn$channel()
# declare queue
chan$queue_declare('testing')
# define a callback to call for each message that arrives
callback <- function(envelope) { print(envelope$message) }
# start consumer
chan$basic_consume(callback, queue='testing')
# listen for incoming messages
chan$start_consuming()