Github user markap14 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2702#discussion_r197454275
  
    --- Diff: 
nifi-nar-bundles/nifi-pulsar-bundle/nifi-pulsar-processors/src/main/java/org/apache/nifi/processors/pulsar/AbstractPulsarConsumerProcessor.java
 ---
    @@ -0,0 +1,296 @@
    +/*
    + * 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.nifi.processors.pulsar;
    +
    +import java.util.ArrayList;
    +import java.util.Collections;
    +import java.util.HashSet;
    +import java.util.List;
    +import java.util.Set;
    +import java.util.concurrent.ExecutorCompletionService;
    +import java.util.concurrent.ExecutorService;
    +import java.util.concurrent.Executors;
    +import java.util.concurrent.RejectedExecutionException;
    +import java.util.concurrent.TimeUnit;
    +
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.annotation.lifecycle.OnStopped;
    +import org.apache.nifi.annotation.lifecycle.OnUnscheduled;
    +import org.apache.nifi.components.AllowableValue;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.expression.ExpressionLanguageScope;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.util.StandardValidators;
    +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.SubscriptionType;
    +
    +public abstract class AbstractPulsarConsumerProcessor<T> extends 
AbstractPulsarProcessor {
    +
    +    static final AllowableValue EXCLUSIVE = new 
AllowableValue("Exclusive", "Exclusive", "There can be only 1 consumer on the 
same topic with the same subscription name");
    +    static final AllowableValue SHARED = new AllowableValue("Shared", 
"Shared", "Multiple consumer will be able to use the same subscription name and 
the messages");
    +    static final AllowableValue FAILOVER = new AllowableValue("Failover", 
"Failover", "Multiple consumer will be able to use the same subscription name 
but only 1 consumer "
    +                    + "will receive the messages. If that consumer 
disconnects, one of the other connected consumers will start receiving 
messages");
    +
    +    static final AllowableValue CONSUME = new 
AllowableValue(ConsumerCryptoFailureAction.CONSUME.name(), "Consume",
    +            "Mark the message as consumed despite being unable to decrypt 
the contents");
    +    static final AllowableValue DISCARD = new 
AllowableValue(ConsumerCryptoFailureAction.DISCARD.name(), "Discard",
    +            "Discard the message and don't perform any addtional 
processing on the message");
    +    static final AllowableValue FAIL = new 
AllowableValue(ConsumerCryptoFailureAction.FAIL.name(), "Fail",
    +            "Report a failure condition, and the route the message 
contents to the FAILED relationship.");
    +
    +    public static final PropertyDescriptor TOPICS = new 
PropertyDescriptor.Builder()
    +            .name("topics")
    +            .displayName("Topic Names")
    +            .description("Specify the topics this consumer will subscribe 
on. "
    +                    + "You can specify multiple topics in a 
comma-separated list."
    +                    + "E.g topicA, topicB, topicC ")
    +            .required(false)
    +            
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
    +            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
    +            .build();
    +
    +    public static final PropertyDescriptor TOPICS_PATTERN = new 
PropertyDescriptor.Builder()
    +            .name("Topics Pattern")
    +            .description("Specify a pattern for topics that this consumer 
will subscribe on. "
    +                    + "It accepts regular expression and will be compiled 
into a pattern internally. "
    +                    + "E.g. 
\"persistent://prop/use/ns-abc/pattern-topic-.*\"")
    +            .required(false)
    +            .addValidator(StandardValidators.REGULAR_EXPRESSION_VALIDATOR)
    +            .build();
    +
    +    public static final PropertyDescriptor SUBSCRIPTION_NAME = new 
PropertyDescriptor.Builder()
    +            .name("Subscription Name")
    +            .description("Specify the subscription name for this 
consumer.")
    +            .required(true)
    +            .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
    +            .build();
    +
    +    public static final PropertyDescriptor ASYNC_ENABLED = new 
PropertyDescriptor.Builder()
    +            .name("Async Enabled")
    +            .description("Control whether the messages will be consumed 
asyncronously or not. Messages consumed"
    +                    + " syncronously will be acknowledged immediately 
before processing the next message, while"
    +                    + " asyncronous messages will be acknowledged after 
the Pulsar broker responds.")
    +            .required(true)
    +            .addValidator(StandardValidators.BOOLEAN_VALIDATOR)
    --- End diff --
    
    We should user `allowableValues("true", "false")` instead of a boolean 
validator.


---

Reply via email to