Skip to content

Conversation

@Denovo1998
Copy link
Contributor

PIP: #23143

This is a native implementation of the request-reply model in pulsar.

Although at present, there is no support from many people in the email discussion. But I think things still have to have a result.

I am sorry that I am just a personal developer. I have not done pulsar-related work in the company, and I have no business scenarios to test. The implementation code is as follows, if you are interested in this request-reply synchronization model, or if you have the usage scenario of this function. Can help with internal testing.

This is just a simple implementation, there are many exception handling or the metrics is not perfect. You are still welcome to discuss your questions on the mailing list or pr.

Motivation

As we known,Pulsar's current asynchronous publish-subscribe model serves well for decoupled message distribution, but it lacks a native mechanism for handling synchronous interactions typical of Remote Procedure Calls (RPC).

This request-reply model can greatly enhance the utility of Pulsar. We can then use Pulsar as RPC.

Why would we use Pulsar for this RPC call?

  • This proposal to achieve the function is request. Request and existing send function of pulsar can be mixed to same topic. This means that the user can choose, and the call to the server side (consumer) can be asynchronous or synchronous, which is controlled by the user flexibly.
  • Similar enhancements can be implemented in pulsar-spring, just like rocketmq-spring#209. However, this proposal does not use the solution of storing the request and reply result topics. After the consumer processing request is message, the processing result is directly sent to the broker and finally passed to the original producer. This call of link has one less message publishing and subscription of reply result, and its performance is higher than that of other request-reply models.
  • You can directly use Pulsar's own delaying messages, that is, you can execute RPC regularly.
  • You can directly use Pulsar's own load balancing mechanism.
  • You can directly use Pulsar's own message consumption throttling mechanism.
  • You can directly use Pulsar's own expansion and contraction mechanism.
  • You can directly use Pulsar's own message call tracking, monitoring, and logging mechanisms.

Modifications

Please read the https://github.com/apache/pulsar/pull/23143/files.

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@github-actions
Copy link

@Denovo1998 Please add the following content to your PR description and select a checkbox:

- [ ] `doc` <!-- Your PR contains doc changes -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->

@Denovo1998
Copy link
Contributor Author

@lhotari Help close this PR thanks.

@thetumbled
Copy link
Member

Welcomed to the Apache Pulsar community and contributing to Apache Pulsar.

@thetumbled thetumbled closed this Aug 19, 2024
liangyepianzhou pushed a commit to apache/pulsar-java-contrib that referenced this pull request Dec 6, 2024
…ulsar client (#6)

**Feedback is not positive due to PIP-371.**
apache/pulsar#23143
apache/pulsar#23194

**We need to implement this distributed RPC framework in a way that does not intrude into the pulsar core library. Therefore, we need to use two topics, one is the request topic and the other is the reply topic. The client side sends RPC requests to the request topic, the server side receives request message and performs customized processing, and finally sends them to the reply topic. The client receives the reply message and returns.**

### Motivation

<!-- Explain here the context, and why you're making that change. What is the problem you're trying to solve. -->
As we known,Pulsar's current **asynchronous** publish-subscribe model serves well for decoupled message distribution, but it lacks a native mechanism for handling **synchronous** interactions typical of Remote Procedure Calls (RPC).

This request-reply model can greatly enhance the utility of Pulsar. We can then use Pulsar as RPC.

Why would we use Pulsar for this RPC call?

- **Implement RPC using Apache Pulsar. Requests can be sent through a client, received by one or more servers and processed in parallel. Finally, the server returns all processing results after processing, and the client can perform summary and other operations after receiving them.**
- **This proposal to achieve the function is `request`. `Request` and existing send function of pulsar can be mixed to same topic. This means that the user can choose, and the call to the server side (consumer) can be asynchronous or synchronous, which is controlled by the user flexibly.**
- You can directly use Pulsar's own delaying messages, that is, you can execute RPC regularly.
- You can directly use Pulsar's own load balancing mechanism.
- You can directly use Pulsar's own message consumption throttling mechanism.
- You can directly use Pulsar's own expansion and contraction mechanism.
- You can directly use Pulsar's own message call tracking, monitoring, and logging mechanisms.

### Modifications

![RPC.drawio](https://github.com/user-attachments/assets/91208b7b-7f65-4a22-8bfb-fc3161e4ec18)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants