Author: davsclaus
Date: Sun Mar 18 08:30:31 2012
New Revision: 1302093
URL: http://svn.apache.org/viewvc?rev=1302093&view=rev
Log:
CAMEL-5091: Do not enlist producer cache in JMX for EIPs, its internal details
only. And will just clutter up the JMX tree if having many routes.
Removed:
camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedProducerCacheHitsTest.java
camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedProducerCacheTest.java
camel/trunk/camel-core/src/test/java/org/apache/camel/management/RecipientListProducerCacheLimitTest.java
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientList.java
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java
camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRouteAddRemoveTest.java
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientList.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientList.java?rev=1302093&r1=1302092&r2=1302093&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientList.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientList.java
Sun Mar 18 08:30:31 2012
@@ -162,8 +162,6 @@ public class RecipientList extends Servi
protected void doStart() throws Exception {
if (producerCache == null) {
producerCache = new ProducerCache(this, camelContext);
- // add it as a service so we can manage it
- camelContext.addService(producerCache);
}
ServiceHelper.startService(producerCache);
}
@@ -173,8 +171,6 @@ public class RecipientList extends Servi
}
protected void doShutdown() throws Exception {
- // remove producer cache from service
- camelContext.removeService(producerCache);
ServiceHelper.stopAndShutdownService(producerCache);
}
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientListProcessor.java?rev=1302093&r1=1302092&r2=1302093&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RecipientListProcessor.java
Sun Mar 18 08:30:31 2012
@@ -223,8 +223,6 @@ public class RecipientListProcessor exte
super.doStart();
if (producerCache == null) {
producerCache = new ProducerCache(this, getCamelContext());
- // add it as a service so we can manage it
- getCamelContext().addService(producerCache);
}
ServiceHelper.startService(producerCache);
}
@@ -235,8 +233,6 @@ public class RecipientListProcessor exte
}
protected void doShutdown() throws Exception {
- // remove producer cache from service
- getCamelContext().removeService(producerCache);
ServiceHelper.stopAndShutdownService(producerCache);
super.doShutdown();
}
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java?rev=1302093&r1=1302092&r2=1302093&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java
Sun Mar 18 08:30:31 2012
@@ -358,8 +358,6 @@ public class RoutingSlip extends Service
protected void doStart() throws Exception {
if (producerCache == null) {
producerCache = new ProducerCache(this, camelContext);
- // add it as a service so we can manage it
- camelContext.addService(producerCache);
}
ServiceHelper.startService(producerCache);
}
@@ -369,8 +367,6 @@ public class RoutingSlip extends Service
}
protected void doShutdown() throws Exception {
- // remove producer cache from service
- camelContext.removeService(producerCache);
ServiceHelper.stopAndShutdownService(producerCache);
}
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java?rev=1302093&r1=1302092&r2=1302093&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java
Sun Mar 18 08:30:31 2012
@@ -66,6 +66,10 @@ public class SendProcessor extends Servi
public void setDestination(Endpoint destination) {
this.destination = destination;
+ // destination changed so purge the cache
+ if (producerCache != null) {
+ producerCache.purge();
+ }
}
public String getTraceLabel() {
@@ -143,9 +147,9 @@ public class SendProcessor extends Servi
protected void doStart() throws Exception {
if (producerCache == null) {
- producerCache = new ProducerCache(this, camelContext);
- // add it as a service so we can manage it
- camelContext.addService(producerCache);
+ // use a single producer cache as we need to only hold reference
for one destination
+ producerCache = new ProducerCache(this, camelContext, 1);
+ // do not add as service as we do not want to manage the producer
cache
}
ServiceHelper.startService(producerCache);
@@ -169,8 +173,6 @@ public class SendProcessor extends Servi
}
protected void doShutdown() throws Exception {
- // remove producer cache from service
- camelContext.removeService(producerCache);
ServiceHelper.stopAndShutdownService(producerCache);
}
}
Modified:
camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRouteAddRemoveTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRouteAddRemoveTest.java?rev=1302093&r1=1302092&r2=1302093&view=diff
==============================================================================
---
camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRouteAddRemoveTest.java
(original)
+++
camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedRouteAddRemoveTest.java
Sun Mar 18 08:30:31 2012
@@ -49,11 +49,11 @@ public class ManagedRouteAddRemoveTest e
result.assertIsSatisfied();
MBeanServer mbeanServer = getMBeanServer();
- ObjectName on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,name=ProducerCache*");
+ ObjectName on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,*");
- // number of producer caches
+ // number of services
Set<ObjectName> names = mbeanServer.queryNames(on, null);
- assertEquals(1, names.size());
+ assertEquals(7, names.size());
log.info("Adding 2nd route");
@@ -71,9 +71,9 @@ public class ManagedRouteAddRemoveTest e
template.sendBody("direct:bar", "Hello World");
bar.assertIsSatisfied();
- // there should be one more producer cache
+ // there should still be the same number of services
names = mbeanServer.queryNames(on, null);
- assertEquals(2, names.size());
+ assertEquals(7, names.size());
log.info("Removing 2nd route");
@@ -82,10 +82,9 @@ public class ManagedRouteAddRemoveTest e
boolean removed = context.removeRoute("bar");
assertTrue(removed);
- // the producer cache should have been removed
- on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,name=ProducerCache*");
+ // there should still be the same number of services
names = mbeanServer.queryNames(on, null);
- assertEquals(1, names.size());
+ assertEquals(7, names.size());
log.info("Shutting down...");
}
@@ -97,11 +96,11 @@ public class ManagedRouteAddRemoveTest e
result.assertIsSatisfied();
MBeanServer mbeanServer = getMBeanServer();
- ObjectName on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,name=ProducerCache*");
+ ObjectName on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,*");
- // number of producer caches
+ // number of services
Set<ObjectName> names = mbeanServer.queryNames(on, null);
- assertEquals(1, names.size());
+ assertEquals(7, names.size());
log.info("Adding 2nd route");
@@ -119,9 +118,9 @@ public class ManagedRouteAddRemoveTest e
template.sendBodyAndHeader("direct:bar", "Hello World", "bar",
"mock:bar");
bar.assertIsSatisfied();
- // there should be one more producer cache
+ // there should still be the same number of services
names = mbeanServer.queryNames(on, null);
- assertEquals(2, names.size());
+ assertEquals(7, names.size());
log.info("Removing 2nd route");
@@ -130,10 +129,9 @@ public class ManagedRouteAddRemoveTest e
boolean removed = context.removeRoute("bar");
assertTrue(removed);
- // the producer cache should have been removed
- on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,name=ProducerCache*");
+ // there should still be the same number of services
names = mbeanServer.queryNames(on, null);
- assertEquals(1, names.size());
+ assertEquals(7, names.size());
log.info("Shutting down...");
}
@@ -145,11 +143,11 @@ public class ManagedRouteAddRemoveTest e
result.assertIsSatisfied();
MBeanServer mbeanServer = getMBeanServer();
- ObjectName on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,name=ProducerCache*");
+ ObjectName on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,*");
- // number of producer caches
+ // number of services
Set<ObjectName> names = mbeanServer.queryNames(on, null);
- assertEquals(1, names.size());
+ assertEquals(7, names.size());
log.info("Adding 2nd route");
@@ -167,9 +165,9 @@ public class ManagedRouteAddRemoveTest e
template.sendBodyAndHeader("direct:bar", "Hello World", "bar",
"mock:bar");
bar.assertIsSatisfied();
- // there should be one more producer cache
+ // there should still be the same number of services
names = mbeanServer.queryNames(on, null);
- assertEquals(2, names.size());
+ assertEquals(7, names.size());
log.info("Removing 2nd route");
@@ -178,10 +176,9 @@ public class ManagedRouteAddRemoveTest e
boolean removed = context.removeRoute("bar");
assertTrue(removed);
- // the producer cache should have been removed
- on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,name=ProducerCache*");
+ // there should still be the same number of services
names = mbeanServer.queryNames(on, null);
- assertEquals(1, names.size());
+ assertEquals(7, names.size());
log.info("Shutting down...");
}
@@ -193,11 +190,11 @@ public class ManagedRouteAddRemoveTest e
result.assertIsSatisfied();
MBeanServer mbeanServer = getMBeanServer();
- ObjectName on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,name=ProducerCache*");
+ ObjectName on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,*");
- // number of producer caches
+ // number of services
Set<ObjectName> names = mbeanServer.queryNames(on, null);
- assertEquals(1, names.size());
+ assertEquals(7, names.size());
log.info("Adding 2nd route");
@@ -225,9 +222,9 @@ public class ManagedRouteAddRemoveTest e
assertMockEndpointsSatisfied();
- // there should be two more producer cache
+ // there should still be the same number of services
names = mbeanServer.queryNames(on, null);
- assertEquals(3, names.size());
+ assertEquals(7, names.size());
// now stop and remove the 2nd route
log.info("Stopping 2nd route");
@@ -237,10 +234,9 @@ public class ManagedRouteAddRemoveTest e
boolean removed = context.removeRoute("bar");
assertTrue(removed);
- // the producer cache should have been removed
- on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,name=ProducerCache*");
+ // there should still be the same number of services
names = mbeanServer.queryNames(on, null);
- assertEquals(1, names.size());
+ assertEquals(7, names.size());
log.info("Shutting down...");
}
@@ -252,11 +248,11 @@ public class ManagedRouteAddRemoveTest e
result.assertIsSatisfied();
MBeanServer mbeanServer = getMBeanServer();
- ObjectName on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,name=ProducerCache*");
+ ObjectName on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,*");
- // number of producer caches
+ // number of services
Set<ObjectName> names = mbeanServer.queryNames(on, null);
- assertEquals(1, names.size());
+ assertEquals(7, names.size());
log.info("Adding 2nd route");
@@ -285,9 +281,9 @@ public class ManagedRouteAddRemoveTest e
assertMockEndpointsSatisfied();
- // there should be two more producer cache
+ // there should still be the same number of services
names = mbeanServer.queryNames(on, null);
- assertEquals(3, names.size());
+ assertEquals(7, names.size());
// now stop and remove the 2nd route
log.info("Stopping 2nd route");
@@ -297,10 +293,9 @@ public class ManagedRouteAddRemoveTest e
boolean removed = context.removeRoute("bar");
assertTrue(removed);
- // only the producer cache from the 2nd route should have been removed
(the on exception becomes context scoped)
- on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,name=ProducerCache*");
+ // there should still be the same number of services
names = mbeanServer.queryNames(on, null);
- assertEquals(2, names.size());
+ assertEquals(7, names.size());
log.info("Shutting down...");
}
@@ -312,11 +307,11 @@ public class ManagedRouteAddRemoveTest e
result.assertIsSatisfied();
MBeanServer mbeanServer = getMBeanServer();
- ObjectName on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,name=ProducerCache*");
+ ObjectName on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,*");
- // number of producer caches
+ // number of services
Set<ObjectName> names = mbeanServer.queryNames(on, null);
- assertEquals(1, names.size());
+ assertEquals(7, names.size());
log.info("Adding 2nd route");
@@ -343,9 +338,9 @@ public class ManagedRouteAddRemoveTest e
assertMockEndpointsSatisfied();
- // there should be two more producer cache
+ // there should still be the same number of services
names = mbeanServer.queryNames(on, null);
- assertEquals(3, names.size());
+ assertEquals(7, names.size());
// now stop and remove the 2nd route
log.info("Stopping 2nd route");
@@ -355,10 +350,9 @@ public class ManagedRouteAddRemoveTest e
boolean removed = context.removeRoute("bar");
assertTrue(removed);
- // the producer cache should have been removed
- on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,name=ProducerCache*");
+ // there should still be the same number of services
names = mbeanServer.queryNames(on, null);
- assertEquals(1, names.size());
+ assertEquals(7, names.size());
log.info("Shutting down...");
}
@@ -370,11 +364,11 @@ public class ManagedRouteAddRemoveTest e
result.assertIsSatisfied();
MBeanServer mbeanServer = getMBeanServer();
- ObjectName on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,name=ProducerCache*");
+ ObjectName on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,*");
- // number of producer caches
+ // number of services
Set<ObjectName> names = mbeanServer.queryNames(on, null);
- assertEquals(1, names.size());
+ assertEquals(7, names.size());
log.info("Adding 2nd route");
@@ -402,9 +396,9 @@ public class ManagedRouteAddRemoveTest e
assertMockEndpointsSatisfied();
- // there should be two more producer cache
+ // there should still be the same number of services
names = mbeanServer.queryNames(on, null);
- assertEquals(3, names.size());
+ assertEquals(7, names.size());
// now stop and remove the 2nd route
log.info("Stopping 2nd route");
@@ -414,10 +408,9 @@ public class ManagedRouteAddRemoveTest e
boolean removed = context.removeRoute("bar");
assertTrue(removed);
- // only the producer cache from the 2nd route should have been removed
(the on completion is context scoped)
- on =
ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=services,name=ProducerCache*");
+ // there should still be the same number of services
names = mbeanServer.queryNames(on, null);
- assertEquals(2, names.size());
+ assertEquals(7, names.size());
log.info("Shutting down...");
}