[ISSUE #218] Fix spring scopeTarget will repeat consumer instance#210
[ISSUE #218] Fix spring scopeTarget will repeat consumer instance#210RongtongJin merged 23 commits intoapache:masterfrom
Conversation
RongtongJin
left a comment
There was a problem hiding this comment.
I think it's a good enhancement, but the implementation is a bit complex.
Firstly, it is unnecessary to expose client instance name to users in RocketMQProperties explicitly. Users can set consumer instance name in prepareStart method If he want to do that.
Secondly, why not just filter the proxy bean in afterSingletonsInstantiated method? Writing a SpringBeanUtil class make the code complex.
Finally, It would be better if you can write some unit tests.
|
|
||
| # another nameserver different global | ||
| demo.rocketmq.myNameServer=127.0.0.1:9876 No newline at end of file | ||
| demo.rocketmq.myNameServer=dev1.host.70yi.ren:9876 No newline at end of file |
There was a problem hiding this comment.
Please change back to 127.0.0.1
|
Could you open a issue first? |
|
@RongtongJin sorry busy for work , open issue late :-) |
|
issue : #218 |
|
resolve conflict with latest master |
|
@snicoll Could you help to review this pr:-) refresh could result in the two instances of the **Container created. But I feel spring has provided a similar elegant method like "SpringBeanUtil" here, we do not want to create an extra class to deal with this problem. |
|
Can do when time permits. I'd appreciate an answer here: #171 (comment) |
|
@snicoll Thank you in advance, we hope this feature can be released in version 2.1.0 in the latest week, I really appreciate your time:-) |
snicoll
left a comment
There was a problem hiding this comment.
Calling ScopedProxyUtils.isScopedTarget(beanName) is what you should be doing there. There isn't an infrastructure for such use cases as each detection logic is slightly different so it's hard to create a common API that would suits all needs.
| * @param clazz annotation class | ||
| * @return beans map without proxyTarget bean | ||
| */ | ||
| public static Map<String, Object> getBeansWithAnnotation(@NonNull ConfigurableApplicationContext applicationContext, Class<? extends Annotation> clazz) { |
There was a problem hiding this comment.
I'd rather move the check in the code that's calling it. This also prevents the creation of a util class
|
I will merge the PR first, then modify the code according to @snicoll . |
1 similar comment
|
I will merge the PR first, then modify the code according to @snicoll . |
What is the purpose of the change
change consumer listener use SpringContext getBeansWithAnnotation will get same bean with scopeTarget ,cause repeat consumer client with same clientId(IP@PID on rocketmq-client 4.6.0)
Brief changelog
fix scopeTarget bean instance same clientId
Verifying this change
use @RefreshScope on RocketMQListener , will registration is the same clientId on RocketMQ-Console consumer client (same IP@PID),will thorws error (log :
has been created before, specify another name please.) , but only on rocketmq-client version >= 4.6.0at forfuns:develop-pr branch will fixed