atheriel / longears

The RabbitMQ client for R
https://atheriel.github.io/longears/
36 stars 9 forks source link

Can't get Direct Reply-to to work #23

Open martinschueller opened 9 months ago

martinschueller commented 9 months ago

For Sending and immediatly receiving messages, RabbitMQ has the Direct Reply-To feature: https://www.rabbitmq.com/direct-reply-to.html

I can't get it to work with this code, even though there's no error in the consumer or the queue and the message is sent back:

library(longears)

conn <- amqp_connect()

consumer <- amqp_consume(
    conn = conn,
    no_ack = TRUE,
    # prefetch_count = 1,
    timeout = 15,   
    queue = "amq.rabbitmq.reply-to",
    fun = function(msg) {
      received <<- received + 1
})

amqp_publish(conn, '{"content":1707163749285}', exchange = "", routing_key = "QUEUE_NAME", properties=amqp_properties(content_type="application/json", reply_to="amq.rabbitmq.reply-to.bdwkehdwhecbhjwe", delivery_mode=2))

while (TRUE) {
  amqp_listen(conn, timeout = 15)
}