706 Commits

Author SHA1 Message Date
Gary Russell
d4b7578627 GH-1236: Handle non-String contentType
Resolves https://github.com/spring-projects/spring-amqp/issues/1236

The user may set the contentType to a `MimeType`.

Always use `toString()` when replacing the `contentType`.

**cherry-pick to 2.2.x, 2.1.x, 1.7.x**

(cherry picked from commit 8c7e4f95ee)

# Conflicts:
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/annotation/ContentTypeDelegatingMessageConverterIntegrationTests.java
2020-08-05 14:47:24 -04:00
Gary Russell
efcba3a83a GH-1237: RCFB Close key/trust store input streams
Resolves https://github.com/spring-projects/spring-amqp/issues/1237

**cherry-pick to 2.2.x, 2.1.x, 1.7.x**

(cherry picked from commit 165b838c3a)

# Conflicts:
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/RabbitConnectionFactoryBean.java
2020-08-05 14:30:41 -04:00
Gary Russell
028b28ae17 GH-1225: Fix Log4j2 Appender Termination
Replaces https://github.com/spring-projects/spring-amqp/pull/1225

`manager.stop()` was never called to destroy the connection factory, preventing
JVM exit.

Also protect for re-connecting after stop (both appenders).

Tested with a Spring Boot application.

**cherry-pick to 2.2.x, 2.1.x, 1.7.x**
2020-07-22 17:32:21 -04:00
Gary Russell
11c4367c84 Fix another exchange declaration 2020-07-07 17:44:50 -04:00
Gary Russell
1eb4b359f7 Fix test exchange declaration
- exchanges are now durable by default and tests fail if the exchange
  already exists on the CI broker (declared by a newer release).
2020-07-07 17:06:55 -04:00
Gary Russell
eeaeb68e9a Fix Appender Test
- changed property value without changing the test
2020-07-07 15:56:08 -04:00
Gary Russell
304832d407 Remove unnecessary slf4j dependency
- causes problems for the logback appender tests
- also make the `logs` exchange consistent across all 3 appenders
2020-07-07 15:10:45 -04:00
Gary Russell
16a87df36b 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**

# Conflicts:
#	spring-amqp/src/main/java/org/springframework/amqp/support/AmqpHeaders.java
#	spring-amqp/src/main/java/org/springframework/amqp/support/converter/MessagingMessageConverter.java
#	src/reference/asciidoc/amqp.adoc

# Conflicts:
#	src/reference/asciidoc/amqp.adoc
2020-07-07 12:30:28 -04:00
Gary Russell
c1566ffb6c Make sendTo.replies test queue args consistent
- changed to non-autoDelete in 2.1.x
2019-08-23 16:11:52 -04:00
Artem Bilan
080aeabcf7 Add HTTPS entries for XSD into spring.schemas
Related to https://github.com/spring-projects/spring-integration/issues/2987

**Cherry-pick to 2.1.x, 2.0.x & 1.7.x**
2019-07-18 14:14:54 -04:00
Ian Roberts
d9686822dc Sleep for failed declaration out of warn block
* Respect `failedDeclarationRetryInterval` even when logging is not enabled.

**Cherry-pick to 2.1.x, 2.0.x & 1.7.x**

# Conflicts:
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/BlockingQueueConsumer.java
2019-07-17 15:51:45 -04:00
Gary Russell
beb208c50d GH-1038: RT: Fix evaluatedFastReplyTo
Fixes https://github.com/spring-projects/spring-amqp/issues/1038

Don't set `evaluatedFastReplyTo` if we didn't actually evaluate it because
the broker is down on the first request.

**cherry-pick to all 2.x; backport to 1.7.x**

# Conflicts:
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/core/RabbitTemplateTests.java

# Conflicts:
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/core/RabbitTemplateTests.java

# Conflicts:
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/core/RabbitTemplateTests.java
2019-06-28 11:50:51 -04:00
Gary Russell
fee8a97532 GH-1026: Fix Delay with CacheMode.CONNECTION
Fixes https://github.com/spring-projects/spring-amqp/issues/1026

When using a `channelCheckoutTimeout` with `CacheModeConnection`,
we incorrectly spin waiting for a connection until the timeout
expires.

We should only wait for a connection if the limit is exceeded.

**cherry-pick to all supported**

(cherry picked from commit dde7a37350)

# Conflicts:
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/connection/CachingConnectionFactory.java
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/connection/CachingConnectionFactoryTests.java

# Conflicts:
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/connection/CachingConnectionFactoryTests.java
2019-06-17 11:58:05 -04:00
Eugene Gusev
34e614a30a GH-1014: Add addMdcAsHeaders into appenders
Fixes https://github.com/spring-projects/spring-amqp/issues/1014

**Cherry-pick to 2.1.x, 2.0.x & 1.7.x**

GH-1014 minor changes

GH-1014 renamed property to addMdcAsHeaders

GH-1014 added addMdcAsHeaders into documentation

GH-1014 added addMdcAsHeaders into logback appender. added integration test

GH-1014 updated documentation

GH-1014 minor fix

GH-1014 updated documentation

GH-1014 minor fix

GH-1014 removed this prefix

* Made addMdcAsHeaders true by default

* Polishing

# Conflicts:
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/log4j2/AmqpAppenderTests.java
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/logback/AmqpAppenderIntegrationTests.java

# Conflicts:
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/log4j2/AmqpAppender.java
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/logback/AmqpAppender.java
#	src/reference/asciidoc/logging.adoc
#	src/reference/asciidoc/whats-new.adoc

# Conflicts:
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/log4j2/AmqpAppender.java
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/logback/AmqpAppender.java
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/log4j2/AmqpAppenderTests.java
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/logback/AmqpAppenderIntegrationTests.java
#	spring-rabbit/src/test/resources/log4j2-amqp-appender.xml
#	spring-rabbit/src/test/resources/logback-test.xml
2019-06-13 12:45:34 -04:00
Spring Operator
b74a6883e6 URL Cleanup
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# Fixed URLs

## Fixed But Review Recommended
These URLs were fixed, but the https status was not OK. However, the https status was the same as the http request or http redirected to an https URL, so they were migrated. Your review is recommended.

* [ ] http://www.puppycrawl.com/dtds/configuration_1_2.dtd (404) with 1 occurrences migrated to:
  https://www.puppycrawl.com/dtds/configuration_1_3.dtd ([https](https://www.puppycrawl.com/dtds/configuration_1_2.dtd) result 404).
* [ ] http://www.puppycrawl.com/dtds/suppressions_1_1.dtd (404) with 1 occurrences migrated to:
  https://www.puppycrawl.com/dtds/suppressions_1_2.dtd ([https](https://www.puppycrawl.com/dtds/suppressions_1_1.dtd) result 404).

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* [ ] http://www.springframework.org/schema/beans/spring-beans.xsd with 34 occurrences migrated to:
  https://www.springframework.org/schema/beans/spring-beans.xsd ([https](https://www.springframework.org/schema/beans/spring-beans.xsd) result 200).
* [ ] http://www.springframework.org/schema/context/spring-context.xsd with 1 occurrences migrated to:
  https://www.springframework.org/schema/context/spring-context.xsd ([https](https://www.springframework.org/schema/context/spring-context.xsd) result 200).
* [ ] http://www.springframework.org/schema/rabbit/spring-rabbit.xsd with 32 occurrences migrated to:
  https://www.springframework.org/schema/rabbit/spring-rabbit.xsd ([https](https://www.springframework.org/schema/rabbit/spring-rabbit.xsd) result 200).
* [ ] http://www.springframework.org/schema/task/spring-task.xsd with 1 occurrences migrated to:
  https://www.springframework.org/schema/task/spring-task.xsd ([https](https://www.springframework.org/schema/task/spring-task.xsd) result 200).
* [ ] http://www.springframework.org/schema/util/spring-util.xsd with 5 occurrences migrated to:
  https://www.springframework.org/schema/util/spring-util.xsd ([https](https://www.springframework.org/schema/util/spring-util.xsd) result 200).

# Ignored
These URLs were intentionally ignored.

* http://www.springframework.org/schema/beans with 77 occurrences
* http://www.springframework.org/schema/context with 2 occurrences
* http://www.springframework.org/schema/rabbit with 71 occurrences
* http://www.springframework.org/schema/task with 2 occurrences
* http://www.springframework.org/schema/util with 10 occurrences
* http://www.w3.org/2001/XMLSchema-instance with 34 occurrences

* Upgrade to SF-4.3.23.BUILD-SNAPSHOT for HTTPS resolution for XSDs
2019-03-26 13:15:23 -04:00
Spring Operator
33797aa426 URL Cleanup
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# Fixed URLs

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* [ ] http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.2.1/css/font-awesome.css with 1 occurrences migrated to:
  https://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.2.1/css/font-awesome.css ([https](https://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.2.1/css/font-awesome.css) result 200).
* [ ] http://docs.spring.io/spring-amqp/docs/latest-ga/api/org/springframework/amqp/core/MessageProperties.html with 1 occurrences migrated to:
  https://docs.spring.io/spring-amqp/docs/latest-ga/api/org/springframework/amqp/core/MessageProperties.html ([https](https://docs.spring.io/spring-amqp/docs/latest-ga/api/org/springframework/amqp/core/MessageProperties.html) result 200).
* [ ] http://static.springsource.org/spring-amqp/docs/latest_ga/api/org/springframework/amqp/rabbit/core/RabbitTemplate.html (301) with 1 occurrences migrated to:
  https://docs.spring.io/spring-amqp/docs/latest_ga/api/org/springframework/amqp/rabbit/core/RabbitTemplate.html ([https](https://static.springsource.org/spring-amqp/docs/latest_ga/api/org/springframework/amqp/rabbit/core/RabbitTemplate.html) result 200).
* [ ] http://static.springsource.org/spring-amqp/docs/latest_ga/api/org/springframework/amqp/rabbit/transaction/RabbitTransactionManager.html (301) with 1 occurrences migrated to:
  https://docs.spring.io/spring-amqp/docs/latest_ga/api/org/springframework/amqp/rabbit/transaction/RabbitTransactionManager.html ([https](https://static.springsource.org/spring-amqp/docs/latest_ga/api/org/springframework/amqp/rabbit/transaction/RabbitTransactionManager.html) result 200).
* [ ] http://docs.spring.io/spring-amqp/reference/ with 1 occurrences migrated to:
  https://docs.spring.io/spring-amqp/reference/ ([https](https://docs.spring.io/spring-amqp/reference/) result 200).
* [ ] http://static.springsource.org/spring-retry/docs/api/current/ (301) with 1 occurrences migrated to:
  https://docs.spring.io/spring-retry/docs/api/current/ ([https](https://static.springsource.org/spring-retry/docs/api/current/) result 200).
* [ ] http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/htmlsingle/spring-framework-reference.html (301) with 2 occurrences migrated to:
  https://docs.spring.io/spring/docs/3.0.x/spring-framework-reference/htmlsingle/spring-framework-reference.html ([https](https://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/htmlsingle/spring-framework-reference.html) result 200).
