Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate afterReceivePostProcessors execution with rabbitTemplate.convertSendAndReceiveAsType #1359

Closed
bastiat opened this issue Jun 24, 2021 · 0 comments · Fixed by #1360
Closed

Comments

@bastiat
Copy link

bastiat commented Jun 24, 2021

Bug report

Version:
[INFO] | - org.springframework.amqp:spring-rabbit:jar:2.2.15.RELEASE:compile
[INFO] | +- com.rabbitmq:amqp-client:jar:5.9.0:compile
[INFO] | +- org.springframework.amqp:spring-amqp:jar:2.2.15.RELEASE:compile

Problem:

// given
rabbitTemplate.addAfterReceivePostProcessors(someLoggingPostProcessor)

// when
rabbitTemplate.convertSendAndReceiveAsType(final String exchange, final String routingKey, final Object message,
@nullable final MessagePostProcessor messagePostProcessor, @nullable final CorrelationData correlationData,
ParameterizedTypeReference responseType)

// then
someLoggingPostProcessor is executed twice.

Possible source of problem:

afterReceivePostProcessors from rabbitTemplate are set to DirectReplyToMessageListenerContainer
https://github.com/spring-projects/spring-amqp/blame/main/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java#L1984

and now afterReceivePostProcessors are executed twice:

first in
https://github.com/spring-projects/spring-amqp/blob/main/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/AbstractMessageListenerContainer.java#L1543

and next in
https://github.com/spring-projects/spring-amqp/blame/main/spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java#L2031

@garyrussell garyrussell self-assigned this Jun 25, 2021
@garyrussell garyrussell added this to the 2.4 M1 milestone Jun 25, 2021
garyrussell added a commit to garyrussell/spring-amqp that referenced this issue Jun 25, 2021
Resolves spring-projects#1359

When the `RabbitTemplate` is configured with `afterReceivePostProcessors`
and uses the default internal `DirectReplyToMessageListenerContainer`, the
postprocessors are applied twice, once by the container and once by the
template.

The template should not propagate the post processors into the container.

**cherry-pick to 2.3.x, 2.2.x**
artembilan pushed a commit that referenced this issue Jun 25, 2021
Resolves #1359

When the `RabbitTemplate` is configured with `afterReceivePostProcessors`
and uses the default internal `DirectReplyToMessageListenerContainer`, the
postprocessors are applied twice, once by the container and once by the
template.

The template should not propagate the post processors into the container.

**cherry-pick to 2.3.x, 2.2.x**
artembilan pushed a commit that referenced this issue Jun 25, 2021
Resolves #1359

When the `RabbitTemplate` is configured with `afterReceivePostProcessors`
and uses the default internal `DirectReplyToMessageListenerContainer`, the
postprocessors are applied twice, once by the container and once by the
template.

The template should not propagate the post processors into the container.

**cherry-pick to 2.3.x, 2.2.x**
artembilan pushed a commit that referenced this issue Jun 25, 2021
Resolves #1359

When the `RabbitTemplate` is configured with `afterReceivePostProcessors`
and uses the default internal `DirectReplyToMessageListenerContainer`, the
postprocessors are applied twice, once by the container and once by the
template.

The template should not propagate the post processors into the container.

**cherry-pick to 2.3.x, 2.2.x**

# Conflicts:
#	spring-rabbit/src/main/java/org/springframework/amqp/rabbit/core/RabbitTemplate.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants