This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new 45cf4ee CAMEL-12665: Polished 45cf4ee is described below commit 45cf4ee6903aa325b65745ebd65b0c867d3cec36 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Thu Apr 11 11:39:31 2019 +0200 CAMEL-12665: Polished --- components/camel-pulsar/pom.xml | 112 +++++++++++---------- .../camel/component/pulsar/PulsarProducer.java | 14 +-- .../pulsar/configuration/PulsarConfiguration.java | 7 -- 3 files changed, 61 insertions(+), 72 deletions(-) diff --git a/components/camel-pulsar/pom.xml b/components/camel-pulsar/pom.xml index 744d3af..3594462 100644 --- a/components/camel-pulsar/pom.xml +++ b/components/camel-pulsar/pom.xml @@ -18,53 +18,67 @@ --> <project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <artifactId>components</artifactId> - <groupId>org.apache.camel</groupId> - <version>3.0.0-SNAPSHOT</version> - </parent> - <modelVersion>4.0.0</modelVersion> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>components</artifactId> + <groupId>org.apache.camel</groupId> + <version>3.0.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> - <artifactId>camel-pulsar</artifactId> - <packaging>jar</packaging> - <name>Camel :: Pulsar</name> - <description>Camel Apache Pulsar Component</description> + <artifactId>camel-pulsar</artifactId> + <packaging>jar</packaging> + <name>Camel :: Pulsar</name> + <description>Camel Apache Pulsar Component</description> - <properties> - </properties> + <properties> + </properties> - <dependencies> + <dependencies> - <dependency> - <groupId>org.apache.pulsar</groupId> - <artifactId>pulsar-client</artifactId> - </dependency> - <dependency> - <groupId>org.apache.pulsar</groupId> - <artifactId>pulsar-client-admin</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-support</artifactId> - </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-support</artifactId> + </dependency> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-test</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> + <dependency> + <groupId>org.apache.pulsar</groupId> + <artifactId>pulsar-client</artifactId> + </dependency> + <dependency> + <groupId>org.apache.pulsar</groupId> + <artifactId>pulsar-client-admin</artifactId> + </dependency> + + <!-- testing --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.testcontainers</groupId> + <artifactId>testcontainers</artifactId> + <version>${testcontainers-version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.testcontainers</groupId> + <artifactId>pulsar</artifactId> + <version>${testcontainers-version}</version> + <scope>test</scope> + </dependency> <!-- logging --> <dependency> <groupId>org.apache.logging.log4j</groupId> @@ -81,17 +95,5 @@ <artifactId>log4j-slf4j-impl</artifactId> <scope>test</scope> </dependency> - <dependency> - <groupId>org.testcontainers</groupId> - <artifactId>testcontainers</artifactId> - <version>1.11.1</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.testcontainers</groupId> - <artifactId>pulsar</artifactId> - <version>1.11.1</version> - <scope>test</scope> - </dependency> - </dependencies> + </dependencies> </project> diff --git a/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/PulsarProducer.java b/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/PulsarProducer.java index 3466d1c..445fe40 100644 --- a/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/PulsarProducer.java +++ b/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/PulsarProducer.java @@ -17,6 +17,7 @@ package org.apache.camel.component.pulsar; import java.util.Map; + import org.apache.camel.Exchange; import org.apache.camel.Message; import org.apache.camel.NoTypeConversionAvailableException; @@ -26,13 +27,9 @@ import org.apache.camel.component.pulsar.utils.message.PulsarMessageUtils; import org.apache.camel.support.DefaultProducer; import org.apache.pulsar.client.api.Producer; import org.apache.pulsar.client.api.ProducerBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class PulsarProducer extends DefaultProducer { - private static final Logger LOGGER = LoggerFactory.getLogger(PulsarProducer.class); - private final PulsarEndpoint pulsarEndpoint; public PulsarProducer(PulsarEndpoint pulsarEndpoint) { @@ -65,15 +62,12 @@ public class PulsarProducer extends DefaultProducer { byte[] body = exchange.getContext().getTypeConverter() .mandatoryConvertTo(byte[].class, exchange, message.getBody()); producer.send(body); - } catch (NoTypeConversionAvailableException | TypeConversionException exception) { - LOGGER.warn("An error occurred while serializing to byte array, fall using fall back strategy :: {}", exception); - + // fallback to try serialize the data byte[] body = PulsarMessageUtils.serialize(message.getBody()); - producer.send(body); + } finally { + producer.close(); } - - producer.close(); } } diff --git a/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/configuration/PulsarConfiguration.java b/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/configuration/PulsarConfiguration.java index 011ee77..5e76604 100644 --- a/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/configuration/PulsarConfiguration.java +++ b/components/camel-pulsar/src/main/java/org/apache/camel/component/pulsar/configuration/PulsarConfiguration.java @@ -46,7 +46,6 @@ public class PulsarConfiguration { /** * Name of the subscription to use - * @param subscriptionName */ public void setSubscriptionName(String subscriptionName) { this.subscriptionName = subscriptionName; @@ -58,7 +57,6 @@ public class PulsarConfiguration { /** * Type of the subscription [EXCLUSIVE|SHARED|FAILOVER], defaults to EXCLUSIVE - * @param subscriptionType */ public void setSubscriptionType(SubscriptionType subscriptionType) { this.subscriptionType = subscriptionType; @@ -70,7 +68,6 @@ public class PulsarConfiguration { /** * Number of consumers - defaults to 1 - * @param numberOfConsumers */ public void setNumberOfConsumers(int numberOfConsumers) { this.numberOfConsumers = numberOfConsumers; @@ -82,7 +79,6 @@ public class PulsarConfiguration { /** * Size of the consumer queue - defaults to 10 - * @param consumerQueueSize */ public void setConsumerQueueSize(int consumerQueueSize) { this.consumerQueueSize = consumerQueueSize; @@ -94,7 +90,6 @@ public class PulsarConfiguration { /** * Name of the consumer when subscription is EXCLUSIVE - * @param consumerName */ public void setConsumerName(String consumerName) { this.consumerName = consumerName; @@ -106,7 +101,6 @@ public class PulsarConfiguration { /** * Name of the producer - * @param producerName */ public void setProducerName(String producerName) { this.producerName = producerName; @@ -118,7 +112,6 @@ public class PulsarConfiguration { /** * Prefix to add to consumer names when a SHARED or FAILOVER subscription is used - * @param consumerNamePrefix */ public void setConsumerNamePrefix(String consumerNamePrefix) { this.consumerNamePrefix = consumerNamePrefix;