spring-pulsar icon indicating copy to clipboard operation
spring-pulsar copied to clipboard

Consider adding support for TableView

Open onobc opened this issue 2 years ago • 3 comments

Explore the TableView API and consider adding support for it.

It may be that it is simple enough as it is and there is not much to add/enhance.

onobc avatar Nov 23 '23 04:11 onobc

One could expose a TableView as a bean as such:

@Bean
TableView<User> userTableView(PulsarClient pulsarClient) {
  try {
    return pulsarClient
	    .newTableView(Schema.AVRO(User.class))
	    .topic("persistent://public/default/user")
	    .autoUpdatePartitionsInterval(10, TimeUnit.SECONDS)
	    .create();
  }
  catch (PulsarClientException e) {
    throw new RuntimeException(e);
  }
}

A TableViewFactory like Consumer-and-Producer-Factory could be provided to facilitate in creating TableViews:

pulsarTableViewFactory.createTableView("persistent://public/default/user", Schema.AVRO(User.class));

The TableViewFactory could internally rely on Customizers and let them be overridden if specific Customizers are passed in the createTableView method.

jonas-grgt avatar Feb 07 '24 14:02 jonas-grgt

That sounds like a good approach @jonasgeiregat

onobc avatar Feb 07 '24 16:02 onobc

Contemplated on this a bit more and came up with another design in the line of @PulsarMessage

@PulsarTableView(topic = "${topic.name}", ...)
class CustomType {
}

This would expose a pulsar TableView<CustomType> as a bean.

jonas-grgt avatar Feb 11 '24 21:02 jonas-grgt