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

two consumer beans are created. #3618

Open
beiwei30 opened this issue Mar 8, 2019 · 0 comments
Open

two consumer beans are created. #3618

beiwei30 opened this issue Mar 8, 2019 · 0 comments
Assignees

Comments

@beiwei30
Copy link
Member

beiwei30 commented Mar 8, 2019

Hi,
Every one.
I use dubbo spring-boot with

<dependency>
    <groupId>com.alibaba.boot</groupId>
    <artifactId>dubbo-spring-boot-starter</artifactId>
    <version>0.2.0</version>
</dependency>

And in order to decouple with dubbo .
I do not use @service (com.alibaba.dubbo.config.annotation.Service) annotation on my serviceImpl class , but add @component annotation to them.
Then I config the service and refrence in another two xml file as

<dubbo:service interface="com.ecms.ecframe.auth.service.EcAuthMenuI18nService" ref="ecAuthMenuI18nServiceImpl" version="0.5.0" protocol="dubbo" timeout="5000"></dubbo:service>    

<dubbo:reference xmlns="" interface="com.ecms.ecframe.auth.service.EcAuthMenuI18nService" version="0.5.0" id="ecAuthMenuI18n"></dubbo:reference>  

to regist the bean to zookeeper as a service.
Finally I use

@ImportResource(locations = {"classpath:META-INF/dubbo/provider.xml"}) 

on the bootstrap class of my springboot application.
Then it works.

But when I config the consumer , a problem happened.
In my application.properties I set a property as
dubbo.consumer.check=false
to skip the exist check of provider
and I need a filter to do some work before a RPC request send,so I configed a filter on my xml file

<dubbo:consumer filter="UserConsumerFilter"/>

when the application start

2019-03-07 15:23:14.672  WARN 4116 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException:  Error creating bean with name 'ecAuthMenuI18n': Invocation of init method failed; nested exception is java.lang.IllegalStateException:  Duplicate consumer configs: <dubbo:consumer generic="false" filter="UserConsumerFilter" id="com.alibaba.dubbo.config.ConsumerConfig" /> and <dubbo:consumer generic="false" />

I think the first tag is from the xml and the secod tag is from the application.properties.

then I try to add a id parameter on my xml file like

<dubbo:consumer filter="UserConsumerFilter" id="aaa"/>

the warn info is :

2019-03-07 16:56:32.498  WARN 6504 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException:  Error creating bean with name 'ecAuthMenuI18n': Invocation of init method failed; nested exception is java.lang.IllegalStateException:  Duplicate consumer configs: <dubbo:consumer generic="false" filter="UserConsumerFilter" id="aaa" /> and <dubbo:consumer generic="false" />

So I think dubbo can only config one <dubbo:consumer > in a context.

Can we consider to imporve this in the future ?

我们在使用dubbo的过程中,希望可以很容易的在rpc模式和本地模式之间切换,所以并没有使用dubbo的@service注解和@refrence注解。而是使用@component注解将service的实现类注册到spring
再用额外的xml分别定义dubbo的service和refrence

<dubbo:service interface="com.ecms.ecframe.auth.service.EcAuthMenuI18nService" ref="ecAuthMenuI18nServiceImpl" version="0.5.0" protocol="dubbo" timeout="5000"></dubbo:service>    

<dubbo:reference xmlns="" interface="com.ecms.ecframe.auth.service.EcAuthMenuI18nService" version="0.5.0" id="ecAuthMenuI18n"></dubbo:reference>  

在springboot的启动类中分别引入consumer和provider的xml配置。
现在我需要在consumer端加一个filter,于是,我在xml中增加了

<dubbo:consumer filter="UserConsumerFilter"/>

由于原来在application.properties中指定了
dubbo.consumer.check=false

启动报错:

2019-03-07 15:23:14.672  WARN 4116 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException:  Error creating bean with name 'ecAuthMenuI18n': Invocation of init method failed; nested exception is java.lang.IllegalStateException:  Duplicate consumer configs: <dubbo:consumer generic="false" filter="UserConsumerFilter" id="com.alibaba.dubbo.config.ConsumerConfig" /> and <dubbo:consumer generic="false" />

xml中的标签加了个id

<dubbo:consumer filter="UserConsumerFilter" id="aaa"/>

报错:

2019-03-07 16:56:32.498  WARN 6504 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.BeanCreationException:  Error creating bean with name 'ecAuthMenuI18n': Invocation of init method failed; nested exception is java.lang.IllegalStateException:  Duplicate consumer configs: <dubbo:consumer generic="false" filter="UserConsumerFilter" id="aaa" /> and <dubbo:consumer generic="false" />

我想这个是由于dubbo只能接受一个<dubbo:consumer />配置的原因吗?
这个是否能够作为一个issue提出来,后续加以改进呢?

谢谢。

@mercyblitz mercyblitz self-assigned this Mar 8, 2019
@mercyblitz mercyblitz added this to the 2.6.7 milestone Mar 8, 2019
@mercyblitz mercyblitz removed this from the 2.6.7 milestone Jul 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants