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

[Enhancement] Improve the performance of publish event in connector-pulsar #1636

Closed
2 tasks done
fengyongshe opened this issue Oct 18, 2022 · 1 comment
Closed
2 tasks done
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@fengyongshe
Copy link
Contributor

fengyongshe commented Oct 18, 2022

Search before asking

  • I had searched in the issues and found no similar issues.

Enhancement Request

When pulsar connector receive a produce event , will construct a new producer instance. It's in a wrong way and poor performance .

public void publish(CloudEvent cloudEvent, SendCallback sendCallback) {

     try {
         Producer<byte[]> producer = this.pulsarClient.newProducer()
                 .topic(cloudEvent.getSubject())
                 .batchingMaxPublishDelay(10, TimeUnit.MILLISECONDS)
                 .sendTimeout(10, TimeUnit.SECONDS)
                 .blockIfQueueFull(true)
                 .create();

         ......
         producer.sendAsync(serializedCloudEvent).thenAccept(messageId -> {
             sendCallback.onSuccess(CloudEventUtils.convertSendResult(cloudEvent));
         });
     }

As the code above shows , One message one Producer .

Describe the solution you'd like

  1. Construct the producer in init , and put it in the Cache(HashMap)
  2. When publish a event, get it from cache
  3. If need to create a new instance, do as the step one

Are you willing to submit PR?

  • Yes I am willing to submit a PR!
@fengyongshe fengyongshe added the enhancement New feature or request label Oct 18, 2022
@fengyongshe
Copy link
Contributor Author

@xwm1992 I'm willing to accomplish it .

fengyongshe added a commit to fengyongshe/incubator-eventmesh that referenced this issue Oct 25, 2022
Motivation
Improve the performance of publish event in connector-pulsar

Modifications
Hold the producer instance in map, create when used for the first time

Documentation
@xwm1992 xwm1992 added this to the 1.7.0 milestone Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants