Resolves https://github.com/spring-projects/spring-amqp/issues/1422
Broker-named queues did not work with `@RabbitListener` because the BPP
only passed the name of the queue bean, not the bean itself, into the
endpoint.
Support bean injection; fall back to the previous behavior if a mixture
of beans and names are encountered (the containers don't support both
types of configuration).
Add a note to the javadoc to indicate that broker-named queues are not
supported via `queuesToDeclare` and `bindings` properties; such queues
must be declared as discrete beans.
* Docs.
**cherry-pick to `2.4.x` & `2.3.x`**
# Conflicts:
# spring-rabbit/src/test/java/org/springframework/amqp/rabbit/annotation/EnableRabbitIntegrationTests.java
Resolves https://github.com/spring-projects/spring-amqp/issues/1409
Normally, when message has a fatal exception (such as message conversion)
`basicNack` with `multiple` true is used, to nack any previously unacked
messages (e.g. when using batch size to limit the ack traffic).
Even when using manual acks, fatal exceptions are nacked by the container
because the user does not have access to the message.
However, when using async replies, this has the side effect of nacking
unprocessed messages.
Detect whether async replies are being used and only nack individual
records that cause fatal exceptions.
Also, coerce the `AcknowledgeMode` to `MANUAL` for such listners.
Add a test for both containers; send a good message followed by a
bad one without actually completing the reply future.
After the exception occurs and the container is stopped, there should
be one messag in the queue.
* Remove warning, deprecation; add docs.
* Docs.
**Cherry-pick to `2.3.x` & `2.2.x`**
# Conflicts:
# spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/adapter/MessagingMessageListenerAdapter.java
This commit b945d1cc02
incorrectly added text about reducing the prefetch to 1 when using manual acks.
While changing it to 1 fixed a test case (`testListenerRecoversFromBogusDoubleAck`) it should
not have been a general recommendation since acking the same message twice is not a valid
situation.
**cherry-pick to all supported branches**
* Add links to alternate documentation formats
Link the HTML to the PDF and vice-versa.
* Update src/reference/asciidoc/index.adoc
Co-authored-by: Gary Russell <grussell@vmware.com>
Co-authored-by: Gary Russell <grussell@vmware.com>
Resolves https://github.com/spring-projects/spring-amqp/issues/1339
Error handler was not called for conversion exceptions, preventing
the application from returning some error to the caller for request/reply processing.
**cherry-pick to 2.2.x**
Resolves https://github.com/spring-projects/spring-amqp/issues/1295
GH-1295: add custom HandlerMethodArgumentResolver
Signed-off-by: Dmitrii Bocharov <bdshadow@gmail.com>
GH-1295: simplify configuration of argument Validator. Add argument validation support for @RabbitHandler methods
Signed-off-by: Dmitrii Bocharov <bdshadow@gmail.com>
Avoid double payload validation in the listener that has no default handler, when a validator is provided
Signed-off-by: Dmitrii Bocharov <bdshadow@gmail.com>
Resolves https://github.com/spring-projects/spring-amqp/issues/1331
Provide a mechanism so that a thread can hand off its channel(s) to another thread.
Add protection to close a channel that would be orphaned if a second channel is transferred
to the thread and the thread failed to close its channel beforehand.
Other improvements:
- only call the channel listener when a channel is actually created
- physically close a transactional channel that is no longer in the thread local because
`closeThreadChannel` was called
- move reset of physical close flag to the actual close
* Suggestions from PR review + other improvements:
- protect against calling 'prepare' when no channels bound
- log warning for unclaimed context switches
- add more tests
Resolves https://github.com/spring-projects/spring-amqp/issues/1296
- Add `MissingQueueEvent`
- Fix detection of a deleted queue in recovery - previously incorrectly used the
absense of the queue in `consumersByQueue`, which can be empty if missing during
start
- Add an index to `SimpleConsumer`
- When adjusting consumer counts, look for gaps in the index sequence because reducing
the consumer count can remove any idle consumer.
- Change consumers to restart to a `Set` to avoid OOM when no broker
(see https://github.com/spring-projects/spring-amqp/pull/642)
- Unconditionally add consumers to `consumersToRestart`
**cherry-pick to 2.2.x, 2.1.x**
Resolves https://github.com/spring-projects/spring-amqp/issues/1289
`RoutingConnectionFactory` did not support correlated confirms or returns.
Target factories (and default) must have the same settings.
**cherry-pick to 2.2.x, 2.1.x**
- Allow the publishing connection factory to be explicitly set and be
any type
- Do not propagate properties when the factory is explicitly configured
* Reset flag when this is a publisher CF.
Resolves https://github.com/spring-projects/spring-amqp/issues/1251
Delimiter should be a comma and whitespace trimmeed.
Handle both delimiters in decompressors and add property for backwards compatibility.
**I will backport to 2.2.x with default `:`**
* Do not add a delimiter if the original encoding is an empty String.
Previously, only random address shuffling was supported; it is useful,
for scenarios such as using the RabbitMQ Sharding Plugin, to be able
to connect to multiple nodes in a deterministic manner.
Resolves https://github.com/spring-projects/spring-amqp/issues/1226https://github.com/spring-projects/spring-amqp/issues/1157 changed the way we spy
listeners - to support CGLIB proxies (e.g. `@Transactional`).
Instead of spying the listener, it mocks the listener and sets a default answer
to call the real method on the delegate.
This broke when users used other answers, such as those provided by the framework.
Change the provided answers to subclass `ForwardsInvocation`.
Also fix `ConcurrentModificationException` in `getExceptions()`.
**cherry-pick to 2.2.x, 2.1.x**
Resolves https://github.com/spring-projects/spring-amqp/issues/1219
The headers were mapped after message conversion.
This prevented using a `ContentTypeDelegatingMessageConverter` because
the content type was not set.
Add a header to control whether the user or converter gets to set the
content type property in the final message.
**cherry-pick to 2.2.x, 2.1.x, 1.7.x**
Resolves https://github.com/spring-projects/spring-amqp/issues/1215
Previously, the message converter would fall back to header type info
if the inferred type was abstract.
Furthermore, we did not examine container type content being abstract.
With a custom deserializer, abstract classes can be deserialized.
Resolves https://github.com/spring-projects/spring-amqp/issues/1201
Support de-batching producer batches to a `List<Meessage>` with native
`BatchMessageListener`s; previously this was only possible with
`@RabbitListener` which does the debatching itself.
* Fix race in test.
https://github.com/spring-projects/spring-amqp/pull/1202#issuecomment-629436933
The test has a very short timeout; there is a race such that the channel won't be
physically closed if we don't get the `ConsumeOK` in time.
This won't really cause a problem in a real application, but this change will
prevent the test from sporadically failing.
It turns out that relative path in the property
`<property name="file" value="src/checkstyle/checkstyle-suppressions.xml"/>`
in some cases is resolved against a Gradle deamon dir as a root for configs
* Fix Checkstyle plugin config to use an absolute path in the project for
the `configDirectory`.
* Since `configDirectory` is exposed as a Checkstyle config variable,
we can use its `${config_loc}` placeholder to rely on the absolute path
in the project