public class PulsarClientImpl extends Object implements PulsarClient
Constructor and Description |
---|
PulsarClientImpl(ClientConfigurationData conf) |
PulsarClientImpl(ClientConfigurationData conf,
io.netty.channel.EventLoopGroup eventLoopGroup) |
PulsarClientImpl(ClientConfigurationData conf,
io.netty.channel.EventLoopGroup eventLoopGroup,
ConnectionPool cnxPool) |
PulsarClientImpl(String serviceUrl,
ClientConfiguration conf)
Deprecated.
|
PulsarClientImpl(String serviceUrl,
ClientConfiguration conf,
io.netty.channel.EventLoopGroup eventLoopGroup)
Deprecated.
|
PulsarClientImpl(String serviceUrl,
ClientConfiguration conf,
io.netty.channel.EventLoopGroup eventLoopGroup,
ConnectionPool cnxPool)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the PulsarClient and release all the resources.
|
CompletableFuture<Void> |
closeAsync()
Asynchronously close the PulsarClient and release all the resources.
|
Producer<byte[]> |
createProducer(String topic)
Create a producer with default
ProducerConfiguration for publishing on a specific topic |
Producer<byte[]> |
createProducer(String topic,
ProducerConfiguration conf)
Create a producer with given
ProducerConfiguration for publishing on a specific topic |
CompletableFuture<Producer<byte[]>> |
createProducerAsync(ProducerConfigurationData conf) |
<T> CompletableFuture<Producer<T>> |
createProducerAsync(ProducerConfigurationData conf,
Schema<T> schema) |
<T> CompletableFuture<Producer<T>> |
createProducerAsync(ProducerConfigurationData conf,
Schema<T> schema,
ProducerInterceptors<T> interceptors) |
CompletableFuture<Producer<byte[]>> |
createProducerAsync(String topic)
Asynchronously create a producer with default
ProducerConfiguration for publishing on a specific topic |
CompletableFuture<Producer<byte[]>> |
createProducerAsync(String topic,
ProducerConfiguration conf)
Asynchronously create a producer with given
ProducerConfiguration for publishing on a specific topic |
Reader<byte[]> |
createReader(String topic,
MessageId startMessageId,
ReaderConfiguration conf)
Create a topic reader with given
ReaderConfiguration for reading messages from the specified topic. |
CompletableFuture<Reader<byte[]>> |
createReaderAsync(ReaderConfigurationData<byte[]> conf) |
<T> CompletableFuture<Reader<T>> |
createReaderAsync(ReaderConfigurationData<T> conf,
Schema<T> schema) |
CompletableFuture<Reader<byte[]>> |
createReaderAsync(String topic,
MessageId startMessageId,
ReaderConfiguration conf)
Asynchronously create a topic reader with given
ReaderConfiguration for reading messages from the
specified topic. |
io.netty.channel.EventLoopGroup |
eventLoopGroup() |
ConnectionPool |
getCnxPool() |
ClientConfigurationData |
getConfiguration() |
protected CompletableFuture<ClientCnx> |
getConnection(String topic) |
LookupService |
getLookup() |
CompletableFuture<Integer> |
getNumberOfPartitions(String topic) |
CompletableFuture<PartitionedTopicMetadata> |
getPartitionedTopicMetadata(String topic) |
CompletableFuture<Optional<SchemaInfo>> |
getSchema(String topic)
Read the schema information for a given topic.
|
ConsumerBuilder<byte[]> |
newConsumer()
Create a consumer with default for subscribing on a specific topic
|
<T> ConsumerBuilder<T> |
newConsumer(Schema<T> schema)
Create a consumer with default for subscribing on a specific topic
Since 2.2, if you are creating a consumer with non-bytes schema on a non-existence topic, it will
automatically create the topic with the provided schema.
|
ProducerBuilder<byte[]> |
newProducer()
Create a producer with default for publishing on a specific topic
|
<T> ProducerBuilder<T> |
newProducer(Schema<T> schema)
Create a producer with default for publishing on a specific topic
|
ReaderBuilder<byte[]> |
newReader()
Create a topic reader for reading messages from the specified topic.
|
<T> ReaderBuilder<T> |
newReader(Schema<T> schema)
Create a topic reader for reading messages from the specified topic.
|
long |
newRequestId() |
CompletableFuture<Consumer<byte[]>> |
patternTopicSubscribeAsync(ConsumerConfigurationData<byte[]> conf) |
void |
reloadLookUp() |
void |
shutdown()
Perform immediate shutdown of PulsarClient.
|
Consumer<byte[]> |
subscribe(String topic,
String subscription)
Subscribe to the given topic and subscription combination with default
ConsumerConfiguration |
Consumer<byte[]> |
subscribe(String topic,
String subscription,
ConsumerConfiguration conf)
Subscribe to the given topic and subscription combination with given
ConsumerConfiguration |
CompletableFuture<Consumer<byte[]>> |
subscribeAsync(ConsumerConfigurationData<byte[]> conf) |
<T> CompletableFuture<Consumer<T>> |
subscribeAsync(ConsumerConfigurationData<T> conf,
Schema<T> schema,
ConsumerInterceptors<T> interceptors) |
CompletableFuture<Consumer<byte[]>> |
subscribeAsync(String topic,
String subscription)
Asynchronously subscribe to the given topic and subscription combination using default
ConsumerConfiguration |
CompletableFuture<Consumer<byte[]>> |
subscribeAsync(String topic,
String subscription,
ConsumerConfiguration conf)
Asynchronously subscribe to the given topic and subscription combination using given
ConsumerConfiguration |
io.netty.util.Timer |
timer()
visiable for pulsar-functions
|
static List<String> |
topicsPatternFilter(List<String> original,
Pattern topicsPattern) |
void |
updateServiceUrl(String serviceUrl)
Update the service URL this client is using.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
builder, create, create
@Deprecated public PulsarClientImpl(String serviceUrl, ClientConfiguration conf) throws PulsarClientException
PulsarClientException
@Deprecated public PulsarClientImpl(String serviceUrl, ClientConfiguration conf, io.netty.channel.EventLoopGroup eventLoopGroup) throws PulsarClientException
PulsarClientException
@Deprecated public PulsarClientImpl(String serviceUrl, ClientConfiguration conf, io.netty.channel.EventLoopGroup eventLoopGroup, ConnectionPool cnxPool) throws PulsarClientException
PulsarClientException
public PulsarClientImpl(ClientConfigurationData conf) throws PulsarClientException
PulsarClientException
public PulsarClientImpl(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup) throws PulsarClientException
PulsarClientException
public PulsarClientImpl(ClientConfigurationData conf, io.netty.channel.EventLoopGroup eventLoopGroup, ConnectionPool cnxPool) throws PulsarClientException
PulsarClientException
public ClientConfigurationData getConfiguration()
public ProducerBuilder<byte[]> newProducer()
PulsarClient
Example:
Producer producer = client.newProducer().topic(myTopic).create();
newProducer
in interface PulsarClient
ProducerBuilder
object to configure and construct the Producer
instancepublic <T> ProducerBuilder<T> newProducer(Schema<T> schema)
PulsarClient
Example:
Producer producer = client.newProducer(mySchema).topic(myTopic).create();
newProducer
in interface PulsarClient
schema
- provide a way to convert between serialized data and domain objectsProducerBuilder
object to configure and construct the Producer
instancepublic ConsumerBuilder<byte[]> newConsumer()
PulsarClient
newConsumer
in interface PulsarClient
ConsumerBuilder
object to configure and construct the Consumer
instancepublic <T> ConsumerBuilder<T> newConsumer(Schema<T> schema)
PulsarClient
newConsumer
in interface PulsarClient
schema
- provide a way to convert between serialized data and domain objectsConsumerBuilder
object to configure and construct the Consumer
instancepublic ReaderBuilder<byte[]> newReader()
PulsarClient
The Reader provides a low-level abstraction that allows for manual positioning in the topic, without using a subscription. Reader can only work on non-partitioned topics.
newReader
in interface PulsarClient
ReaderBuilder
that can be used to configure and construct a Reader
instancepublic <T> ReaderBuilder<T> newReader(Schema<T> schema)
PulsarClient
The Reader provides a low-level abstraction that allows for manual positioning in the topic, without using a subscription. Reader can only work on non-partitioned topics.
newReader
in interface PulsarClient
schema
- provide a way to convert between serialized data and domain objectsReaderBuilder
that can be used to configure and construct a Reader
instancepublic Producer<byte[]> createProducer(String topic) throws PulsarClientException
PulsarClient
ProducerConfiguration
for publishing on a specific topiccreateProducer
in interface PulsarClient
topic
- The name of the topic where to producePulsarClientException.AlreadyClosedException
- if the client was already closedPulsarClientException.InvalidTopicNameException
- if the topic name is not validPulsarClientException.AuthenticationException
- if there was an error with the supplied credentialsPulsarClientException.AuthorizationException
- if the authorization to publish on topic was deniedPulsarClientException
public Producer<byte[]> createProducer(String topic, ProducerConfiguration conf) throws PulsarClientException
PulsarClient
ProducerConfiguration
for publishing on a specific topiccreateProducer
in interface PulsarClient
topic
- The name of the topic where to produceconf
- The ProducerConfiguration
objectPulsarClientException
- if it was not possible to create the producerpublic CompletableFuture<Producer<byte[]>> createProducerAsync(String topic)
PulsarClient
ProducerConfiguration
for publishing on a specific topiccreateProducerAsync
in interface PulsarClient
topic
- The name of the topic where to producepublic CompletableFuture<Producer<byte[]>> createProducerAsync(String topic, ProducerConfiguration conf)
PulsarClient
ProducerConfiguration
for publishing on a specific topiccreateProducerAsync
in interface PulsarClient
topic
- The name of the topic where to produceconf
- The ProducerConfiguration
objectpublic CompletableFuture<Producer<byte[]>> createProducerAsync(ProducerConfigurationData conf)
public <T> CompletableFuture<Producer<T>> createProducerAsync(ProducerConfigurationData conf, Schema<T> schema)
public <T> CompletableFuture<Producer<T>> createProducerAsync(ProducerConfigurationData conf, Schema<T> schema, ProducerInterceptors<T> interceptors)
public Consumer<byte[]> subscribe(String topic, String subscription) throws PulsarClientException
PulsarClient
ConsumerConfiguration
subscribe
in interface PulsarClient
topic
- The name of the topicsubscription
- The name of the subscriptionConsumer
objectPulsarClientException
public Consumer<byte[]> subscribe(String topic, String subscription, ConsumerConfiguration conf) throws PulsarClientException
PulsarClient
ConsumerConfiguration
subscribe
in interface PulsarClient
topic
- The name of the topicsubscription
- The name of the subscriptionconf
- The ConsumerConfiguration
objectConsumer
objectPulsarClientException
public CompletableFuture<Consumer<byte[]>> subscribeAsync(String topic, String subscription)
PulsarClient
ConsumerConfiguration
subscribeAsync
in interface PulsarClient
topic
- The topic namesubscription
- The subscription nameConsumer
objectpublic CompletableFuture<Consumer<byte[]>> subscribeAsync(String topic, String subscription, ConsumerConfiguration conf)
PulsarClient
ConsumerConfiguration
subscribeAsync
in interface PulsarClient
topic
- The name of the topicsubscription
- The name of the subscriptionconf
- The ConsumerConfiguration
objectConsumer
objectpublic CompletableFuture<Consumer<byte[]>> subscribeAsync(ConsumerConfigurationData<byte[]> conf)
public <T> CompletableFuture<Consumer<T>> subscribeAsync(ConsumerConfigurationData<T> conf, Schema<T> schema, ConsumerInterceptors<T> interceptors)
public CompletableFuture<Consumer<byte[]>> patternTopicSubscribeAsync(ConsumerConfigurationData<byte[]> conf)
public static List<String> topicsPatternFilter(List<String> original, Pattern topicsPattern)
public Reader<byte[]> createReader(String topic, MessageId startMessageId, ReaderConfiguration conf) throws PulsarClientException
PulsarClient
ReaderConfiguration
for reading messages from the specified topic.
The Reader provides a low-level abstraction that allows for manual positioning in the topic, without using a subscription. Reader can only work on non-partitioned topics.
The initial reader positioning is done by specifying a message id. The options are:
MessageId.earliest
: Start reading from the earliest message available in the topic
MessageId.latest
: Start reading from the end topic, only getting messages published after the
reader was created
MessageId
: When passing a particular message id, the reader will position itself on that
specific position. The first message to be read will be the message next to the specified messageId.
createReader
in interface PulsarClient
topic
- The name of the topic where to readstartMessageId
- The message id where the reader will position itself. The first message returned will be the one after
the specified startMessageIdconf
- The ReaderConfiguration
objectReader
objectPulsarClientException
public CompletableFuture<Reader<byte[]>> createReaderAsync(String topic, MessageId startMessageId, ReaderConfiguration conf)
PulsarClient
ReaderConfiguration
for reading messages from the
specified topic.
The Reader provides a low-level abstraction that allows for manual positioning in the topic, without using a subscription. Reader can only work on non-partitioned topics.
The initial reader positioning is done by specifying a message id. The options are:
MessageId.earliest
: Start reading from the earliest message available in the topic
MessageId.latest
: Start reading from the end topic, only getting messages published after the
reader was created
MessageId
: When passing a particular message id, the reader will position itself on that
specific position. The first message to be read will be the message next to the specified messageId.
createReaderAsync
in interface PulsarClient
topic
- The name of the topic where to readstartMessageId
- The message id where the reader will position itself. The first message returned will be the one after
the specified startMessageIdconf
- The ReaderConfiguration
objectpublic CompletableFuture<Reader<byte[]>> createReaderAsync(ReaderConfigurationData<byte[]> conf)
public <T> CompletableFuture<Reader<T>> createReaderAsync(ReaderConfigurationData<T> conf, Schema<T> schema)
public CompletableFuture<Optional<SchemaInfo>> getSchema(String topic)
public void close() throws PulsarClientException
PulsarClient
close
in interface Closeable
close
in interface AutoCloseable
close
in interface PulsarClient
PulsarClientException
- if the close operation failspublic CompletableFuture<Void> closeAsync()
PulsarClient
closeAsync
in interface PulsarClient
public void shutdown() throws PulsarClientException
PulsarClient
shutdown
in interface PulsarClient
PulsarClientException
- if the forceful shutdown failspublic void updateServiceUrl(String serviceUrl) throws PulsarClientException
PulsarClient
updateServiceUrl
in interface PulsarClient
serviceUrl
- the new service URL this client should connect toPulsarClientException
- in case the serviceUrl is not validprotected CompletableFuture<ClientCnx> getConnection(String topic)
public io.netty.util.Timer timer()
public long newRequestId()
public ConnectionPool getCnxPool()
public io.netty.channel.EventLoopGroup eventLoopGroup()
public LookupService getLookup()
public void reloadLookUp() throws PulsarClientException
PulsarClientException
public CompletableFuture<Integer> getNumberOfPartitions(String topic)
public CompletableFuture<PartitionedTopicMetadata> getPartitionedTopicMetadata(String topic)
Copyright © 2017–2018 Apache Software Foundation. All rights reserved.