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 2018/07/19 08:40:34 UTC

[camel] branch master updated (75862f3 -> 31ae174)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 75862f3  CAMEL-12664 - Fixed CS
     new 2c451b5  CAMEL-12664 - Camel-Nats Refactoring consumer a bit
     new 31ae174  CAMEL-12664 - Removed NatsPropertiesConstants class as it is not used anymore

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/camel/component/nats/NatsConsumer.java  | 46 +++++++++-------------
 .../apache/camel/component/nats/NatsProducer.java  |  3 --
 .../component/nats/NatsPropertiesConstants.java    | 31 ---------------
 3 files changed, 18 insertions(+), 62 deletions(-)
 delete mode 100644 components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsPropertiesConstants.java


[camel] 01/02: CAMEL-12664 - Camel-Nats Refactoring consumer a bit

Posted by ac...@apache.org.
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 2c451b563628bd3469b9f15f64f046cb6788ba25
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jul 19 10:33:21 2018 +0200

    CAMEL-12664 - Camel-Nats Refactoring consumer a bit
---
 .../apache/camel/component/nats/NatsConsumer.java  | 46 +++++++++-------------
 1 file changed, 18 insertions(+), 28 deletions(-)

diff --git a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConsumer.java b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConsumer.java
index 9bcc8c4..51d9593 100644
--- a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConsumer.java
+++ b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsConsumer.java
@@ -134,21 +134,8 @@ public class NatsConsumer extends DefaultConsumer {
         @Override
         public void run() {
             try {
+                dispatcher = connection.createDispatcher(new CamelNatsMessageHandler());
                 if (ObjectHelper.isNotEmpty(configuration.getQueueName())) {
-                    dispatcher = connection.createDispatcher(new MessageHandler() {
-                        @Override
-                        public void onMessage(Message msg) {
-                            LOG.debug("Received Message: {}", msg);
-                            Exchange exchange = getEndpoint().createExchange();
-                            exchange.getIn().setBody(msg);
-                            exchange.getIn().setHeader(NatsConstants.NATS_MESSAGE_TIMESTAMP, System.currentTimeMillis());
-                            try {
-                                processor.process(exchange);
-                            } catch (Exception e) {
-                                getExceptionHandler().handleException("Error during processing", exchange, e);
-                            }
-                        }
-                    });
                     dispatcher = dispatcher.subscribe(getEndpoint().getNatsConfiguration().getTopic(), getEndpoint().getNatsConfiguration().getQueueName());
                     if (ObjectHelper.isNotEmpty(getEndpoint().getNatsConfiguration().getMaxMessages())) {
                         dispatcher.unsubscribe(getEndpoint().getNatsConfiguration().getTopic(), Integer.parseInt(getEndpoint().getNatsConfiguration().getMaxMessages()));
@@ -157,20 +144,6 @@ public class NatsConsumer extends DefaultConsumer {
                         setActive(true);
                     }
                 } else {
-                    dispatcher = connection.createDispatcher(new MessageHandler() {
-                        @Override
-                        public void onMessage(Message msg) {
-                            LOG.debug("Received Message: {}", msg);
-                            Exchange exchange = getEndpoint().createExchange();
-                            exchange.getIn().setBody(msg);
-                            exchange.getIn().setHeader(NatsConstants.NATS_MESSAGE_TIMESTAMP, System.currentTimeMillis());
-                            try {
-                                processor.process(exchange);
-                            } catch (Exception e) {
-                                getExceptionHandler().handleException("Error during processing", exchange, e);
-                            }
-                        }
-                    });
                     dispatcher = dispatcher.subscribe(getEndpoint().getNatsConfiguration().getTopic());
                     if (ObjectHelper.isNotEmpty(getEndpoint().getNatsConfiguration().getMaxMessages())) {
                         dispatcher.unsubscribe(getEndpoint().getNatsConfiguration().getTopic(), Integer.parseInt(getEndpoint().getNatsConfiguration().getMaxMessages()));
@@ -182,6 +155,23 @@ public class NatsConsumer extends DefaultConsumer {
             } catch (Throwable e) {
                 getExceptionHandler().handleException("Error during processing", e);
             }
+            
+        }
+        
+        class CamelNatsMessageHandler implements MessageHandler {
+
+            @Override
+            public void onMessage(Message msg) throws InterruptedException {
+                LOG.debug("Received Message: {}", msg);
+                Exchange exchange = getEndpoint().createExchange();
+                exchange.getIn().setBody(msg);
+                exchange.getIn().setHeader(NatsConstants.NATS_MESSAGE_TIMESTAMP, System.currentTimeMillis());
+                try {
+                    processor.process(exchange);
+                } catch (Exception e) {
+                    getExceptionHandler().handleException("Error during processing", exchange, e);
+                }
+            }
         }
     }
 


[camel] 02/02: CAMEL-12664 - Removed NatsPropertiesConstants class as it is not used anymore

Posted by ac...@apache.org.
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 31ae174cf8251f8847d2700ca14fce50e8b91258
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jul 19 10:37:35 2018 +0200

    CAMEL-12664 - Removed NatsPropertiesConstants class as it is not used anymore
---
 .../apache/camel/component/nats/NatsProducer.java  |  3 ---
 .../component/nats/NatsPropertiesConstants.java    | 31 ----------------------
 2 files changed, 34 deletions(-)

diff --git a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsProducer.java b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsProducer.java
index c8ac879..085b8ab 100644
--- a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsProducer.java
+++ b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsProducer.java
@@ -18,10 +18,7 @@ package org.apache.camel.component.nats;
 
 import java.io.IOException;
 import java.security.GeneralSecurityException;
-import java.security.NoSuchAlgorithmException;
 import java.time.Duration;
-import java.util.Properties;
-import java.util.concurrent.TimeoutException;
 
 import javax.net.ssl.SSLContext;
 
diff --git a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsPropertiesConstants.java b/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsPropertiesConstants.java
deleted file mode 100644
index 61e5431..0000000
--- a/components/camel-nats/src/main/java/org/apache/camel/component/nats/NatsPropertiesConstants.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.nats;
-
-public interface NatsPropertiesConstants {
-    String NATS_PROPERTY_URL = "io.nats.client.url";
-    String NATS_PROPERTY_VERBOSE = "io.nats.client.verbose";
-    String NATS_PROPERTY_PEDANTIC = "io.nats.client.pedantic";
-    String NATS_PROPERTY_RECONNECT = "io.nats.client.reconnect.allowed";
-    String NATS_PROPERTY_SSL = "io.nats.client.secure";
-    String NATS_PROPERTY_MAX_RECONNECT_ATTEMPTS = "io.nats.client.reconnect.max";
-    String NATS_PROPERTY_RECONNECT_TIME_WAIT = "io.nats.client.reconnect.wait";
-    String NATS_PROPERTY_PING_INTERVAL = "io.nats.client.pinginterval";
-    String NATS_PROPERTY_DONT_RANDOMIZE_SERVERS = "io.nats.client.norandomize";
-    String NATS_PROPERTY_QUEUE = "queue";
-    String NATS_PROPERTY_MAX_MESSAGES = "max";
-}