-
Notifications
You must be signed in to change notification settings - Fork 1.1k
AMQP CorrelationDataWrapper Needs to Delegate New Methods #2759
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
Comments
@artembilan Instead of making protected static final class CorrelationDataWrapper extends CorrelationData {
private static final Method setReturnedMessage;
static {
AtomicReference<Method> method = new AtomicReference<>();
ReflectionUtils.doWithMethods(CorrelationData.class, m -> {
m.setAccessible(true);
method.set(m);
}, m -> {
return m.getName().equals("setReturnedMessage");
});
setReturnedMessage = method.get();
}
private final Object userData;
private final Message<?> message;
CorrelationDataWrapper(String id, Object userData, Message<?> message) {
super(id);
this.userData = userData;
this.message = message;
}
public Object getUserData() {
return this.userData;
}
public Message<?> getMessage() {
return this.message;
}
@Override
public SettableListenableFuture<Confirm> getFuture() {
if (userData instanceof CorrelationData) {
return ((CorrelationData) userData).getFuture();
}
else {
return super.getFuture();
}
}
@Override
public org.springframework.amqp.core.Message getReturnedMessage() {
return super.getReturnedMessage();
}
@Override
public void setReturnedMessage(org.springframework.amqp.core.Message returnedMessage) {
if (this.userData instanceof CorrelationData && setReturnedMessage != null) {
try {
setReturnedMessage.invoke(this.userData, returnedMessage);
}
catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
// empty
}
}
super.setReturnedMessage(returnedMessage);
}
} If you agree, I'll push the change to AMQP and issue a PR for this. |
To be honest I don't see any problems to make that I think we have similar discussion in the past about other |
See spring-projects/spring-integration#2759 __cherry-pick to 2.1.x, 2.0.x, 1.7.x__
See spring-projects/spring-integration#2759 __cherry-pick to 2.1.x, 2.0.x, 1.7.x__
Fixes spring-projects#2759 The outbound endpoints wrap user correlation data in a wrapper. If the user data is a `CorrelationData`, we must delegate methods involving the `Future<?>` and `returnedMessage` to the user data.
Fixes spring-projects#2759 The outbound endpoints wrap user correlation data in a wrapper. If the user data is a `CorrelationData`, we must delegate methods involving the `Future<?>` and `returnedMessage` to the user data. **cherry-pick to 2.1 and switch AMQP to snapshots**
* GH-2759: Fix CorrelationData.future Fixes #2759 The outbound endpoints wrap user correlation data in a wrapper. If the user data is a `CorrelationData`, we must delegate methods involving the `Future<?>` and `returnedMessage` to the user data. **cherry-pick to 5.1 and switch AMQP to snapshots** * Polishing - remove redundant override. * Add debug log with null correlation data
* GH-2759: Fix CorrelationData.future Fixes #2759 The outbound endpoints wrap user correlation data in a wrapper. If the user data is a `CorrelationData`, we must delegate methods involving the `Future<?>` and `returnedMessage` to the user data. **cherry-pick to 5.1 and switch AMQP to snapshots** * Polishing - remove redundant override. * Add debug log with null correlation data # Conflicts: # spring-integration-amqp/src/test/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpointTests.java * Updated Spring AMQP dependency to `2.1.5.BUILD-SNAPSHOT` * Moved `AmqpOutboundEndpointTests` assertions to `AssertJ` to avoid conflicts with `master`
Affects Version(s): all
The
AmqpOutboundEndpoint
wraps the userCorrelationData
in aCorrelationDataWrapper
.This wrapper must delegate
getFuture()
andsetReturnedMessage()
methods to the delegate.Needs a change in Spring AMQP to make
setReturnedMessage()
public (or use reflection).See https://stackoverflow.com/questions/54713121/spring-integration-publisher-confirms-with-timeout/54799635#comment96403650_54799635
The text was updated successfully, but these errors were encountered: