diff --git a/docker/Dockerfile b/docker/Dockerfile
index 323a35f..8d0dd43 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -2,4 +2,4 @@ FROM apache/nifi:1.14.0
COPY --chown=nifi:nifi lib/*.nar /opt/nifi/nifi-current/lib/
-COPY --chown=nifi:nifi creds/*.json /tmp
\ No newline at end of file
+COPY --chown=nifi:nifi creds/*.json /tmp
diff --git a/nifi-pulsar-client-service-api/pom.xml b/nifi-pulsar-client-service-api/pom.xml
index ce3e8d6..d2f0e00 100644
--- a/nifi-pulsar-client-service-api/pom.xml
+++ b/nifi-pulsar-client-service-api/pom.xml
@@ -35,7 +35,7 @@
org.apache.pulsar
- pulsar-client-original
+ pulsar-client
${pulsar.version}
diff --git a/nifi-pulsar-client-service-api/src/main/java/org/apache/nifi/pulsar/PulsarClientService.java b/nifi-pulsar-client-service-api/src/main/java/org/apache/nifi/pulsar/PulsarClientService.java
index 446364e..9561e21 100644
--- a/nifi-pulsar-client-service-api/src/main/java/org/apache/nifi/pulsar/PulsarClientService.java
+++ b/nifi-pulsar-client-service-api/src/main/java/org/apache/nifi/pulsar/PulsarClientService.java
@@ -29,5 +29,5 @@ public interface PulsarClientService extends ControllerService {
public PulsarClient getPulsarClient();
public String getPulsarBrokerRootURL();
-
+
}
diff --git a/nifi-pulsar-client-service-api/src/main/java/org/apache/nifi/pulsar/cache/PulsarClientLRUCache.java b/nifi-pulsar-client-service-api/src/main/java/org/apache/nifi/pulsar/cache/PulsarConsumerLRUCache.java
similarity index 88%
rename from nifi-pulsar-client-service-api/src/main/java/org/apache/nifi/pulsar/cache/PulsarClientLRUCache.java
rename to nifi-pulsar-client-service-api/src/main/java/org/apache/nifi/pulsar/cache/PulsarConsumerLRUCache.java
index 446cb88..644554f 100644
--- a/nifi-pulsar-client-service-api/src/main/java/org/apache/nifi/pulsar/cache/PulsarClientLRUCache.java
+++ b/nifi-pulsar-client-service-api/src/main/java/org/apache/nifi/pulsar/cache/PulsarConsumerLRUCache.java
@@ -21,17 +21,17 @@
import org.apache.commons.collections4.map.LRUMap;
-public class PulsarClientLRUCache extends LRUMap {
+public class PulsarConsumerLRUCache extends LRUMap {
private static final long serialVersionUID = 730163138087670453L;
private final static float LOAD_FACTOR = 0.75F;
private final static boolean SCAN_UNTIL_REMOVABLE = false;
- public PulsarClientLRUCache(int maxSize) {
+ public PulsarConsumerLRUCache(int maxSize) {
this(maxSize, LOAD_FACTOR, SCAN_UNTIL_REMOVABLE);
}
- public PulsarClientLRUCache(int maxSize, float loadFactor, boolean scanUntilRemovable) {
+ public PulsarConsumerLRUCache(int maxSize, float loadFactor, boolean scanUntilRemovable) {
super(maxSize, loadFactor, scanUntilRemovable);
}
diff --git a/nifi-pulsar-client-service-api/src/test/java/org/apache/nifi/pulsar/cache/PulsarClientLRUCacheTest.java b/nifi-pulsar-client-service-api/src/test/java/org/apache/nifi/pulsar/cache/PulsarClientLRUCacheTest.java
index 42abe7d..9274898 100644
--- a/nifi-pulsar-client-service-api/src/test/java/org/apache/nifi/pulsar/cache/PulsarClientLRUCacheTest.java
+++ b/nifi-pulsar-client-service-api/src/test/java/org/apache/nifi/pulsar/cache/PulsarClientLRUCacheTest.java
@@ -44,7 +44,7 @@ public void setUp() throws InterruptedException {
*/
@Test
public void simpleTest() {
- PulsarClientLRUCache cache = new PulsarClientLRUCache(10);
+ PulsarConsumerLRUCache cache = new PulsarConsumerLRUCache(10);
for (Character i='A'; i<='E'; i++){
cache.put(i.toString(), mockedPulsarProducer);
@@ -60,7 +60,7 @@ public void simpleTest() {
@Test
public void evictionTest() {
- PulsarClientLRUCache cache = new PulsarClientLRUCache(5);
+ PulsarConsumerLRUCache cache = new PulsarConsumerLRUCache(5);
for (Character i='A'; i<='Z'; i++){
cache.put(i.toString(), mockedPulsarProducer);
@@ -78,7 +78,7 @@ public void evictionTest() {
@Test
public void evictionLruTest() {
- PulsarClientLRUCache cache = new PulsarClientLRUCache(5);
+ PulsarConsumerLRUCache cache = new PulsarConsumerLRUCache(5);
final Character A = 'A';
@@ -102,7 +102,7 @@ public void evictionLruTest() {
@Test
public void clearTest() throws PulsarClientException {
- PulsarClientLRUCache cache = new PulsarClientLRUCache(26);
+ PulsarConsumerLRUCache cache = new PulsarConsumerLRUCache(26);
for (Character i='A'; i<='Z'; i++) {
cache.put(i.toString(), mockedPulsarProducer);
diff --git a/nifi-pulsar-client-service/pom.xml b/nifi-pulsar-client-service/pom.xml
index 476bb4b..cb53d2a 100644
--- a/nifi-pulsar-client-service/pom.xml
+++ b/nifi-pulsar-client-service/pom.xml
@@ -27,11 +27,22 @@
+
+ org.apache.pulsar
+ pulsar-client
+ ${pulsar.version}
+
+
+
+ org.apache.pulsar
+ pulsar-client-admin
+ ${pulsar.version}
+
+
org.apache.nifi
nifi-pulsar-client-service-api
${version}
- provided
diff --git a/nifi-pulsar-client-service/src/main/java/org/apache/nifi/pulsar/StandardPulsarClientService.java b/nifi-pulsar-client-service/src/main/java/org/apache/nifi/pulsar/StandardPulsarClientService.java
index a2e03fa..e69b76f 100644
--- a/nifi-pulsar-client-service/src/main/java/org/apache/nifi/pulsar/StandardPulsarClientService.java
+++ b/nifi-pulsar-client-service/src/main/java/org/apache/nifi/pulsar/StandardPulsarClientService.java
@@ -53,9 +53,7 @@ public class StandardPulsarClientService extends AbstractControllerService imple
.defaultValue("false")
.description("")
.displayName("Allow TLS Insecure Connection")
- .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.required(false)
- .addValidator(StandardValidators.BOOLEAN_VALIDATOR)
.build();
public static final PropertyDescriptor AUTHENTICATION_SERVICE = new PropertyDescriptor.Builder()
@@ -96,9 +94,7 @@ public class StandardPulsarClientService extends AbstractControllerService imple
+ "It validates incoming x509 certificate and matches provided hostname(CN/SAN) with expected "
+ "broker's host name. It follows RFC 2818, 3.1. Server Identity hostname verification.")
.displayName("Enable TLS Hostname Verification")
- .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.required(false)
- .addValidator(StandardValidators.BOOLEAN_VALIDATOR)
.build();
public static final PropertyDescriptor IO_THREADS = new PropertyDescriptor.Builder()
@@ -233,10 +229,10 @@ protected List getSupportedPropertyDescriptors() {
@OnEnabled
public void onEnabled(final ConfigurationContext context) throws InitializationException, UnsupportedAuthenticationException {
try {
- client = getClientBuilder(context).build();
+ client = getClient(context);
brokerUrl = context.getProperty(PULSAR_SERVICE_URL).evaluateAttributeExpressions().getValue();
} catch (Exception e) {
- throw new InitializationException("Unable to create Pulsar Client", e);
+ throw new InitializationException("Unable to connect to the Pulsar cluster ", e);
}
}
@@ -258,11 +254,11 @@ public String getPulsarBrokerRootURL() {
return brokerUrl;
}
- private ClientBuilder getClientBuilder(ConfigurationContext context) throws UnsupportedAuthenticationException, MalformedURLException {
+ private PulsarClient getClient(ConfigurationContext context) throws MalformedURLException, PulsarClientException {
ClientBuilder builder = PulsarClient.builder()
- .allowTlsInsecureConnection(context.getProperty(ALLOW_TLS_INSECURE_CONNECTION).evaluateAttributeExpressions().asBoolean())
- .enableTlsHostnameVerification(context.getProperty(ENABLE_TLS_HOSTNAME_VERIFICATION).evaluateAttributeExpressions().asBoolean())
+ .allowTlsInsecureConnection(context.getProperty(ALLOW_TLS_INSECURE_CONNECTION).asBoolean())
+ .enableTlsHostnameVerification(context.getProperty(ENABLE_TLS_HOSTNAME_VERIFICATION).asBoolean())
.maxConcurrentLookupRequests(context.getProperty(CONCURRENT_LOOKUP_REQUESTS).evaluateAttributeExpressions().asInteger())
.connectionsPerBroker(context.getProperty(CONNECTIONS_PER_BROKER).evaluateAttributeExpressions().asInteger())
.ioThreads(context.getProperty(IO_THREADS).evaluateAttributeExpressions().asInteger())
@@ -288,7 +284,7 @@ private ClientBuilder getClientBuilder(ConfigurationContext context) throws Unsu
}
builder = builder.serviceUrl(context.getProperty(PULSAR_SERVICE_URL).evaluateAttributeExpressions().getValue());
- return builder;
+ return builder.build();
}
}
diff --git a/nifi-pulsar-client-service/src/main/java/org/apache/nifi/pulsar/validator/PulsarBrokerUrlValidator.java b/nifi-pulsar-client-service/src/main/java/org/apache/nifi/pulsar/validator/PulsarBrokerUrlValidator.java
index 8f11ed2..b0d21c5 100644
--- a/nifi-pulsar-client-service/src/main/java/org/apache/nifi/pulsar/validator/PulsarBrokerUrlValidator.java
+++ b/nifi-pulsar-client-service/src/main/java/org/apache/nifi/pulsar/validator/PulsarBrokerUrlValidator.java
@@ -16,7 +16,7 @@
*/
package org.apache.nifi.pulsar.validator;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.components.Validator;
diff --git a/nifi-pulsar-client-service/src/test/java/org/apache/nifi/pulsar/TestStandardPulsarClientService.java b/nifi-pulsar-client-service/src/test/java/org/apache/nifi/pulsar/TestStandardPulsarClientService.java
index f9c4bd9..1efb941 100644
--- a/nifi-pulsar-client-service/src/test/java/org/apache/nifi/pulsar/TestStandardPulsarClientService.java
+++ b/nifi-pulsar-client-service/src/test/java/org/apache/nifi/pulsar/TestStandardPulsarClientService.java
@@ -24,7 +24,7 @@
public class TestStandardPulsarClientService {
@Test
- public void testService() throws InitializationException {
+ public void validServiceTest() throws InitializationException {
final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
final PulsarClientService service = new StandardPulsarClientService();
runner.addControllerService("test-good", service);
diff --git a/nifi-pulsar-processors/pom.xml b/nifi-pulsar-processors/pom.xml
index 3fb9fa8..af044c1 100644
--- a/nifi-pulsar-processors/pom.xml
+++ b/nifi-pulsar-processors/pom.xml
@@ -24,7 +24,7 @@
nifi-pulsar-processors
jar
-
+
org.apache.nifi
@@ -56,9 +56,38 @@
org.apache.nifi
nifi-pulsar-client-service-api
${version}
- provided
+
+ org.apache.commons
+ commons-lang3
+ ${commons-lang3.version}
+
+
+
+ org.apache.commons
+ commons-compress
+ ${commons-compress.version}
+
+
+
+ org.apache.directory.studio
+ org.apache.commons.io
+ ${commons.io.version}
+
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ ${jackson-core.version}
+
+
+
+ com.google.protobuf
+ protobuf-java
+ ${protobuf3.version}
+
+
org.apache.nifi
nifi-mock
@@ -77,24 +106,6 @@
test
-
- org.apache.commons
- commons-lang3
- ${commons-lang3.version}
-
-
-
- org.apache.directory.studio
- org.apache.commons.io
- ${commons.io.version}
-
-
-
- com.fasterxml.jackson.core
- jackson-core
- ${jackson-core.version}
-
-
diff --git a/nifi-pulsar-processors/src/main/java/org/apache/nifi/processors/pulsar/AbstractPulsarConsumerProcessor.java b/nifi-pulsar-processors/src/main/java/org/apache/nifi/processors/pulsar/AbstractPulsarConsumerProcessor.java
index 91ac5d6..93638d4 100644
--- a/nifi-pulsar-processors/src/main/java/org/apache/nifi/processors/pulsar/AbstractPulsarConsumerProcessor.java
+++ b/nifi-pulsar-processors/src/main/java/org/apache/nifi/processors/pulsar/AbstractPulsarConsumerProcessor.java
@@ -47,15 +47,18 @@
import org.apache.nifi.processor.ProcessSession;
import org.apache.nifi.processor.Relationship;
import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.processors.pulsar.PropertyMappingUtils;
import org.apache.nifi.pulsar.PulsarClientService;
-import org.apache.nifi.pulsar.cache.PulsarClientLRUCache;
+import org.apache.nifi.pulsar.cache.PulsarConsumerLRUCache;
import org.apache.nifi.util.StringUtils;
import org.apache.pulsar.client.api.Consumer;
import org.apache.pulsar.client.api.ConsumerBuilder;
import org.apache.pulsar.client.api.ConsumerCryptoFailureAction;
import org.apache.pulsar.client.api.Message;
import org.apache.pulsar.client.api.PulsarClientException;
+import org.apache.pulsar.client.api.Schema;
import org.apache.pulsar.client.api.SubscriptionType;
+import org.apache.pulsar.client.api.schema.GenericRecord;
public abstract class AbstractPulsarConsumerProcessor extends AbstractProcessor {
protected static final String PULSAR_MESSAGE_KEY = "__KEY__";
@@ -263,9 +266,9 @@ public abstract class AbstractPulsarConsumerProcessor extends AbstractProcess
}
private PulsarClientService pulsarClientService;
- private PulsarClientLRUCache> consumers;
+ private PulsarConsumerLRUCache> consumers;
private ExecutorService consumerPool;
- private ExecutorCompletionService>> consumerService;
+ private ExecutorCompletionService>> consumerService;
private ExecutorService ackPool;
private ExecutorCompletionService