new PulsarClientException.InvalidConfigurationException("Consumer configuration undefined")); .failedFuture(new PulsarClientException.InvalidConfigurationException("Invalid startMessageId"));
LOG.error("Failed to close the authentication service", ioe); throw new PulsarClientException.InvalidConfigurationException(e.getMessage());
new PulsarClientException.InvalidConfigurationException("Consumer configuration undefined")); .failedFuture(new PulsarClientException.InvalidConfigurationException("Invalid startMessageId"));
LOG.error("Failed to close the authentication service", ioe); throw new PulsarClientException.InvalidConfigurationException(e.getMessage());
confBuilder.setUseInsecureTrustManager(tlsAllowInsecureConnection); } catch (Exception e) { throw new PulsarClientException.InvalidConfigurationException(e);
if (conf == null) { return FutureUtil.failedFuture( new PulsarClientException.InvalidConfigurationException("Producer configuration undefined")); new PulsarClientException.InvalidConfigurationException("AutoConsumeSchema is only used by consumers to detect schemas automatically"));
new PulsarClientException.InvalidConfigurationException("Consumer configuration undefined")); .failedFuture(new PulsarClientException.InvalidConfigurationException("Empty subscription name")); || (conf.getSubscriptionType() != SubscriptionType.Exclusive && conf.getSubscriptionType() != SubscriptionType.Failover))) { return FutureUtil.failedFuture(new PulsarClientException.InvalidConfigurationException( "Read compacted can only be used with exclusive of failover persistent subscriptions")); return FutureUtil.failedFuture(new PulsarClientException.InvalidConfigurationException( "Active consumer listener is only supported for failover subscription"));
@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"); } switch (getState()) { case Ready: case Connecting: break; // Ok case Closing: case Closed: throw new PulsarClientException.AlreadyClosedException("Consumer already closed"); case Terminated: throw new PulsarClientException.AlreadyClosedException("Topic was terminated"); case Failed: case Uninitialized: throw new PulsarClientException.NotConnectedException(); } return internalReceive(timeout, unit); }
@Override public CompletableFuture<Message<T>> receiveAsync() { if (listener != null) { return FutureUtil.failedFuture(new PulsarClientException.InvalidConfigurationException( "Cannot use receive() when a listener has been set")); } switch (getState()) { case Ready: case Connecting: break; // Ok case Closing: case Closed: return FutureUtil.failedFuture(new PulsarClientException.AlreadyClosedException("Consumer already closed")); case Terminated: return FutureUtil.failedFuture(new PulsarClientException.AlreadyClosedException("Topic was terminated")); case Failed: case Uninitialized: return FutureUtil.failedFuture(new PulsarClientException.NotConnectedException()); } return internalReceiveAsync(); }
@Override public Message<T> receive() throws PulsarClientException { if (listener != null) { throw new PulsarClientException.InvalidConfigurationException( "Cannot use receive() when a listener has been set"); } switch (getState()) { case Ready: case Connecting: break; // Ok case Closing: case Closed: throw new PulsarClientException.AlreadyClosedException("Consumer already closed"); case Terminated: throw new PulsarClientException.AlreadyClosedException("Topic was terminated"); case Failed: case Uninitialized: throw new PulsarClientException.NotConnectedException(); default: break; } return internalReceive(); }
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; this.conf = conf; 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.isUseTls(), externalExecutorProvider.getExecutor()); } timer = new HashedWheelTimer(getThreadFactory("pulsar-timer"), 1, TimeUnit.MILLISECONDS); producers = Maps.newIdentityHashMap(); consumers = Maps.newIdentityHashMap(); state.set(State.Open); }
@Override public Producer<byte[]> createProducer(final String topic, final ProducerConfiguration conf) throws PulsarClientException { if (conf == null) { throw new PulsarClientException.InvalidConfigurationException("Invalid null configuration object"); } try { ProducerConfigurationData confData = conf.getProducerConfigurationData().clone(); confData.setTopicName(topic); return createProducerAsync(confData).get(); } catch (ExecutionException e) { Throwable t = e.getCause(); if (t instanceof PulsarClientException) { throw (PulsarClientException) t; } else { throw new PulsarClientException(t); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new PulsarClientException(e); } }
@Override public CompletableFuture<Consumer<T>> subscribeAsync() { if (conf.getTopicNames().isEmpty() && conf.getTopicsPattern() == null) { return FutureUtil .failedFuture(new InvalidConfigurationException("Topic name must be set on the consumer builder")); } if (StringUtils.isBlank(conf.getSubscriptionName())) { return FutureUtil.failedFuture( new InvalidConfigurationException("Subscription name must be set on the consumer builder")); } return interceptorList == null || interceptorList.size() == 0 ? client.subscribeAsync(conf, schema, null) : client.subscribeAsync(conf, schema, new ConsumerInterceptors<>(interceptorList)); }
@Override public CompletableFuture<Void> acknowledgeCumulativeAsync(MessageId messageId) { if (!isCumulativeAcknowledgementAllowed(conf.getSubscriptionType())) { return FutureUtil.failedFuture(new PulsarClientException.InvalidConfigurationException( "Cannot use cumulative acks on a non-exclusive subscription")); } return doAcknowledge(messageId, AckType.Cumulative, Collections.emptyMap()); }
public CompletableFuture<PartitionedTopicMetadata> getPartitionedTopicMetadata(String topic) { CompletableFuture<PartitionedTopicMetadata> metadataFuture; try { TopicName topicName = TopicName.get(topic); metadataFuture = lookup.getPartitionedTopicMetadata(topicName); } catch (IllegalArgumentException e) { return FutureUtil.failedFuture(new PulsarClientException.InvalidConfigurationException(e.getMessage())); } return metadataFuture; }
@Override public CompletableFuture<Consumer<byte[]>> subscribeAsync(final String topic, final String subscription, final ConsumerConfiguration conf) { if (conf == null) { return FutureUtil.failedFuture( new PulsarClientException.InvalidConfigurationException("Invalid null configuration")); } ConsumerConfigurationData<byte[]> confData = conf.getConfigurationData().clone(); confData.getTopicNames().add(topic); confData.setSubscriptionName(subscription); return subscribeAsync(confData); }
if (conf == null) { return FutureUtil.failedFuture( new PulsarClientException.InvalidConfigurationException("Producer configuration undefined")); new PulsarClientException.InvalidConfigurationException("AutoConsumeSchema is only used by consumers to detect schemas automatically"));
confBuilder.setUseInsecureTrustManager(tlsAllowInsecureConnection); } catch (Exception e) { throw new PulsarClientException.InvalidConfigurationException(e);
new PulsarClientException.InvalidConfigurationException("Consumer configuration undefined")); .failedFuture(new PulsarClientException.InvalidConfigurationException("Empty subscription name")); || (conf.getSubscriptionType() != SubscriptionType.Exclusive && conf.getSubscriptionType() != SubscriptionType.Failover))) { return FutureUtil.failedFuture(new PulsarClientException.InvalidConfigurationException( "Read compacted can only be used with exclusive of failover persistent subscriptions")); return FutureUtil.failedFuture(new PulsarClientException.InvalidConfigurationException( "Active consumer listener is only supported for failover subscription"));
@Override public Message<T> receive() throws PulsarClientException { if (listener != null) { throw new PulsarClientException.InvalidConfigurationException( "Cannot use receive() when a listener has been set"); } switch (getState()) { case Ready: case Connecting: break; // Ok case Closing: case Closed: throw new PulsarClientException.AlreadyClosedException("Consumer already closed"); case Terminated: throw new PulsarClientException.AlreadyClosedException("Topic was terminated"); case Failed: case Uninitialized: throw new PulsarClientException.NotConnectedException(); default: break; } return internalReceive(); }