Java Code Examples for org.apache.pulsar.client.api.PulsarClientException#InvalidConfigurationException

The following examples show how to use org.apache.pulsar.client.api.PulsarClientException#InvalidConfigurationException . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PulsarClientImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
public PulsarClientImpl(ClientConfigurationData conf, EventLoopGroup eventLoopGroup, ConnectionPool cnxPool)
        throws PulsarClientException {
    if (conf == null || isBlank(conf.getServiceUrl()) || eventLoopGroup == null) {
        throw new PulsarClientException.InvalidConfigurationException("Invalid client configuration");
    }
    this.eventLoopGroup = eventLoopGroup;
    setAuth(conf);
    this.conf = conf;
    this.clientClock = conf.getClock();
    conf.getAuthentication().start();
    this.cnxPool = cnxPool;
    externalExecutorProvider = new ExecutorProvider(conf.getNumListenerThreads(), getThreadFactory("pulsar-external-listener"));
    if (conf.getServiceUrl().startsWith("http")) {
        lookup = new HttpLookupService(conf, eventLoopGroup);
    } else {
        lookup = new BinaryProtoLookupService(this, conf.getServiceUrl(), conf.getListenerName(), conf.isUseTls(), externalExecutorProvider.getExecutor());
    }
    timer = new HashedWheelTimer(getThreadFactory("pulsar-timer"), 1, TimeUnit.MILLISECONDS);
    producers = Maps.newIdentityHashMap();
    consumers = Maps.newIdentityHashMap();
    state.set(State.Open);
}
 
Example 2
Source File: ZeroQueueSizeTest.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Test(expectedExceptions = PulsarClientException.InvalidConfigurationException.class)
public void zeroQueueSizeReceieveAsyncInCompatibility() throws PulsarClientException {
    String key = "zeroQueueSizeReceieveAsyncInCompatibility";
    final String topicName = "persistent://prop/use/ns-abc/topic-" + key;
    final String subscriptionName = "my-ex-subscription-" + key;

    Consumer<byte[]> consumer = pulsarClient.newConsumer().topic(topicName).subscriptionName(subscriptionName)
            .receiverQueueSize(0).subscribe();
    consumer.receive(10, TimeUnit.SECONDS);
}
 
Example 3
Source File: ConsumerBase.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Override
public Message<T> receive() throws PulsarClientException {
    if (listener != null) {
        throw new PulsarClientException.InvalidConfigurationException(
                "Cannot use receive() when a listener has been set");
    }
    verifyConsumerState();
    return internalReceive();
}
 
Example 4
Source File: ConsumerBase.java    From pulsar with Apache License 2.0 5 votes vote down vote up
@Override
public Message<T> receive(int timeout, TimeUnit unit) throws PulsarClientException {
    if (conf.getReceiverQueueSize() == 0) {
        throw new PulsarClientException.InvalidConfigurationException(
                "Can't use receive with timeout, if the queue size is 0");
    }
    if (listener != null) {
        throw new PulsarClientException.InvalidConfigurationException(
                "Cannot use receive() when a listener has been set");
    }

    verifyConsumerState();
    return internalReceive(timeout, unit);
}
 
Example 5
Source File: ConsumerBase.java    From pulsar with Apache License 2.0 5 votes vote down vote up
private void verifyBatchReceive() throws PulsarClientException {
    if (listener != null) {
        throw new PulsarClientException.InvalidConfigurationException(
            "Cannot use receive() when a listener has been set");
    }
    if (conf.getReceiverQueueSize() == 0) {
        throw new PulsarClientException.InvalidConfigurationException(
            "Can't use batch receive, if the queue size is 0");
    }
}