* [ ] http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/transaction/PlatformTransactionManager.html (301) with 1 occurrences migrated to:
  https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/transaction/PlatformTransactionManager.html ([https](https://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/transaction/PlatformTransactionManager.html) result 200).
* [ ] http://fonts.googleapis.com/css?family=Varela+Round|Open+Sans:400italic,700italic,400,700 with 1 occurrences migrated to:
  https://fonts.googleapis.com/css?family=Varela+Round|Open+Sans:400italic,700italic,400,700 ([https](https://fonts.googleapis.com/css?family=Varela+Round|Open+Sans:400italic,700italic,400,700) result 200).
* [ ] http://github.com/spring-projects/spring-amqp with 1 occurrences migrated to:
  https://github.com/spring-projects/spring-amqp ([https](https://github.com/spring-projects/spring-amqp) result 200).
* [ ] http://github.com/spring-projects/spring-amqp-samples with 1 occurrences migrated to:
  https://github.com/spring-projects/spring-amqp-samples ([https](https://github.com/spring-projects/spring-amqp-samples) result 200).
* [ ] http://gradle.org/ with 2 occurrences migrated to:
  https://gradle.org/ ([https](https://gradle.org/) result 200).
* [ ] http://projects.spring.io/spring-amqp/ with 2 occurrences migrated to:
  https://projects.spring.io/spring-amqp/ ([https](https://projects.spring.io/spring-amqp/) result 200).
* [ ] http://stackoverflow.com/questions/134882/undoing-a-git-rebase with 1 occurrences migrated to:
  https://stackoverflow.com/questions/134882/undoing-a-git-rebase ([https](https://stackoverflow.com/questions/134882/undoing-a-git-rebase) result 200).
* [ ] http://stackoverflow.com/questions/tagged/spring-amqp with 3 occurrences migrated to:
  https://stackoverflow.com/questions/tagged/spring-amqp ([https](https://stackoverflow.com/questions/tagged/spring-amqp) result 200).
* [ ] http://www.amqp.org/ with 2 occurrences migrated to:
  https://www.amqp.org/ ([https](https://www.amqp.org/) result 200).
* [ ] http://www.amqp.org/resources/download with 1 occurrences migrated to:
  https://www.amqp.org/resources/download ([https](https://www.amqp.org/resources/download) result 200).
* [ ] http://www.rabbitmq.com/ with 2 occurrences migrated to:
  https://www.rabbitmq.com/ ([https](https://www.rabbitmq.com/) result 200).
* [ ] http://www.rabbitmq.com/blog/2011/02/10/introducing-publisher-confirms/ with 1 occurrences migrated to:
  https://www.rabbitmq.com/blog/2011/02/10/introducing-publisher-confirms/ ([https](https://www.rabbitmq.com/blog/2011/02/10/introducing-publisher-confirms/) result 200).
* [ ] http://www.rabbitmq.com/blog/2013/12/16/using-consumer-priorities-with-rabbitmq/ with 1 occurrences migrated to:
  https://www.rabbitmq.com/blog/2013/12/16/using-consumer-priorities-with-rabbitmq/ ([https](https://www.rabbitmq.com/blog/2013/12/16/using-consumer-priorities-with-rabbitmq/) result 200).
* [ ] http://www.rabbitmq.com/direct-reply-to.html with 5 occurrences migrated to:
  https://www.rabbitmq.com/direct-reply-to.html ([https](https://www.rabbitmq.com/direct-reply-to.html) result 200).
* [ ] http://www.rabbitmq.com/download.html with 2 occurrences migrated to:
  https://www.rabbitmq.com/download.html ([https](https://www.rabbitmq.com/download.html) result 200).
* [ ] http://www.rabbitmq.com/how.html with 1 occurrences migrated to:
  https://www.rabbitmq.com/how.html ([https](https://www.rabbitmq.com/how.html) result 200).
* [ ] http://www.rabbitmq.com/semantics.html with 1 occurrences migrated to:
  https://www.rabbitmq.com/semantics.html ([https](https://www.rabbitmq.com/semantics.html) result 200).
* [ ] http://www.rabbitmq.com/ttl.html with 1 occurrences migrated to:
  https://www.rabbitmq.com/ttl.html ([https](https://www.rabbitmq.com/ttl.html) result 200).
* [ ] http://www.rabbitmq.com/tutorials/tutorial-six-java.html with 1 occurrences migrated to:
  https://www.rabbitmq.com/tutorials/tutorial-six-java.html ([https](https://www.rabbitmq.com/tutorials/tutorial-six-java.html) result 200).
* [ ] http://www.sonarsource.org/ (301) with 2 occurrences migrated to:
  https://www.sonarqube.org/ ([https](https://www.sonarsource.org/) result 200).
* [ ] http://www.springframework.org/schema/beans/spring-beans.xsd with 1 occurrences migrated to:
  https://www.springframework.org/schema/beans/spring-beans.xsd ([https](https://www.springframework.org/schema/beans/spring-beans.xsd) result 200).
* [ ] http://www.springframework.org/schema/rabbit/spring-rabbit.xsd with 1 occurrences migrated to:
  https://www.springframework.org/schema/rabbit/spring-rabbit.xsd ([https](https://www.springframework.org/schema/rabbit/spring-rabbit.xsd) result 200).
* [ ] http://contributor-covenant.org with 1 occurrences migrated to:
  https://contributor-covenant.org ([https](https://contributor-covenant.org) result 301).
* [ ] http://contributor-covenant.org/version/1/3/0/ with 1 occurrences migrated to:
  https://contributor-covenant.org/version/1/3/0/ ([https](https://contributor-covenant.org/version/1/3/0/) result 301).
* [ ] http://docs.spring.io/spring/docs/current/spring-framework-reference/html/oxm.html with 1 occurrences migrated to:
  https://docs.spring.io/spring/docs/current/spring-framework-reference/html/oxm.html ([https](https://docs.spring.io/spring/docs/current/spring-framework-reference/html/oxm.html) result 301).
* [ ] http://static.springsource.org/spring/docs/current/spring-framework-reference/html/remoting.html (301) with 1 occurrences migrated to:
  https://docs.spring.io/spring/docs/current/spring-framework-reference/html/remoting.html ([https](https://static.springsource.org/spring/docs/current/spring-framework-reference/html/remoting.html) result 301).
* [ ] http://forum.springsource.org/forumdisplay.php?f=74 (301) with 2 occurrences migrated to:
  https://forum.spring.io/forumdisplay.php?f=74 ([https](https://forum.springsource.org/forumdisplay.php?f=74) result 301).
* [ ] http://github.com/SpringSource/spring-amqp with 1 occurrences migrated to:
  https://github.com/SpringSource/spring-amqp ([https](https://github.com/SpringSource/spring-amqp) result 301).
* [ ] http://github.com/SpringSource/spring-amqp-samples with 1 occurrences migrated to:
  https://github.com/SpringSource/spring-amqp-samples ([https](https://github.com/SpringSource/spring-amqp-samples) result 301).
* [ ] http://help.github.com/fork-a-repo/ with 1 occurrences migrated to:
  https://help.github.com/fork-a-repo/ ([https](https://help.github.com/fork-a-repo/) result 301).
* [ ] http://help.github.com/forking/ with 2 occurrences migrated to:
  https://help.github.com/forking/ ([https](https://help.github.com/forking/) result 301).
* [ ] http://www.rabbitmq.com/install.html with 1 occurrences migrated to:
  https://www.rabbitmq.com/install.html ([https](https://www.rabbitmq.com/install.html) result 301).
* [ ] http://www.spring.io with 2 occurrences migrated to:
  https://www.spring.io ([https](https://www.spring.io) result 301).
* [ ] http://www.spring.io/spring-amqp with 1 occurrences migrated to:
  https://www.spring.io/spring-amqp ([https](https://www.spring.io/spring-amqp) result 301).
* [ ] http://www.springsource.org/spring-amqp with 1 occurrences migrated to:
  https://www.springsource.org/spring-amqp ([https](https://www.springsource.org/spring-amqp) result 301).
* [ ] http://www.springsource.org/spring-integration with 1 occurrences migrated to:
  https://www.springsource.org/spring-integration ([https](https://www.springsource.org/spring-integration) result 301).
* [ ] http://www.springsource.org/sts with 1 occurrences migrated to:
  https://www.springsource.org/sts ([https](https://www.springsource.org/sts) result 301).
* [ ] http://git-scm.com/book/en/Distributed-Git-Contributing-to-a-Project with 1 occurrences migrated to:
  https://git-scm.com/book/en/Distributed-Git-Contributing-to-a-Project ([https](https://git-scm.com/book/en/Distributed-Git-Contributing-to-a-Project) result 302).
* [ ] http://git-scm.com/book/en/Git-Branching-Rebasing with 2 occurrences migrated to:
  https://git-scm.com/book/en/Git-Branching-Rebasing ([https](https://git-scm.com/book/en/Git-Branching-Rebasing) result 302).
* [ ] http://www.springsource.org/node/feed with 2 occurrences migrated to:
  https://www.springsource.org/node/feed ([https](https://www.springsource.org/node/feed) result 302).

# Ignored
These URLs were intentionally ignored.

* http://baz:15672/api/ with 1 occurrences
* http://foo/bar with 2 occurrences
* http://guest:guest@localhost:15672/api/ with 2 occurrences
* http://host1:15672 with 1 occurrences
* http://host2:15672 with 1 occurrences
* http://host:port with 4 occurrences
* http://localhost:11235 with 2 occurrences
* http://localhost:11236 with 2 occurrences
* http://localhost:15672 with 2 occurrences
* http://localhost:15672/api/ with 2 occurrences
* http://www.springframework.org/schema/beans with 18 occurrences
* http://www.springframework.org/schema/rabbit with 20 occurrences
* http://www.springframework.org/schema/tool with 16 occurrences
* http://www.w3.org/2001/XMLSchema with 8 occurrences
* http://www.w3.org/2001/XMLSchema-instance with 9 occurrences
2019-03-26 12:48:11 -04:00
Spring Operator
f08b536b12 URL Cleanup
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# Fixed URLs

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* [ ] http://www.apache.org/licenses/ with 1 occurrences migrated to:
  https://www.apache.org/licenses/ ([https](https://www.apache.org/licenses/) result 200).
* [ ] http://www.apache.org/licenses/LICENSE-2.0 with 381 occurrences migrated to:
  https://www.apache.org/licenses/LICENSE-2.0 ([https](https://www.apache.org/licenses/LICENSE-2.0) result 200).
2019-03-22 17:22:39 -04:00
Gary Russell
e535c33cf2 GH-935: Handle all exceptions in handleDelivery
Fixes https://github.com/spring-projects/spring-amqp/issues/935

- Don't call basicCancel if already canceled
- Catch all `Exception`s

# Conflicts:
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/BlockingQueueConsumer.java
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/listener/BlockingQueueConsumerTests.java
2019-03-19 15:21:28 -04:00
Artem Bilan
723499fff0 GH-905: Fix @RabbitListener Thread Names
Fixes https://github.com/spring-projects/spring-amqp/issues/905

Default container thread names are based on the bean name. `@RabbitListener`
containers are not beans; use `getListenerId()` instead (which falls back
to bean name for other containers).

**cherry-pick to all supported branches**

(cherry picked from commit 5f4c60a969)
2019-02-18 12:03:19 -05:00
Gary Russell
9f7b65ba27 GH-905: Fix @RabbitListener Thread Names
Fixes https://github.com/spring-projects/spring-amqp/issues/905

Default container thread names are based on the bean name. `@RabbitListener`
containers are not beans; use `getListenerId()` instead (which falls back
to bean name for other containers).

**cherry-pick to all supported branches**

(cherry picked from commit 5f4c60a969)

# Conflicts:
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/annotation/EnableRabbitIntegrationTests.java

# Conflicts:
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/AbstractMessageListenerContainer.java
2019-02-17 18:33:16 -05:00
Gary Russell
1fc6fc1f0d Fix concurrency in test case 2019-01-25 12:52:23 -05:00
Artem Bilan
41a61eb4de AMQP-847: Close channel in RabbitTemplate.receive
JIRA: https://jira.spring.io/browse/AMQP-847

To avoid unacked messages race condition when client timeouts, but at
this moment the message becomes available in queue, physically close
a receive channel on the `TimeoutException` from the `Future.get()`

**Cherry-pick to 2.0.x & 1.7.x**
2018-12-11 14:40:26 -05:00
Gary Russell
1283edfb35 Close auto-recovering connection
When a connection is auto-recovered, the `RabbitAdmin` is not
invoked to re-declare auto-delete queues because the connection
listeners are not invoked.

Close an auto-recovered connection before it is recovered.

Tested with a stand-alone spring-cloud-bus application.

**Cherry-pick to 2.0.x, 1.7.x**

# Conflicts:
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/connection/CachingConnectionFactoryIntegrationTests.java
2018-09-20 11:14:45 -04:00
Gary Russell
cdd6201c80 Fix assertion typo 2018-09-04 13:32:36 -04:00
Gary Russell
aff4d0aefc AMQP-830 Enable Hostname Verification by default
JIRA: https://jira.spring.io/browse/AMQP-830
2018-08-28 16:02:28 -04:00
Gary Russell
159d2b4315 AMQP-828: AutoRecovery with template.receive()
JIRA: https://jira.spring.io/browse/AMQP-828

Close auto-recoving channels during recovery since the consumer is
no longer there.

This was previously fixed for the `BlockingQueueConsumer`, but not for
`template.receive()` operations.

* Polishing - PR Comments

AMQP-828: Fix race, removing the shutdown listener

The channel might close between the `isOpen()` test and removing the listener.
2018-08-20 20:00:29 -04:00
Gary Russell
0e597c98de AMQP-827: Fix @RL reply Message<?> conversion
JIRA: https://jira.spring.io/browse/AMQP-827

Use the correct `payloadConverter` in the `MessagingMessageConverter`
to support `@RabbitListener` `Message<?>` return types.

**cherry-pick to 2.0.x, 1.7.x**

# Conflicts:
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/annotation/EnableRabbitIntegrationTests.java
2018-08-08 12:03:16 -04:00
Will Droste
7bf27de152 AMQP-824: Name for deferredCloseExec thread pool
JIRA https://jira.spring.io/browse/AMQP-824

Taking the comments into account

Fix build

* Polishing for code style

**Cherry-pick to 2.0.x & 2.1.x**
2018-07-13 08:54:41 -04:00
Gary Russell
922994f5a2 Fix test race condition
https://build.spring.io/browse/AMQP-MEIGHT-1472
2018-06-30 10:24:06 -04:00
Artem Bilan
7b475d5dad Fix SimpleMessageListenerContainerLongTests fails
https://build.spring.io/browse/PLATFORM-COM2-JOB1-605

* A couple tests doesn't send to the proper queue for the
consecutive consumers start logic to be triggered properly
* The `testIncreaseMinAtMax()` used "too long"
`startConsumerMinInterval` therefore existing consumers were able to
consumer all the messages
2018-06-14 10:47:02 -04:00
Gary Russell
8d21242c77 Add more debug/trace logging
- add delivery tag to inbound delivery logs
- add trace logging to channel method calls

**cherry-pick to 2.0.x, 1.7.x**

(cherry picked from commit 4fdb1e4)
2018-06-05 17:45:39 -04:00
Gary Russell
1ced9ab061 AMQP-814: Add retry to RabbitAdmin
JIRA: https://jira.spring.io/browse/AMQP-814

Add retry to avoid race conditions with auto-delete, exclusive queues.

**cherry-pick to 2.0.x**
**back port to 1.7.x, without lambda in RabbitAdmin**

# Conflicts:
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitAdmin.java
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/core/RabbitAdminTests.java
2018-05-22 17:24:05 -04:00
Gary Russell
daa78ff3db Make ConditionalRejectingErrorHandler extendable
Make it easier to customize the logging behavior of the default
error handler.

Add protected `log()` method and make `causeChainContainsARADRE()` protected.

**cherry-pick to 2.0.x, 1.7.x**

https://stackoverflow.com/questions/50350377/hide-runtime-exception-in-rabbitmq-listener/50354643#50354643

(cherry picked from commit 3a6176e)

# Conflicts:
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/ConditionalRejectingErrorHandler.java
2018-05-15 14:57:40 -04:00
Gary Russell
8e0cd408cf AMQP-810: Fix adjust consumers when max present
JIRA: https://jira.spring.io/browse/AMQP-810

SMLC: adjusting the `concurrentConsumers` did not consider `maxConcurrentConsumers`.
- increase added consumers even if at max
- decrease removed consumers when they had increased due to max being set

Further, decreasing the `maxConcurrentConsumers` did not remove consumers if there
were more consumers than the new max.

- don't add consumers beyond the max
- don't remove consumers unless the new max is exceeded

**cherry-pick to 2.0.x, 1.7.x**

There will be some minor conflicts in 1.7.x since the modified test is JUnit5.

(cherry picked from commit daebf40)

# Conflicts:
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/SimpleMessageListenerContainer.java
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/listener/SimpleMessageListenerContainerLongTests.java
2018-04-27 16:23:52 -04:00
Artem Bilan
f69f54e828 GH-723: Add AmqpResourceNotAvailableException (#737)
* GH-723: Add AmqpResourceNotAvailableException

Fixes spring-projects/spring-amqp#723

To avoid an `NPE` when connection returns `null` for the
`createChannel()` in case of `channelMax` is reached, throw newly
introduced `AmqpResourceNotAvailableException`.
This exception can be used in the `RetryPolicy` to retry the original
operation after some back-off - the channel permit may be released in
between

**Cherry-pick to 2.0.x and 1.7.x**

* * Fix `AbstractConnectionFactoryTests` for proper mock
* Fix `amqp.adoc` according PR comments
2018-04-03 17:44:05 -04:00
Artem Bilan
6498219274 Honor Java 7 language level
https://build.spring.io/browse/AMQP-SA17X-129/
2018-03-30 17:10:38 -04:00
Artem Bilan
adcfef4862 Remove @Override from the RabbitAdmin.initialize
https://build.spring.io/browse/AMQP-AMQP20X-3/

The `AmqpAdmin.initialize()` is there since `2.1`

**Cherry-pick to 1.7.x**

(cherry picked from commit 9e3e5b6)
2018-03-30 17:04:20 -04:00
Gary Russell
539af7f1f0 GH-734: Option to suppress declaring Collections
Fixes https://github.com/spring-projects/spring-amqp/issues/734

Add `declareCollections` flag to admin (default false).

(cherry picked from commit 5423233)
2018-03-30 16:57:29 -04:00
Romster
c8d66d24fa AMQP-805: protected postProcessMessageBeforeSend
JIRA: https://jira.spring.io/browse/AMQP-805
Fixes https://github.com/spring-projects/spring-amqp/issues/722

The `AmqpAppender.postProcessMessageBeforeSend()` is `public`
and uses a `protected` `Event` API.
This combination is useless when we use it from outside call and 
also it is clashes with Kotlin

* Make `postProcessMessageBeforeSend()` as `protected` because
it's never been designed for public usage.

**Cherry-pick to 2.0.x, master**
2018-03-22 12:08:05 -04:00
Artem Bilan
e50cb897c7 AMQP-801-2: Introduce ConsumerDecorator
JIRA: https://jira.spring.io/browse/AMQP-801

To properly assign the queue to the `ConsumeOkEvent`, we need perform
such a logic in the `Consumer.handleConsumeOk()`.

* Introduce `BlockingQueueConsumer.ConsumerDecorator` to be created on
each `channel.basicConsume()` for wrapping the target `InternalConsumer`
per queue
* Add getters to the `ConsumeOkEvent` for better interoperability
* Assert assigned queue names for the `ConsumeOkEvent`s in the
`SimpleMessageListenerContainerIntegration2Tests`

**Cherry-pick to 1.7.x**

* Add `ConsumerDecorator.consumerTag` property
* Add `ConsumerDecorator.toString()`
* Add JavaDocs for the `ConsumeOkEvent`
2018-03-08 16:42:09 -05:00
Gary Russell
3dba703a12 @Ignore testDeleteExchange
Currently incompatible with a 3.7.x broker.
2018-03-07 16:05:55 -05:00
Artem Bilan
8fc94ebc27 AMQP-801: Move ConsumeOkEvent to handleConsumeOk
JIRA: https://jira.spring.io/browse/AMQP-801

The proper place to emit the `ConsumeOkEvent` is really a
`handleConsumeOk()` callback when broker answers us that consumer has
been subscribed to the queue

**Cherry-pick to 1.7.x**
2018-03-07 15:22:12 -05:00
Artem Bilan
1e8986eeb9 Decrease logging level to the WARN
https://build.spring.io/browse/AMQP-SA17X-120

There is some race condition in the Log4J that log messages
are processed on a wrong thread.

*  Decrease logging level to the `WARN` for the `spring-rabbit` to
minimize the level of vulnerability for the `AmqpAppenderIntegrationTests`
2018-01-23 17:47:39 -05:00
Gary Russell
f786c5b59d AMQP-796: Fix Admin Transaction
JIRA: https://jira.spring.io/browse/AMQP-796

If an admin uses a transactional `RabbitTemplate` it will start a transaction.
If the connection was opened due to a `RabbitTemplate` operation it should participate
in the same transaction.
Previously, the template used a second channel and treated it as a local transaction.

Also fix the `RabbitAdmin` so it does no work if there is nothing to declare.

# Conflicts:
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitAdmin.java
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/core/RabbitAdminDeclarationTests.java
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/core/RabbitAdminTests.java
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/core/RabbitTemplateTests.java

* Remove `RabbitTemplateTests` changes since they are not related to
the current state of the `RabbitAdmin`: the `RabbitTemplate`-based
constructor has been introduced since version `2.0`
2018-01-23 17:22:09 -05:00
Gary Russell
f78d916719 AMQP-794: CRErrorHandler: Traverse cause tree
JIRA: https://jira.spring.io/browse/AMQP-794

In the `ConditionalRejectingErrorHandleri.DefaultExceptionStrategy`,
if the `cause` of the `ListenerExecutionFailedException` is a `MessagingException`,
traverse the `cause` tree to find the root cause of all such exceptions unless
it's a fatal cause itself (`MethodArgumentResolutionException` or `MessageConversionException`).
The final fatal check is performed on the root cause.
2017-12-18 17:37:39 -05:00
Gary Russell
ca32f3f464 AMQP-790: Fix after receive MPPs with send/receive
JIRA: https://jira.spring.io/browse/AMQP-790

Previously, `afterReceivePostProcessors` were not called on `sendAndReceive()`
operations.

# Conflicts:
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java
2017-12-12 14:54:21 -05:00
Gary Russell
80db8b184e AMQP-785: SMLC Lifecycle fixes
JIRA: https://jira.spring.io/browse/AMQP-785

Fixes: spring-projects/spring-amqp#689

- Only stop the container on one thread
- Ignore concurrent stops
- Interrupt consumer threads that are attempting to declare queues
- In `restart()` don't start a new consumer if the container is stopping
- Defer publishing consumer failure events until container is stopped
- Add a RecoveryListener if needed to ensure channels are never recovered
- Fix event publishing for `Error` - it is fatal

__backport to 1.7.x will require work__

Clear the declaring flag when exiting `start()` with exception.

Release the `activeObjectCounter` when interrupted while declaring.

Polishing stopped container lifecycle

Since restarted consumer is not be aware about stopped container,
it can restart properly when RabbitMQ comes back on-line independently
of the container state

* Add `active` flag to the `ActiveObjectCounter` and `deactivate()`
and `isActive()` hooks
* Use `ActiveObjectCounter.deactivate()` in the container shutdown
* Use `ActiveObjectCounter.isActive()` in the
`BlockingQueueConsumer.cancelled()`
* Use `BlockingQueueConsumer.cancelled()` in its `start()` toi check
container activity before performing network job
* Check `isActive()` state in the `AbstractMessageListenerContainer.shutdown()`
* Remove `SimpleMessageListenerContainer.containerStopping` in favor of
`isActive()` hook

Conflicts:
	build.gradle
	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/AbstractMessageListenerContainer.java
	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/ActiveObjectCounter.java
	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/SimpleMessageListenerContainer.java
Resolved.
2017-11-27 17:57:43 -05:00
Gary Russell
a08c07d137 Fix Event Test
https://build.spring.io/browse/AMQP-MEIGHT-1247/

Previous commit added more events but the test latch wasn't adjusted to suit.
2017-11-22 10:29:11 -05:00
Gary Russell
96a7101ec0 AMQP-776: More Consumer Events
JIRA: https://jira.spring.io/browse/AMQP-776
JIRA: https://jira.spring.io/browse/AMQP-777
JIRA: https://jira.spring.io/browse/AMQP-782

Publish an event when a consumer successfully consumes from a queue.
Publish an event when an SMLC listener throws an `Error`.
Doc polishing.

Update minimum client version in docs; remove reference to broker version
since that's no longer linked to the client.

__cherry-pick to 1.7.x (minus DMLC change)__

# Conflicts:
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/DirectMessageListenerContainer.java
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/SimpleMessageListenerContainer.java
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/listener/DirectMessageListenerContainerIntegrationTests.java
#	spring-rabbit/src/test/java/org/springframework/amqp/rabbit/listener/SimpleMessageListenerContainerIntegration2Tests.java
#	src/reference/asciidoc/quick-tour.adoc

* Rework `SimpleMessageListenerContainerIntegration2Tests` do not use
lambda for the `ApplicationEventPublisher` since it is there since
Spring 5 only
2017-11-17 20:18:52 -05:00
Gary Russell
4f4d0c57de AMQP-784: Fix multi method @RabbitListener
JIRA: https://jira.spring.io/browse/AMQP-784

When looking for matching methods, we matched on no annotation or @Payload.

Match should have been no annotation(s) or not @Header.

__cherry-pick to 1.7.x__

(cherry picked from commit 1ddc74f)

* Replace `@NonNull` with the `@Validated` for Spring `4.3` support
2017-11-17 12:41:41 -05:00