Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve] [broker] Support create RawReader based on configuration #22280

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -22,6 +22,7 @@
import java.util.concurrent.CompletableFuture;
import org.apache.pulsar.client.impl.PulsarClientImpl;
import org.apache.pulsar.client.impl.RawReaderImpl;
import org.apache.pulsar.client.impl.conf.ConsumerConfigurationData;

/**
* Topic reader which receives raw messages (i.e. as they are stored in the managed ledger).
Expand All @@ -43,6 +44,16 @@ static CompletableFuture<RawReader> create(PulsarClient client, String topic, St
return future.thenApply(__ -> r);
}

static CompletableFuture<RawReader> create(PulsarClient client,
ConsumerConfigurationData<byte[]> consumerConfiguration,
boolean createTopicIfDoesNotExist) {
CompletableFuture<Consumer<byte[]>> future = new CompletableFuture<>();
RawReader r = new RawReaderImpl((PulsarClientImpl) client,
consumerConfiguration, future, createTopicIfDoesNotExist);
return future.thenApply(__ -> r);
}


/**
* Get the topic for the reader.
*
Expand Down
Expand Up @@ -65,6 +65,14 @@ public RawReaderImpl(PulsarClientImpl client, String topic, String subscription,
consumer = new RawConsumerImpl(client, consumerConfiguration, consumerFuture, createTopicIfDoesNotExist);
}

public RawReaderImpl(PulsarClientImpl client, ConsumerConfigurationData<byte[]> consumerConfiguration,
CompletableFuture<Consumer<byte[]>> consumerFuture,
boolean createTopicIfDoesNotExist) {
this.consumerConfiguration = consumerConfiguration;
consumer = new RawConsumerImpl(client, consumerConfiguration, consumerFuture, createTopicIfDoesNotExist);
}


@Override
public String getTopic() {
return consumerConfiguration.getTopicNames().stream()
Expand Down