GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PIP-12 Introduce builder for creating Producer Consumer Reader by merlimat · Pull Request #1089 · apache/pulsar

Conversation

@merlimat

@merlimat merlimat commented Jan 22, 2018

Copy link
Copy Markdown
Contributor

Motivation

Full context at
https://github.com/apache/incubator-pulsar/wiki/PIP-12:-Introduce-builder-for-creating-Producer-Consumer-Reader

Modifications

  • Added new builder methods

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@merlimat merlimat added the type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages label Jan 22, 2018
@merlimat merlimat added this to the 2.0.0-incubating milestone Jan 22, 2018
@merlimat merlimat self-assigned this Jan 22, 2018
@merlimat
merlimat requested review from jai1, nkurihar, rdhabalia, saandrews, sijie and yush1ga January 22, 2018 22:16
@merlimat
merlimat force-pushed the builder-api branch from 873c90a to f5ee1fe Compare January 22, 2018 22:44
@sijie

sijie commented Feb 1, 2018

Copy link
Copy Markdown
Member

/cc @zhaijack @mgodave

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sijie

sijie commented Feb 1, 2018

Copy link
Copy Markdown
Member

/cc @lucperkins

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sijie
sijie reviewed Feb 1, 2018
View reviewed changes

@sijie sijie left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the proposed api looks good me. but it seems some of the javadocs were copied from configuration based methods, we need to update the javadoc for those methods.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/api/ClientBuilder.java Outdated

@sijie sijie Feb 1, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

documentation seems need to be updated

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Feb 6, 2018

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, this was just a placeholder. I'll clean up all Javadocs when submitting final PR.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@hellostreaming

hellostreaming commented Feb 1, 2018

Copy link
Copy Markdown
Contributor

+1, LGTM, currently.
Once we have subscription for topics and pattern, we need add them in.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mgodave
mgodave approved these changes Feb 1, 2018
View reviewed changes
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/api/ProducerBuilder.java Outdated

@mgodave mgodave Feb 1, 2018

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: since this is a builder, do we want to go with the canonical 'build' terminology instead?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Feb 6, 2018

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was debating about this. My reasoning here was to differentiate the actions:

client.newProducer().topic(MY_TOPIC).create();
// versus
client.newConsumer().topic(MY_TOPIC).subscriptionName(MY_SUB).subscribe();

Subscribe here implies to create a durable Subscription on the topic, not just building an ephemeral Consumer instance.

I'm not 100% settled on this. Please anyone share opinions ;)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/api/ProducerBuilder.java Outdated

@mgodave mgodave Feb 1, 2018

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like having async and sync versions cloud things. The nature of the library is that it is async and if all we are doing is calling CompletableFuture::get and catching exceptions for the user, is it really worth it?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Feb 6, 2018

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think most users still reasons in term of "sync" API, especially for creating the producer/consumer (compared to publishing messages).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@merlimat

merlimat commented Feb 8, 2018

Copy link
Copy Markdown
Contributor Author

The other doubt here was which form would be preferred between:

Producer producer = client.newProducer().topic("my-topic").create();

versus

Producer producer = client.newProducer("my-topic").create();

This is regarding required and optional parameters.

The 2nd is a bit more concise, though that doesn't mean a lot if you're setting multiple options anyway.

Opinions with respect to this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@merlimat merlimat mentioned this pull request Feb 9, 2018
PIP-13-1/3: Provide TopicsConsumer to consume from several topics under same namespace #1103
Merged
@merlimat
merlimat force-pushed the builder-api branch from f5ee1fe to f17cac1 Compare February 14, 2018 05:55
@merlimat merlimat changed the title WIP - PIP-12 Introduce builder for creating Producer Consumer Reader PIP-12 Introduce builder for creating Producer Consumer Reader Feb 14, 2018
@merlimat

merlimat commented Feb 14, 2018

Copy link
Copy Markdown
Contributor Author

This is ready for review. Once this is finalized and merged, I'll start converting all the code to use new API.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@merlimat

merlimat commented Feb 14, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Once we have subscription for topics and pattern, we need add them in.

Yes, the idea was to have different ways to specify:

// Single topic
client.newConsumer().topic(MY_TOPIC).subscriptioName(SUB).build();

// List of topics
List<String> myList = ...;
client.newConsumer().topics(myList).subscriptioName(SUB).build();

// Regex
client.newConsumer().topicsRegex("test.*").subscriptioName(SUB).build();
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hellostreaming hellostreaming mentioned this pull request Feb 14, 2018
Make subscribe for TopicsConsumer using builder #1237
Closed
@mgodave mgodave mentioned this pull request Feb 14, 2018
Schema registry #1137
Closed
sijie
sijie approved these changes Feb 14, 2018
View reviewed changes

@sijie sijie left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the change looks good to me. some minor comments.

it is a really awesome change to move the api to builder pattern!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/api/ClientBuilder.java Outdated

@sijie sijie Feb 14, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it might be good to add "@SInCE 2.0". so we can track when we introduce the build methods.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Feb 14, 2018

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will add @since

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/api/ClientBuilder.java Outdated

@sijie sijie Feb 14, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: @Override?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Feb 14, 2018

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clone() is a bit weird in the way it's treated. It cannot be marked as @Override

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/api/ConsumerBuilder.java Outdated

@sijie sijie Feb 14, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incomplete comment?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Feb 14, 2018

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ups, forgot to finish

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/api/ConsumerBuilder.java Outdated

@sijie sijie Feb 14, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@return a consumer?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/api/ReaderConfiguration.java Outdated

@sijie sijie Feb 14, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the param field seems to be wrong?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@merlimat
merlimat requested review from maskit and sschepens February 14, 2018 17:42
maskit
maskit reviewed Feb 15, 2018
View reviewed changes
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/api/ConsumerBuilder.java Outdated

@maskit maskit Feb 15, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just an idea but we may want to pass a Topic object instead of its string representation. Then this interface would be freed to define a format of topic name string (persistent://.../.../...), and users can manage their topic names in any format.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Feb 16, 2018

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave it as a string, at least for now, because that would be a bigger change I think. We're already trying to address the long topic names by having some degree of implicitenes. See https://github.com/apache/incubator-pulsar/wiki/PIP-10:-Remove-cluster-for-namespace-and-topic-names and https://github.com/apache/incubator-pulsar/wiki/PIP-11:-Short-topic-names

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@maskit maskit Feb 17, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright. Yeah, and the change is not necessary for introducing builders.

Below is what I thought.

We should probably introduce a parser for topic name string to reduce duplicate parsing code. Otherwise PIP-10 and PIP-11 would be tough because we need to modify all parsing code here and there. If we introduce the parser, the builder implementation would be like:

public ConsumerBuilder topic(String topicName) {
  this.topic = Topic.parse(topicName);
  return this;
}

The Topic class would be like this:

class Topic {
  public Topic(String topicName) {
    // parse
    ...
    this.namespace = ....
    this.cluster = ...
    ...
  } 
  public getNamespace() {
    return this.namespace;
  }
  ...
}

Once we did this, other components that use Topic object wouldn't need to care how the object was created. And if so, it might be useful if users could create own Topic implementation and pass it to builders.

So I'm not saying we should eliminate the Pulsar topic URL format. I just thought using Topic object may increase its capability.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Feb 17, 2018

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For parsing, it's already all concentrated in the DestinationName class, which I plan to rename into TopicName. It is not exposed to users though.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
maskit
maskit reviewed Feb 15, 2018
View reviewed changes
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/api/ClientBuilder.java Outdated

@maskit maskit Feb 15, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "allowTlsInsecureConnection"?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Feb 15, 2018

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, with the builder it makes sense a more "imperative" style

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
maskit
maskit reviewed Feb 15, 2018
View reviewed changes
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/api/ClientBuilder.java Outdated

@maskit maskit Feb 15, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"TLS"? or "Tls"? Need consistency.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@merlimat merlimat Feb 15, 2018

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I'll go back back to "Tls"

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
maskit
maskit reviewed Feb 15, 2018
View reviewed changes
Comment thread pulsar-client/src/main/java/org/apache/pulsar/client/api/ProducerConfiguration.java Outdated

@maskit maskit Feb 15, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a parameter name

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@merlimat

merlimat commented Feb 16, 2018

Copy link
Copy Markdown
Contributor Author

retest this please

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

maskit
maskit approved these changes Feb 17, 2018
View reviewed changes

@maskit maskit left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@merlimat
merlimat force-pushed the builder-api branch from 585dd9b to 03dcd22 Compare February 17, 2018 17:04
merlimat added 3 commits February 17, 2018 09:04
@merlimat
PIP-12: Introduce builders for creating Producer Consumer Reader
769dcc3
@merlimat
Fixed Javadocs
5742ca8
@merlimat
Addressed comments
03dcd22
@merlimat

merlimat commented Feb 17, 2018

Copy link
Copy Markdown
Contributor Author

Rebased to fix tls test certificates issue

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@merlimat
merlimat merged commit cb5eb5b into apache:master Feb 17, 2018
@merlimat
merlimat deleted the builder-api branch February 17, 2018 20:22
This was referenced Feb 23, 2018
Refactored ClientConfuguration to use ClientConfigurationData shared with ClientBuilderImpl #1276
Merged
Converted main part of code to use builder APIs with typed interface #1311
Merged
hapihu added a commit to hapihu/pulsar that referenced this pull request Jun 5, 2019
@hapihu
Update concepts-messaging.md
464766b
Since the  apache#1089,the interface 'org.apache.pulsar.client.api.PulsarClient' has supported builder for consumer and producer.
And,int the apache#3272, some deprecated client API have been removed including 'public static PulsarClient create(String serviceUrl)','Consumer<byte[]> subscribe(String topic, String subscription)' and 'Producer<byte[]> createProducer(String topic)'.

So, I modified the example with the current version of the interface.
@hapihu hapihu mentioned this pull request Jun 5, 2019
Update concepts-messaging.md #4483
Merged
merlimat added a commit that referenced this pull request Jun 6, 2019
@hapihu @merlimat
Update concepts-messaging.md (#4483)
304843f
* Update concepts-messaging.md

Since the  #1089,the interface 'org.apache.pulsar.client.api.PulsarClient' has supported builder for consumer and producer.
And,int the #3272, some deprecated client API have been removed including 'public static PulsarClient create(String serviceUrl)','Consumer<byte[]> subscribe(String topic, String subscription)' and 'Producer<byte[]> createProducer(String topic)'.

So, I modified the example with the current version of the interface.

* Apply suggestions from code review

Specify message schema

Co-Authored-By: Matteo Merli <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@maskit maskit maskit approved these changes
@sijie sijie sijie approved these changes
@rdhabalia rdhabalia Awaiting requested review from rdhabalia
@jai1 jai1 Awaiting requested review from jai1
@saandrews saandrews Awaiting requested review from saandrews
@nkurihar nkurihar Awaiting requested review from nkurihar
@yush1ga yush1ga Awaiting requested review from yush1ga
@sschepens sschepens Awaiting requested review from sschepens
+1 more reviewer
@mgodave mgodave mgodave approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@merlimat merlimat

Labels

type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages

Projects

None yet

Milestone

2.0.0-incubating

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@merlimat @sijie @hellostreaming @maskit @mgodave
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.