Commit Graph

223 Commits

Author SHA1 Message Date
Michael Klishin c8cb9dda6e
Introduce rabbit_shovel_parameters:{src,dest}_protocol/1
which can be used to implement an existing function,
`protocols/1`.
2025-11-10 12:45:34 -08:00
Michael Klishin 4ce144542d
Shovels: cover local shovels in unit_parsing_and_validation_SUITE 2025-11-10 12:08:46 -08:00
Diana Parra Corbacho 797f645a18 Shovel tests: run unit_runtime_parameter_SUITE inside a broker
It needs the rabbit registry to select the protocols
2025-11-10 17:12:41 +01:00
Michael Klishin 7aa7433d91
Shovel: use lqueue over queue
the `queue' module is not aware of the queue
length, which means its `len/1` function is
O(n) while with `lqueue' it is O(1).

We rely on `queue:len/1' for a shovel metric,
so why not use a more efficient drop-in replacement
our team has developed in 2011.
2025-11-03 15:37:21 -08:00
Michael Klishin b905370bf0
Shovel: whitelist one more exception in amqp091_local_dynamic_SUITE 2025-11-03 15:34:05 -08:00
Diana Parra Corbacho f0381159e7 Shovel local bugfix: handle cluster alarms
Local shovels must stop publishing when alarms are set in the destination
cluster. Messages are stored in memory and sent when the alarm clears,
the same way it is done for AMQP091
2025-11-02 21:05:15 +01:00
Diana Parra Corbacho c0b118ac28 Shovel tests: test disk alarm 2025-10-31 19:15:37 +01:00
Diana Parra Corbacho 4ec2f21dbe Shovel: more common testcases 2025-10-29 20:53:13 +01:00
Michael Klishin 5518a92e42
Comment formatting #14757
Trigger a 4.3.x alpha release build / trigger_alpha_build (push) Waiting to run Details
Test (make) / Build and Xref (1.18, 26) (push) Waiting to run Details
Test (make) / Build and Xref (1.18, 27) (push) Waiting to run Details
Test (make) / Build and Xref (1.18, 28) (push) Waiting to run Details
Test (make) / Test (1.18, 28, khepri) (push) Waiting to run Details
Test (make) / Test (1.18, 28, mnesia) (push) Waiting to run Details
Test (make) / Test mixed clusters (1.18, 28, khepri) (push) Waiting to run Details
Test (make) / Test mixed clusters (1.18, 28, mnesia) (push) Waiting to run Details
Test (make) / Type check (1.18, 28) (push) Waiting to run Details
2025-10-20 08:29:26 -07:00
Diana Parra Corbacho f1a7020ad1 Shovels: skip tests cases until rejection behaviour is unified 2025-10-20 09:14:17 +02:00
Diana Parra Corbacho 059813a831 Shovel: more common testcases 2025-10-16 12:07:05 +02:00
Diana Parra Corbacho 629cf77743 Shovel: delete duplicated tests
Test cases covered by shovel_dynamic_SUITE
2025-10-16 12:07:05 +02:00
Diana Parra Corbacho d5f9ff27bd Shovel tests: tests for autodelete common to all protocols 2025-10-16 12:07:04 +02:00
David Ansari 02807a2beb Require feature flag `rabbitmq_4.0.0`
Require feature flag `rabbitmq_4.0.0` for RabbitMQ 4.3 and delete the
compatibility code.
2025-10-15 16:55:45 +02:00
Diana Parra Corbacho c4138d5194 Shovel tests: refactor and new tests for all protocols 2025-10-08 17:43:53 +02:00
Diana Parra Corbacho 7f25c52eaf Shovel: tests delete after with queue rejections
Peer Discovery AWS Integration Test / Integration Test (push) Has been cancelled Details
2025-10-08 13:07:55 +02:00
Michael Klishin 3c4707d9df
Merge pull request #14614 from cloudamqp/shovel-pending-count
Peer Discovery AWS Integration Test / Integration Test (push) Waiting to run Details
Trigger a 4.3.x alpha release build / trigger_alpha_build (push) Has been cancelled Details
Test (make) / Build and Xref (1.18, 26) (push) Has been cancelled Details
Test (make) / Build and Xref (1.18, 27) (push) Has been cancelled Details
Test (make) / Build and Xref (1.18, 28) (push) Has been cancelled Details
Test (make) / Test (1.18, 28, khepri) (push) Has been cancelled Details
Test (make) / Test (1.18, 28, mnesia) (push) Has been cancelled Details
Test (make) / Test mixed clusters (1.18, 28, khepri) (push) Has been cancelled Details
Test (make) / Test mixed clusters (1.18, 28, mnesia) (push) Has been cancelled Details
Test (make) / Type check (1.18, 28) (push) Has been cancelled Details
Ensures pending counter in rabbit_shovel_status is always an integer
2025-10-08 01:15:49 -04:00
Michael Klishin 3a43a95a1a
Merge pull request #14704 from rabbitmq/shovel-tests-refactor
Shovels: increase forwarded counter for AMQP1.0
2025-10-07 23:15:06 -04:00
Diana Parra Corbacho 28f9720a12 Shovel tests: extract common test cases to all protocols into a generic test suite 2025-10-07 16:30:20 +02:00
Diana Parra Corbacho bc9b2f5a71 Shovel tests: code refactor 2025-10-07 12:28:44 +02:00
Michael Davis 9393ec9db5
amqp_client: Emit 'connection.blocked' in direct connections
Previously direct 0-9-1 connections did not notice when memory or disk
alarms were set. This could allow an 0-9-1 shovel where the destination
is a direct connection to completely overload a broker which is already
in alarm. With this change, direct connections register the connection
process with `rabbit_alarm` and emit `connection.blocked` and
`connection.unblocked` to the blocked handler if one is registered.
`rabbit_amqp091_shovel` already respects the `connection.blocked`, so
the destination will not receive any messages.
2025-10-02 13:26:29 -04:00
Michael Davis 24e2575bee
rabbitmq_shovel: Split 0-9-1 alarms tests into a new suite
This change also refactors them to use two unclustered nodes. This is
a prerequisite for the child change which will remove the workaround of
using a direct connection to be able to publish while a node is in
alarm.
2025-10-02 13:26:17 -04:00
Diana Parra Corbacho c9697a6b7a Shovels: make changes to shovel status backward compatible 2025-09-30 17:53:51 +02:00
Diana Parra Corbacho 33a6a20017 Shovels: tests for deletion of failed shovels 2025-09-30 10:10:35 +02:00
markus812498 878d53e1f4 fixup: addressing feedback and cleaning up tests 2025-09-30 08:45:21 +13:00
markus812498 fe6fb4cbb3 ensures the pending returns an integer and not a list for shovels 2025-09-26 13:14:21 +12:00
Michael Klishin 351ec1b4c7
Merge pull request #14593 from rabbitmq/shovel-raw
Shovels: Optimise amqp10 client messages for shovel usage
2025-09-24 14:04:00 -04:00
Diana Parra Corbacho 897260ce3d Shovels: Optimise amqp10 client messages for shovel usage
AMQP10 shovels don't need the amqp10 message format, the binary
can be translated directly into a message container and also
the other way around. The new amqp10_raw_msg just stores the payload
and information required to create the transfer frame, skipping
a few unnecessary encoding/decoding operations of the AMQP10 sections.
2025-09-23 23:11:49 +02:00
Diana Parra Corbacho a4b37d7886 Local shovels: Test global counters 2025-09-18 13:18:16 +02:00
David Ansari 72cd7a35c2 Support Direct Reply-To for AMQP 1.0
# What?
* Support Direct Reply-To for AMQP 1.0
* Compared to AMQP 0.9.1, this PR allows for multiple volatile queues on a single
  AMQP 1.0 session. Use case: JMS clients can create multiple temporary queues on
  the same JMS/AMQP session:
  * https://jakarta.ee/specifications/messaging/3.1/apidocs/jakarta.messaging/jakarta/jms/session#createTemporaryQueue()
  * https://jakarta.ee/specifications/messaging/3.1/apidocs/jakarta.messaging/jakarta/jms/jmscontext#createTemporaryQueue()
* Fix missing metrics in for Direct Reply-To in AMQP 0.9.1, e.g.
  `messages_delivered_total`
* Fix missing metrics (even without using Direct Reply-To ) in AMQP 0.9.1:
  If stats level is not `fine`, global metrics `rabbitmq_global_messages_delivered_*` should still be incremented.

 # Why?
* Allow for scalable at-most-once RPC reply delivery
  Example use case: thousands of requesters connect, send a single
  request, wait for a single reply, and disconnect.
  This PR won't create any queue and won't write to the metadata store.
  Therefore, there's less pressure on the metadata store, less pressure
  on the Management API when listing all queues, less pressure on the
  metrics subsystem, etc.
* Feature parity with AMQP 0.9.1

 # How?
This PR extracts the previously channel specific Direct Reply-To code
into a new queue type: `rabbit_volatile_queue`.
"Volatile" describes the semantics, not a use-case. It signals non-durable,
zero-buffer, at-most-once, may-drop, and "not stored in Khepri."

This new queue type is then used for AMQP 1.0 and AMQP 0.9.1.

Sending to the volatile queue is stateless like previously with Direct Reply-To in AMQP 0.9.1 and like done
for the MQTT QoS 0 queue.
This allows for use cases where a single responder replies to e.g. 100k different requesters.

RabbitMQ will automatically auto grant new link-credit to the responder because the new queue type confirms immediately.

The key gets implicitly checked by the channel/session:
If the queue name (including the key) doesn’t exist, the `handle_event` callback for this queue isn’t invoked and therefore
no delivery will be sent to the responder.

This commit supports Direct Reply-To across AMQP 1.0 and 0.9.1. In other
words, the requester can be an AMQP 1.0 client while the responder is an
AMQP 0.9.1 client or vice versa.
RabbitMQ will internally convert between AMQP 0.9.1 `reply_to` and AMQP
1.0 `/queues/<queue>` address. The AMQP 0.9.1 `reply_to` property is
expected to contain a queue name. That's in line with the AMQP 0.9.1
spec:
> One of the standard message properties is Reply-To, which is designed
specifically for carrying the name of reply queues.

Compared to AMQP 0.9.1 where the requester sets the `reply_to` property
to `amq.rabbitmq.reply-to` and RabbitMQ modifies this field when
forwarding the message to the request queue, in AMQP 1.0 the requester
learns about the queue name from the broker at link attachment time.
The requester has to set the reply-to property to the server generated
queue name. That's because the server isn't allowed to modify the bare
message.

During link attachment time, the client has to set certain fields.
These fields are expected to be set by the RabbitMQ client libraries.
Here is an Erlang example:
```erl
Source = #{address => undefined,
           durable => none,
           expiry_policy => <<"link-detach">>,
           dynamic => true,
           capabilities => [<<"rabbitmq:volatile-queue">>]},
