494 Commits

Author SHA1 Message Date
Gary Russell
051c304425 GH-1422: @RabbitListener: Fix Broker-Named Queues
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
2022-02-14 12:16:36 -05:00
Gary Russell
4acabdf25f Remove declareCollections from Doc
Incorrectly left over after the property was removed in 2.2.
2022-02-01 11:36:19 -05:00
Gary Russell
94fff33adf GH-1409: Fix Nacks for Async Replies
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
2021-12-20 11:45:57 -05:00
Gary Russell
a597b9dbb1 Remove Incorrect Doc Re Prefetch with MANUAL Acks
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**
2021-10-12 10:59:50 -04:00
Gary Russell
032f8ecee7 GH-1362: Enable Capture of Tx Synchronization Fail
Resolves https://github.com/spring-projects/spring-amqp/issues/1362

**cherry-pick to 2.3.x**

* Add missing doc changes.

* Fix test to reset flag.
2021-07-16 18:53:40 -04:00
Gary Russell
ea97b1179c GH-1347: DMLC Ignored Authentication Failures
Resolves https://github.com/spring-projects/spring-amqp/issues/1347

Container starts and keeps trying to connect instead of honoring
the property.

**cherry-pick to 2.2.x**
2021-06-09 12:07:44 -04:00
Jay Bryant
8e8dda721f Add links to alternate documentation formats (#1348)
* 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>
2021-06-08 17:08:57 -04:00
Gary Russell
96070f6720 GH-1339: Fix RLErrorHandler with Conversion Ex. (#1346)
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**
2021-06-07 16:05:14 -04:00
Łukasz Tworek
c5ee02d851 Fix a small typo in the documentation (DeclarationCustomizer -> DeclarableCustomizer) (#1342) 2021-06-02 12:52:33 -04:00
Gary Russell
9137a366c5 CachingCF Threading Doc Polishing 2021-05-27 15:41:44 -04:00
Dmitrii Bocharov
c577fbbf31 GH-1295: Validation for @RabbitHandler
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>
2021-05-06 13:12:09 -04:00
Gary Russell
e787950364 GH-1312: Correlation on Channel with Direct Reply
Resolves https://github.com/spring-projects/spring-amqp/issues/1312

With Direct Reply-To we can correlate the reply using the channel
instead of requiring the server to echo back the correlation id.

* Fix link in what's new.
2021-05-05 14:20:14 -04:00
Gary Russell
d269a3244e GH-1331: ThreadChannelConnFactory Improvements
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
2021-04-30 13:20:33 -04:00
Gary Russell
52cb8987cf GH-1329: Document Multi-Threaded Strict Ordering
Resolves https://github.com/spring-projects/spring-amqp/issues/1329
2021-04-28 10:32:57 -04:00
Gary Russell
2cded99e33 GH-1325: Queue API Deprecations and Improvements
Resolves https://github.com/spring-projects/spring-amqp/issues/1325
2021-04-22 15:07:34 -04:00
Artem Bilan
0757aac4f1 Use current main branch in docs instead of master (#1322) 2021-04-15 11:38:07 -04:00
Gary Russell
e190e53dfd GH-1318: Support the Global Flag in basicQos
Resolves https://github.com/spring-projects/spring-amqp/issues/1318

**cherry-pick to 2.2.x**
2021-04-07 17:45:11 -04:00
Gary Russell
866868cd5d Fix link in doc 2021-04-02 14:09:30 -04:00
Gary Russell
b95de43151 Update Doc Copyright 2021-02-17 16:40:59 -05:00
Gary Russell
2c9119622f GH-1307: Doc Polishing
Resolves https://github.com/spring-projects/spring-amqp/issues/1307

Define beans with narrower types.
2021-02-11 12:48:17 -05:00
Gary Russell
2c929ff8d9 GH-1296: Fix DMLC Recovery: Missing Queue at Start
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**
2021-01-12 14:14:16 -05:00
Gary Russell
d5f81a62c3 GH-1293: Confirms/Returns with Republish Recoverer
Resolves https://github.com/spring-projects/spring-amqp/issues/1293

Add a subclass that waits for confirms and checks for returns.

* Fix import.

* Fix javadocs.

* Fix copyright year.

* Fix Sonar issues.
2021-01-08 15:39:49 -05:00
Gary Russell
e382f67325 GH-1289: Confirms and Returns with Routing CF
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**
2020-12-23 14:28:42 -05:00
Artem Bilan
ab5df7d4a7 Some build and docs fixes
* Fix author list for VMware emails
* Fix link for the project page
* Fix Copyright in the `index.adoc`
* Check GH Actions in action
2020-12-07 16:07:51 -05:00
choubani amir
18bd707519 Fix Spelling errors in the amqp.adoc 2020-12-03 10:25:16 -05:00
Dmitry Baev
189847d5aa fix asyncrabbittemplate section 2020-12-02 10:54:35 -05:00
Gary Russell
99ccb1bfb5 Fix Sonar issues and other refactoring
- 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.
2020-11-30 13:41:12 -05:00
Gary Russell
ef03b70e49 GH-891: Docs for Multi RabbitMQ Support
Supplement to https://github.com/spring-projects/spring-amqp/pull/1111
2020-10-28 10:23:41 -04:00
Gary Russell
310f95098e GH-1258: Change OOMHandler to JavaLangErrorHandler
Resolves https://github.com/spring-projects/spring-amqp/issues/1258

Call the handler for all `Error`s on container threads.

**I will do the cherry-pick; there will be conflicts**
2020-10-22 14:08:34 -04:00
Gary Russell
2c3f26e905 GH-1258: Add OOMHandler to the listener containers
Resolves https://github.com/spring-projects/spring-amqp/issues/1258#issuecomment-711670729

**I will backport to 2.2.x with a no-op default**
2020-10-20 13:46:35 -04:00
Gary Russell
4f76b2bc8d Fix Compressed contentEncoding Delimiter
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.
2020-09-25 13:51:38 -04:00
Gary Russell
9868649e8c Require an ID in CorrelationData
Required for proper coordination of returns and confirms.
It is mentioned in the javadocs, but easy to miss.
2020-08-31 10:10:56 -04:00
Gary Russell
01cb986fd1 Add Deterministic Address Shuffling
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.
2020-08-19 15:35:03 -04:00
Gary Russell
90e3232045 Add consumeDelay for RabbitMQ Sharding Plugin 2020-08-19 13:52:27 -04:00
Gary Russell
36e31beb1f ReturnsListener whats-new.adoc 2020-07-30 12:08:18 -04:00
Gary Russell
985cf3c487 Simplify ReturnCallback for Lambdas
- a single parameter instead of 5
2020-07-29 14:05:03 -04:00
Gary Russell
73fdff5a3f Consistent Use of BDDMockito
Mixture of plain and BDD Mockito, sometimes in the same class.

Enforce with checkstyle.
2020-07-21 17:57:31 -04:00
Gary Russell
c40b2b53bc GH-1226: Fix Test Harness
Resolves https://github.com/spring-projects/spring-amqp/issues/1226

https://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**
2020-07-21 13:49:17 -04:00
Gary Russell
e0ca772304 GH-1220: Add replyContentType to @RabbitListener
Resolves https://github.com/spring-projects/spring-amqp/issues/1220

Fix Typo
2020-07-14 12:29:27 -04:00
Gary Russell
cf221da0da GH-1219: Fix header mapping for replies (@SendTo)
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**
2020-07-07 12:18:21 -04:00
Gary Russell
06af4033c8 GH-1215: Allow Abstract Class Deserialization
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.
2020-06-23 15:10:35 -04:00
Gary Russell
ee52539c13 Use allowed list for trusted deserialization 2020-06-18 16:03:25 -04:00
Gary Russell
6c134537af Doc: Fix link in appendix 2020-05-27 10:01:19 -04:00
Gary Russell
7cc3f0a5ee Use Awaitility in tests 2020-05-20 14:14:00 -04:00
Gary Russell
751326ee63 GH-1201: Native BatchMessageListener Support
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.
2020-05-18 14:20:18 -04:00
Gary Russell
e1580d24b0 GH-1198: Support AddressResolver
Resolves https://github.com/spring-projects/spring-amqp/issues/1198

**cherry-pick to 2.2.x, 2.1.x**
2020-05-16 14:03:21 -04:00
Gary Russell
29f3d0d213 Doc Polishing
- remove discussion about `@RabbitListeners`; pre java-8 is no longer supported.
2020-05-14 17:04:15 -04:00
Artem Bilan
97ba480e71 Fix Checkstyle to rely on the absolute path
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
2020-05-06 16:23:03 -04:00
Gary Russell
1572ea8d75 Fix docsZip gradle task and doc links 2020-04-30 17:31:19 -04:00
Gary Russell
07414b0567 AMQP-608: Add new connection factories
JIRA https://jira.spring.io/browse/AMQP-608

Initial Commit

* Doc and Javadoc polishing.
2020-04-30 16:47:02 -04:00