apache camel removeEndpoints

用户TonySu在使用Apache Camel动态配置Endpoint时遇到问题,无法完全移除某些类型的Endpoint,如jms:topic。社区成员协助定位了Camel Context中removeEndpoints方法的问题,并提供了修复。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Problem Removing Endpoints

classicClassiclistListthreadedThreaded
7 messages  Options  Options 
Reply |  Threaded |  More       star

Problem Removing Endpoints

Tony Su
6 posts
This post was updated on  Feb 04, 2012; 5:50am.
I'm attempting to manage routes and endpoints in a camel context using following components (Camel 2.9.0, CXF 2.5.1, AMQ 5.5.1 in karaf 2.2.5).  I have a system that requires that the endpoints be dynamically reconfigured, and this requires that I be able to add/remove routes and endpoints.   

I am able to remove routes from my camel context, but I'm not able to remove all the endpoints.  The endpoints are a combination of the following: 

  1-  jms:queue:jmsQueueEP 
  2 - jms:topic:jmsTopicEP 
  3 - seda:sedaEP 
  4 - CxfEndpoint 

1 - 3 are added to the context during route creation using RouteBuilder.  4 is explicitly added to the context. 

Performing a camelContext.removeEndpoints("*") removes most of the lazy created endpoints.  It removes (1) and (3). 

Performing an explicit removal of (4) - camelContext.removeEndpoints("cxf: https://foo...") is then able to remove the CxfEndpoint.  I'm not sure why the wildcard pattern initially used did not work here. 

Finally, even an explicit attempt to remove the jms topic endpoint was not successful: 

                Collection<Endpoint> removed, 
                      endpoints = camelContext.getEndpoints(); 
                
                for (Endpoint i : endpoints) 
                { 
                        String uri = i.getEndpointUri(); 
                        logger.debug("removing EP: {}", uri); 
                        removed = camelContext.removeEndpoints(i.getEndpointUri()); 
                        if (removed == null) 
                        { 
                                logger.debug("EP not removed: {}", uri); 
                        } 
                } 

Output is: 
       removing EP: jmsvm://topic:CORE_REQUEST_USRMGM 
       removing EP: jmsvm://topic:CORE_ADD_USRMGM 

This indicates that removeEndpoints should have succeeded, but an examination of the context indicates that the endpoint is still present.  Using context.AddRoutes() to add routes with the same endpoints results in duplicate endpoints present in the context. 


Any ideas as to: 
 - Why the wildcard uri pattern fails to remove the cxf endpoint? 
 - How to remove the jms:topic endpoint? 

TIA 

Reply |  Threaded |  More       star

Re: Problem Removing Endpoints

hadrian
1074 posts
Tony, 

I am putting together a unit test to reproduce your problem. I assume 
you don't have one handy. The information you provided should be enough 
to reproduce. 

Hadrian 


On 02/03/2012 04:47 PM, Tony Su wrote:

> Found a mistake in the original post: 


> Tony Su wrote 
>> 
>> if (removed != null) 
>> { 
>> logger.debug("EP not removed: {}", uri); 
>> } 
>> 


> This should be: 
>                          if (removed != null) 
> { 
> logger.debug("EP not removed: {}", uri); 
> } 
> Output is: 
>         removing EP: jmsvm://topic:CORE_REQUEST_USRMGM 
>         removing EP: jmsvm://topic:CORE_ADD_USRMGM 

> This indicates that removeEndpoints should have succeeded, but an 
> examination of the context indicates that the endpoint is still present. 
> Using context.AddRoutes() to add routes with the same endpoints results in 
> duplicate endpoints present in the context. 

> -- 
> View this message in context:  http://camel.465427.n5.nabble.com/Problem-Removing-Endpoints-tp5455029p5455127.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

-- 
Hadrian Zbarcea 
Principal Software Architect 
Talend, Inc 
http://coders.talend.com/
http://camelbot.blogspot.com/
Reply |  Threaded |  More       star

Re: Problem Removing Endpoints

Babak Vahdat
750 posts
In reply to  this post by Tony Su
Hi 

That was a Javadoc typo as CamelContext.removeEndpoints() would never return null but just an empty Collection if no matching endpoint could be found. So in your case checking it aganist null is obsolete. 

I did correct it right before on the trunk. 

Babak
Reply |  Threaded |  More       star

Re: Problem Removing Endpoints

Tony Su
6 posts
Babak Vahdat wrote
Hi 

That was a Javadoc typo as CamelContext.removeEndpoints() would never return null but just an empty Collection if no matching endpoint could be found. So in your case checking it aganist null is obsolete. 

I did correct it right before on the trunk. 

Babak
I just realized that a little while ago while browsing the source :-) 

Changing to check for "removed.isEmpty()" ...
Reply |  Threaded |  More       star

Re: Problem Removing Endpoints

Tony Su
6 posts
In reply to  this post by hadrian
hadrian wrote
I am putting together a unit test to reproduce your problem. I assume 
you don't have one handy. The information you provided should be enough 
to reproduce.
Thanks!  I don't have a test case yet.
Reply |  Threaded |  More       star

Re: Problem Removing Endpoints

hadrian
1074 posts
In reply to  this post by Tony Su
Tony, 

I did reproduce your problem and created CAMEL-4976 [1]. I also added a 
unit test [2] that is consistent with your findings. It doesn'I am 
investigating a fix and I expect to have it committed by Monday. 

Enjoy the weekend, 
Hadrian 

[1]  https://issues.apache.org/jira/browse/CAMEL-4976
[2] 
http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/issues/RemoveEndpointsTest.java?view=markup


On 02/03/2012 04:47 PM, Tony Su wrote:

> Found a mistake in the original post: 


> Tony Su wrote 
>> 
>> if (removed != null) 
>> { 
>> logger.debug("EP not removed: {}", uri); 
>> } 
>> 


> This should be: 
>                          if (removed != null) 
> { 
> logger.debug("EP not removed: {}", uri); 
> } 
> Output is: 
>         removing EP: jmsvm://topic:CORE_REQUEST_USRMGM 
>         removing EP: jmsvm://topic:CORE_ADD_USRMGM 

> This indicates that removeEndpoints should have succeeded, but an 
> examination of the context indicates that the endpoint is still present. 
> Using context.AddRoutes() to add routes with the same endpoints results in 
> duplicate endpoints present in the context. 

> -- 
> View this message in context:  http://camel.465427.n5.nabble.com/Problem-Removing-Endpoints-tp5455029p5455127.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

-- 
Hadrian Zbarcea 
Principal Software Architect 
Talend, Inc 
http://coders.talend.com/
http://camelbot.blogspot.com/
Reply |  Threaded |  More       star

Re: Problem Removing Endpoints

Tony Su
6 posts
Thanks!   I just noticed that you fixed the issue.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值