AttachArgs = #{name => <<"receiver">>,
               role => {receiver, Source, self()},
               snd_settle_mode => settled,
               rcv_settle_mode => first},
{ok, Receiver} = amqp10_client:attach_link(Session, AttachArgs),
AddressReplyQ = receive {amqp10_event, {link, Receiver, {attached, Attach}}} ->
                  #'v1_0.attach'{source = #'v1_0.source'{address = {utf8, Addr}}} = Attach,
                  Addr
end,
```

The client then sends the message by setting the reply-to address as
follows:
```erl
amqp10_client:send_msg(
  SenderRequester,
  amqp10_msg:set_properties(
    #{message_id => <<"my ID">>,
      reply_to => AddressReplyQ},
    amqp10_msg:new(<<"tag">>, <<"request">>))),
```

If the responder attaches to the queue target in the reply-to field,
RabbitMQ will check if the requester link is still attached. If the
requester detached, the link will be refused.

The responder can also attach to the anonymous null target and set the
`to` field to the `reply-to` address.

If RabbitMQ cannot deliver a reply, instead of buffering the reply,
RabbitMQ will be drop the reply and increment the following Prometheus metric:
```
rabbitmq_global_messages_dead_lettered_maxlen_total{queue_type="rabbit_volatile_queue",dead_letter_strategy="disabled"} 0.0
```
That's in line with the MQTT QoS 0 queue type.

A reply message could be dropped for a variety of reasons:
1. The requester ran out of link-credit. It's therefore the requester's
   responsibility to grant sufficient link-credit on its receiving link.
2. RabbitMQ isn't allowed to deliver any message to due session flow
   control. It's the requster's responsibility to keep the session window
   large enough.
3. The requester doesn't consume messages fast enough causing TCP
   backpressure being applied or the RabbitMQ AMQP writer proc isn't
   scheduled quickly enough. The latter can happen for example if
   RabbitMQ runs with a single scheduler (is assigned a single CPU
   core). In either case, RabbitMQ internal flow control causes the
   volatile queue to drop messages.

Therefore, if high throughput is required while message loss is undesirable, a classic queue should be used
instead of a volatile queue since the former buffers messages while the
latter doesn't.

The main difference between the volatile queue and the MQTT QoS 0 queue
is that the former isn't written to the metadata store.

 # Breaking Change
Prior to this PR the following [documented caveat](https://www.rabbitmq.com/docs/4.0/direct-reply-to#limitations) applied:
> If the RPC server publishes with the mandatory flag set then `amq.rabbitmq.reply-to.*`
is treated as **not** a queue; i.e. if the server only publishes to this name then the message
will be considered "not routed"; a `basic.return` will be sent if the mandatory flag was set.

This PR removes this caveat.
This PR introduces the following new behaviour:
> If the RPC server publishes with the mandatory flag set, then `amq.rabbitmq.reply-to.*`
is treated as a queue (assuming this queue name is encoded correctly). However,
whether the requester is still there to consume the reply is not checked at routing time.
In other words, if the RPC server only publishes to this name, then the message will be
considered "routed" and RabbitMQ will therefore not send a `basic.return`.
2025-09-09 14:52:22 +02:00
Diana Parra Corbacho 41d52835bf Local shovels: fix handling of acks/nacks from multiple queues 2025-09-02 12:09:58 +02:00
D Corbacho 7f1febe70b
Local shovels: exclude tests in mixed-versions with 3.13.x (#14482)
The test suites need to be excluded at group level, so the end_per_suite
is always executed and the cluster stopped. Otherwise, clusters
remain running in CI and the following suites find the TCP ports busy.
2025-09-02 10:56:56 +02:00
Michal Kuratczyk 1b4cff21b3
Skip local shovel tests when mixed with 3.13 (#14475) 2025-09-01 15:50:44 +02:00
D Corbacho 0977ad2dde
Local shovels: skip tests in mixed-version (#14473)
Local shovels require rabbitmq_4_0_0 feature flag, so it can't run
in mixed-version clusters with 3.13.x
2025-09-01 13:25:51 +02:00
Michael Klishin 30fb9c1128
Re-arrange shovel test suites
* Use more descriptive names
 * Prefix unit test suites accordingly
 * Reuse await_credit/1
 * await_credit/1 in a flakey test
2025-08-29 18:34:51 -04:00
Diana Parra Corbacho 68b98bfd3b Local shovels: ack messages not routed to any queue using exchanges 2025-08-26 20:24:30 +02:00
Diana Parra Corbacho 1c72316d2e Local shovels: Handle multiple rejects on node down 2025-08-26 12:22:59 +02:00
Diana Parra Corbacho 0174f59c4e Local shovel: handle unacked messages in queue down
It affects messages routed through exchanges, when there is no target
queue configured in the shovel (it could be many queues as destination or none).
2025-08-26 11:27:14 +02:00
D Corbacho e4bc525b5e
Merge pull request #14421 from rabbitmq/local-shovel-default-user-pass
Local shovels: Set default user/pass for uris like "amqp://"
2025-08-25 12:36:47 +02:00
Diana Parra Corbacho f990f7e271 Local shovels: Set default user/pass for uris like "amqp://" 2025-08-25 11:34:57 +02:00
Diana Parra Corbacho b6d831b115 Shovel amqp1.0: fix delete after validation
Queue-length is not supported, so it should fail already during validation and
not shovel startup
2025-08-23 13:26:46 +02:00
Michael Klishin c7f6cad331
Shovel: ignore expected log exceptions in local_SUITE 2025-08-20 19:23:33 -04:00
Diana Parra Corbacho bb5e1d95d9 Local shovels: handle credit on sender side 2025-08-11 21:37:05 +02:00
Diana Parra Corbacho 78167f0fb7 Local shovel: more tests 2025-08-11 21:37:05 +02:00
Michael Klishin 414da5d146 local_dynamic_SUITE: ignore two expected crash reports in the logs 2025-08-11 21:37:05 +02:00
Diana Parra Corbacho be061cd54b Local shovel: fix credit handling order 2025-08-11 21:37:05 +02:00
Diana Parra Corbacho a855146b99 Local shovel: handle destination queue events 2025-08-11 21:37:05 +02:00
Michael Klishin 30f67e0f7a local_dynamic_SUITE: await credit for publishing links
This elimiantes a race condition between the destination
granting the sender link credit and the rest of what
the test does.

Note: the amqp_utils module in server core cannot be easily
moved to, say, rabbit_ct_helpers because it combines
two kinds of helpers that belong to two of our
CT helper subprojects.

So we've copied two small functions from it for
the needs of this suite.
2025-08-11 21:37:05 +02:00
Diana Parra Corbacho 2e2dc4b2dd Shovel tests: ignore nodename
CI uses a different hostname
2025-08-11 21:37:04 +02:00
Diana Parra Corbacho f381993db0 Local shovels: renew credit 2025-08-11 21:37:04 +02:00