apache / apache/eventmesh

[Enhancement] Not yet make full use of Polymorphism in Producer and AbstractProducer.

Open
#3,861 1 comment 1 reaction 0 assignees View on GitHub
enhancement Stale
Dominant language
Java
Stars
1.8k
Forks
658
Avg merge
11h 29m
Merged PRs (30d)
52

Description

### Search before asking

- [X] I had searched in the [issues](https://github.com/apache/eventmesh/issues?q=is%3Aissue) and found no similar issues.

### Enhancement Request

* In storage modules of knative, rocketmq, pulsar, kafka, the model of `Producer`'s hierarchy is not unified and confused: 3 `AbstractProducer`s in module knative, rocketmq, pulsar have some similar contents, but some implement `Producer` and some not. Even `AbstractProducer` in kafka is not been designed into `Producer`'s hierarchy.
* `InterruptedException` should never be ignored. Or the import interrupted state of Thread may be ignored unexpected.
* Some logic has been provided by existing util, so no need to code again.
* Smaller `synchronized` scope, lower the thread competitiveness
* In AtomicXxx, `set()` is thread safe and better than CAS when no need to get a return value.

### Describe the solution you'd like

* Unify the model of `Producer`'s hierarchy: Rename 3 `AbstractProducer` in module knative, rocketmq to `KnativeAbstractProducer, RocketmqAbstractProducer`. Add a `AbstractProducer` in api module implements `Producer`. Make `AbstractProducer`s in module knative, kafka, rocketmq, pulsar all extends `AbstractProducer` in api module or its sub abstract class. Remove `AbstractProducer` in module pulsar.
* Catch `InterruptedException` and call `interrupt()` of current Thread.
* Use existing util.
* Minimize `synchronized` scope.
* Use `set` replace CAS where no need get a return value.

### Are you willing to submit PR?

- [X] Yes I am willing to submit a PR!

Contributor guide

Open the contributing guide

Research direction

Start by comparing the Producer and AbstractProducer hierarchies in the api, knative, rocketmq, pulsar, and kafka storage modules. Trace the existing interruption handling, utility usage, synchronization, and AtomicXxx updates before deciding how the shared hierarchy should be structured. Done means the producer hierarchy is unified, interrupted state is preserved, and the listed concurrency cleanups are applied consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, distributed-systems
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.