Skip to content

Support per partition MessageReceiver #471

@gpoulin

Description

@gpoulin

Is your feature request related to a problem? Please describe.
There's currently no easy way to know from which partition a message come from while using the Subscriber interface. This prevent to implement more complex control flow on a per partition basis. e.g.: We might want to stop processing new messages if there's a single outstanding message with an offset smaller than current offset minus X. In addition, there's no way to determine a unique id as only the offset is available. Ideally the publisher should include an id as an attribute, but there's use case where distinguishing between a message that have been publish more than once vs a message that have been deliver more than once can be useful.

Describe the solution you'd like
Modify SubcriberSettings.Builder to add the method setReceiverFactory(ApiFunction<Partition, MessageReceiver> receiverFactory). The method setReceiver(MessageReceiver receiver) should simply call this method, ignoring the Partition parameter.

Describe alternatives you've considered

Using AssigningSubscriber by giving PartitionSubscriberFactory that simply build a Subscriber from a SubcriberSettings where partitions have been set to a list of one element. Those are in the com.google.cloud.pubsublite.cloudpubsub.internal so it doesn't seem to be something that should be used outside the library.

Metadata

Metadata

Labels

api: pubsubliteIssues related to the googleapis/java-pubsublite API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions