You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Tony Su <to...@yahoo.com> on 2012/02/03 21:59:50 UTC

Problem Removing Endpoints

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:

       removing EP: jmsvm://topic:CORE_REQUEST_USRMGM
       EP not removed: jmsvm://topic:CORE_REQUEST_USRMGM
       removing EP: jmsvm://topic:CORE_ADD_USRMGM
       EP not removed: jmsvm://topic:CORE_ADD_USRMGM


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

TIA



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

Re: Problem Removing Endpoints

Posted by Tony Su <to...@yahoo.com>.
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.

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

Re: Problem Removing Endpoints

Posted by Hadrian Zbarcea <hz...@gmail.com>.
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/

Re: Problem Removing Endpoints

Posted by Tony Su <to...@yahoo.com>.
Thanks!   I just noticed that you fixed the issue.

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

Re: Problem Removing Endpoints

Posted by Hadrian Zbarcea <hz...@gmail.com>.
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/

Re: Problem Removing Endpoints

Posted by Tony Su <to...@yahoo.com>.
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.

Re: Problem Removing Endpoints

Posted by Tony Su <to...@yahoo.com>.
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()" ... 

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

Re: Problem Removing Endpoints

Posted by Babak Vahdat <ba...@swissonline.ch>.
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

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