You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/04/16 07:42:46 UTC
[camel] 04/09: CAMEL-14868 - Camel-AWS2-*: Where possible,
give the possiblity to the end user to pass an AWS Request pojo as
body, aws2-msk describe broker
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit d52ee04b986fdb42d336bda72c002d817ed91731
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Apr 16 09:32:51 2020 +0200
CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-msk describe broker
---
.../apache/camel/component/aws2/msk/MSK2Producer.java | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/components/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2Producer.java b/components/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2Producer.java
index 6edb05d..92253dd 100644
--- a/components/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2Producer.java
+++ b/components/camel-aws2-msk/src/main/java/org/apache/camel/component/aws2/msk/MSK2Producer.java
@@ -214,7 +214,21 @@ public class MSK2Producer extends DefaultProducer {
}
}
- private void describeCluster(KafkaClient mskClient, Exchange exchange) {
+ private void describeCluster(KafkaClient mskClient, Exchange exchange) throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof DescribeClusterRequest) {
+ DescribeClusterResponse result;
+ try {
+ result = mskClient.describeCluster((DescribeClusterRequest) payload);
+ } catch (AwsServiceException ase) {
+ LOG.trace("Delete Cluster command returned the error code {}", ase.awsErrorDetails().errorCode());
+ throw ase;
+ }
+ Message message = getMessageForResponse(exchange);
+ message.setBody(result);
+ }
+ } else {
DescribeClusterRequest.Builder builder = DescribeClusterRequest.builder();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MSK2Constants.CLUSTER_ARN))) {
String arn = exchange.getIn().getHeader(MSK2Constants.CLUSTER_ARN, String.class);
@@ -231,6 +245,7 @@ public class MSK2Producer extends DefaultProducer {
}
Message message = getMessageForResponse(exchange);
message.setBody(result);
+ }
}
public static Message getMessageForResponse(final Exchange exchange) {