jameshilliard commented on a change in pull request #5034:
URL: https://github.com/apache/camel/pull/5034#discussion_r571476889



##########
File path: 
components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsProducer.java
##########
@@ -42,21 +47,42 @@ public NatsEndpoint getEndpoint() {
     }
 
     @Override
-    public void process(Exchange exchange) throws Exception {
+    public void process(Exchange exchange) {
         NatsConfiguration config = getEndpoint().getConfiguration();
         byte[] body = exchange.getIn().getBody(byte[].class);
         if (body == null) {
-            // fallback to use string
-            body = exchange.getIn().getMandatoryBody(String.class).getBytes();
+            try {
+                // fallback to use string
+                body = 
exchange.getIn().getMandatoryBody(String.class).getBytes();
+            } catch (InvalidPayloadException e) {
+                exchange.setException(e);
+            }
         }
 
-        LOG.debug("Publishing to topic: {}", config.getTopic());
+        if (exchange.getPattern().isOutCapable()) {
+            LOG.debug("Requesting to topic: {}", config.getTopic());
 
-        if (ObjectHelper.isNotEmpty(config.getReplySubject())) {
-            String replySubject = config.getReplySubject();
-            connection.publish(config.getTopic(), replySubject, body);
+            CompletableFuture<io.nats.client.Message> future = 
connection.request(config.getTopic(), body);

Review comment:
       I got the implementation switched over to use `process(exchange, 
callback)`, hopefully did it correctly.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to