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:44 UTC
[camel] 02/09: CAMEL-14868 - Camel-AWS2-*: Where possible,
give the possiblity to the end user to pass an AWS Request pojo as
body, aws2-msk create 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 f52bcf1e328fbbd3372c97ef5047f5a45e599c2f
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Apr 16 09:28:09 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 create 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 e6fc60e..1090dca 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
@@ -128,7 +128,21 @@ public class MSK2Producer extends DefaultProducer {
}
}
- private void createCluster(KafkaClient mskClient, Exchange exchange) {
+ private void createCluster(KafkaClient mskClient, Exchange exchange) throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof CreateClusterRequest) {
+ CreateClusterResponse response;
+ try {
+ response = mskClient.createCluster((CreateClusterRequest) payload);
+ } catch (AwsServiceException ase) {
+ LOG.trace("Create Cluster command returned the error code {}", ase.awsErrorDetails().errorCode());
+ throw ase;
+ }
+ Message message = getMessageForResponse(exchange);
+ message.setBody(response);
+ }
+ } else {
CreateClusterRequest.Builder builder = CreateClusterRequest.builder();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MSK2Constants.CLUSTER_NAME))) {
String name = exchange.getIn().getHeader(MSK2Constants.CLUSTER_NAME, String.class);
@@ -163,6 +177,7 @@ public class MSK2Producer extends DefaultProducer {
}
Message message = getMessageForResponse(exchange);
message.setBody(response);
+ }
}
private void deleteCluster(KafkaClient mskClient, Exchange exchange) {