If I use a RabbitMQ's direct Reply-To feature, which name of a queue I must use to peek a reply message without blocking via amqp_basic_get ?
Related
Using the remote procedure call pattern, I need to send an answer to a reply-queue, i.e. I need to send the message to the default exchange with the name of the queue as the routing key.
I am using the SmallRye Reactive Messing RabbitMQ plugin on Quarkus. All channels are defined statically in the configuration files (which is ok), however, due to the way the configuration mechanism works (microprofile config), I cannot use the empty string as a configuration value, which is the name of the default exchange.
It does not help to omit the name of the exchange, as by default the channel name is used.
Is there a way to send a message to the default exchange using the SmallRye RabbitMQ plugin?
Edit: I have no control over the RabbitMQ server.
You should be able to send messages to the default direct RabbitMQ exchange by setting below attributes:
exchange.name (set to empty string)
exchange.type (set to direct)
Assuming your Reactive Messaging channel is named pets-out, here down a configuration sample:
mp.messaging.outgoing.pets-out.connector=smallrye-rabbitmq
mp.messaging.outgoing.pets-out.exchange.name=
mp.messaging.outgoing.pets-out.exchange.declare=false
mp.messaging.outgoing.pets-out.exchange.type=direct
mp.messaging.outgoing.pets-out.default-routing-key=pets
EDIT
After digging into smallrye-reactive-messaging implementation, I figured out that an empty exchange name will cause a fallback to the channel name as the exchange name.
Hence, there should be no way to send direct messages to the default RabbitMQ exchange.
The alternative solution, neglecting the out-of-the-box offered default exchange would be to
Create a direct exchange without any bound queues and have the Outgoing message handler using a dedicated channel config bound to it:
mp.messaging.outgoing.pets-out.connector=smallrye-rabbitmq
mp.messaging.outgoing.pets-out.exchange.name=my-direct
mp.messaging.outgoing.pets-out.exchange.declare=true
mp.messaging.outgoing.pets-out.exchange.type=direct
mp.messaging.outgoing.pets-out.default-routing-key=pets
Create an alternate exchange configuration for the my-direct exchange routing messages to the default one. This can be operated on the RabbitMQ broker directly using rabbitmqctl:
rabbitmqctl set_policy AE "^my-direct$" '{"alternate-exchange":""}' --apply-to exchanges
I've got a Java application that uses RabbitMQ. This application creates a TOPIC exchange and pushes messages to the TOPIC with its own routing key. From this way if I want the data from any application I create a queue binding with the exchange TOPIC and the routing key I want to.
I want to do the same thing by using a Java application with Qpid JMS as the client and ActiveMQ as the server. The information says it's possible, but I don't know how. I cannot found a specific example seems to RabbitMQ. I can create queues but I don't know how to create the exchange and the binding. What steps should I follow to achieve it?
You might consider using ActiveMQ Artemis instead of ActiveMQ 5.x as the address model of Artemis is much more similar to RabbitMQ's than 5.x's address model (which is more JMS-centric).
As far as JMS goes I think what you need is:
A topic. This is analogous to the "exchange" from RabbitMQ. Any message sent to a JMS topic is delivered to every subscriber. It's basic publish/subscribe semantics.
A topic subscriber with a selector. As noted in #1, every subscriber on a topic will get any message sent to that topic, but a JMS "selector" can be used to filter messages similar to the routing key in RabbitMQ.
An agreed-upon key for a message property. In order to create a viable selector for the topic subscriber the producer and the subscriber must agree upon the property key to filter on.
If each subscription is going to have lots of messages and those messages need to be shared among multiple subscribers/consumers (e.g. for load-balancing/distribution) then you will need to use a JMS "shared subscription." However, shared subscriptions are only part of JMS 2 and only ActiveMQ Artemis implements JMS 2. You can't use ActiveMQ 5.x with JMS shared subscriptions as it only supports JMS 1.1.
Both ActiveMQ 5.x and ActiveMQ Artemis create server-side resources (e.g. topics, queues, etc.) on-demand by default so all you need to do is write your JMS application.
I try to send message to multiple queues according this documentation ActiveMQ Wildcards. The idea is to send message to PRICE.> queue and receive them in queues PRICE.STOCK.NASDAQ.ORCL and PRICE.STOCK.NYSE.IBM (queues are created). But instead of forwarding messages to PRICE.STOCK.NASDAQ.ORCL and PRICE.STOCK.NYSE.IBM activemq create new queue PRICE.> that become this message.
I tried to send message with activemq admin tool (send mask) and spring boot application. Behavior is the same - message is placed in new created queue PRICE.>.Activemq was not additionally configured, I'm using configuration provided with activemq 5.15.7.
The feature is only supported for subscribers, you need to send to a specific named destination when publishing a message. You can use the Virtual Destinations feature of ActiveMQ to define a target destination that forwards to some defined set.
I am using rabbitmq client (https://github.com/rabbitmq/rabbitmq-objc-client). I wanted to notify whether or not a message is sent to the rabbitmq server, but I couldn't find anything related to whether or not the message is really sent.
Could someone tell me how to know if I publish a message to a queue and the message really arrives to the rabbitmq server?. Thanks in advance !
Kinh
Publisher acknowledgments are on the amqp level, handled by RMQ itself. In the "API" level you may get a exception or a return value or some indication depends on the library.
Quote from the aforementioned link:
For unroutable messages, the broker will issue a confirm once the
exchange verifies a message won't route to any queue (returns an empty
list of queues). If the message is also published as mandatory, the
basic.return is sent to the client before basic.ack. The same is true
for negative acknowledgements (basic.nack).
For routable messages, the basic.ack is sent when a message has been
accepted by all the queues. For persistent messages routed to durable
queues, this means persisting to disk. For mirrored queues, this means
that all mirrors have accepted the message.
How can manual retry work in RabbitMQ after a message has been put onto dead letter queue?
Does RabbitMQ provide an user interface through which you can do this? I assume here that RabbitMQ console does not provide you this capability.
The Rabbit MQ management interface would let you do this crudely, you can go into the deadletter queue, 'get' the message then copy the content. Go to the queue you want to retry the message on and 'publish' it directly to that queue.
Alternatively, you can enable the shovel plugin which allows you to move messages from one queue to another. The RabbitMQ Management plugin directly contains instructions on how to do this.
You can write a consumer / producer using a number of various client libraries. For python a popular library is pika (https://pypi.python.org/pypi/pika).
The script can consume all the messages in a queue, then publish them to another queue.