Add Apache Camel support (#3887)

* Add Apache Camel support

* Implement `CamelMessageHandler` to perform send and send-n-reply
operations to the Apache Camel routes
* Fix `AbstractMessageProducingHandler` to handle async errors even if reply is
not expected

* * Narrow Camel dependency to `api`
This commit is contained in:
Artem Bilan
2022-09-15 16:41:25 -04:00
committed by GitHub
parent f39ad6f558
commit 5ece0e0dfd
8 changed files with 554 additions and 4 deletions

View File

@@ -24,6 +24,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiConsumer;
@@ -535,7 +536,7 @@ public abstract class AbstractMessageProducingHandler extends AbstractMessageHan
@Override
public void accept(Object result, Throwable exception) {
if (exception == null) {
if (result != null) {
Message<?> replyMessage = null;
try {
replyMessage = createOutputMessage(result, this.requestMessage.getHeaders());
@@ -549,12 +550,12 @@ public abstract class AbstractMessageProducingHandler extends AbstractMessageHan
exceptionToLogAndSend = new MessagingException(replyMessage, exceptionToLogAndSend);
}
}
logger.error(exceptionToLogAndSend, () -> "Failed to send async reply: " + result.toString());
logger.error(exceptionToLogAndSend, () -> "Failed to send async reply: " + result);
onFailure(exceptionToLogAndSend);
}
}
else {
onFailure(exception);
else if (exception != null) {
onFailure(exception instanceof CompletionException ? exception.getCause() : exception);
}
}