You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/10/29 09:14:02 UTC
[3/3] git commit: CAMEL-7981: JMX - Routes with transacted does not
enlist processor mbeans
CAMEL-7981: JMX - Routes with transacted does not enlist processor mbeans
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8578b3fd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8578b3fd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8578b3fd
Branch: refs/heads/camel-2.13.x
Commit: 8578b3fdf50c88384c375d2264dabf8b0d7fd52c
Parents: 8439eca
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Oct 29 08:28:45 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Oct 29 09:13:46 2014 +0100
----------------------------------------------------------------------
.../camel/processor/RedeliveryErrorHandler.java | 20 ++++++-
.../org/apache/camel/util/ServiceHelper.java | 2 +-
.../SpringManagedTransactedProcessorTest.java | 57 ++++++++++++++++++++
.../SpringManagedTransactedProcessorTest.xml | 45 ++++++++++++++++
4 files changed, 122 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/8578b3fd/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java b/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
index b1a5030..beb2b5e 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.processor;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
@@ -27,6 +29,7 @@ import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.LoggingLevel;
import org.apache.camel.Message;
+import org.apache.camel.Navigate;
import org.apache.camel.Predicate;
import org.apache.camel.Processor;
import org.apache.camel.model.OnExceptionDefinition;
@@ -53,7 +56,7 @@ import org.apache.camel.util.ServiceHelper;
*
* @version
*/
-public abstract class RedeliveryErrorHandler extends ErrorHandlerSupport implements AsyncProcessor, ShutdownPrepared {
+public abstract class RedeliveryErrorHandler extends ErrorHandlerSupport implements AsyncProcessor, ShutdownPrepared, Navigate<Processor> {
protected ScheduledExecutorService executorService;
protected final CamelContext camelContext;
@@ -209,6 +212,21 @@ public abstract class RedeliveryErrorHandler extends ErrorHandlerSupport impleme
return false;
}
+ @Override
+ public boolean hasNext() {
+ return output != null;
+ }
+
+ @Override
+ public List<Processor> next() {
+ if (!hasNext()) {
+ return null;
+ }
+ List<Processor> answer = new ArrayList<Processor>(1);
+ answer.add(output);
+ return answer;
+ }
+
protected boolean isRunAllowed(RedeliveryData data) {
// if camel context is forcing a shutdown then do not allow running
boolean forceShutdown = camelContext.getShutdownStrategy().forceShutdown(this);
http://git-wip-us.apache.org/repos/asf/camel/blob/8578b3fd/camel-core/src/main/java/org/apache/camel/util/ServiceHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/ServiceHelper.java b/camel-core/src/main/java/org/apache/camel/util/ServiceHelper.java
index 7e261d6..0a7df51 100644
--- a/camel-core/src/main/java/org/apache/camel/util/ServiceHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/ServiceHelper.java
@@ -449,7 +449,7 @@ public final class ServiceHelper {
/**
* Gathers all child services by navigating the service to recursively gather all child services.
* <p/>
- * The returned set does <b>not</b> include the childern being error handler.
+ * The returned set does <b>not</b> include the children being error handler.
*
* @param service the service
* @return the services, including the parent service, and all its children
http://git-wip-us.apache.org/repos/asf/camel/blob/8578b3fd/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedTransactedProcessorTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedTransactedProcessorTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedTransactedProcessorTest.java
new file mode 100644
index 0000000..c32383d
--- /dev/null
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedTransactedProcessorTest.java
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.management;
+
+import java.util.Set;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ *
+ */
+public class SpringManagedTransactedProcessorTest extends SpringTestSupport {
+
+ @Override
+ protected AbstractXmlApplicationContext createApplicationContext() {
+ return new ClassPathXmlApplicationContext("org/apache/camel/spring/management/SpringManagedTransactedProcessorTest.xml");
+ }
+
+ protected MBeanServer getMBeanServer() {
+ return context.getManagementStrategy().getManagementAgent().getMBeanServer();
+ }
+
+ public void testTransacted() throws Exception {
+ getMockEndpoint("mock:foo").expectedMessageCount(1);
+ getMockEndpoint("mock:bar").expectedMessageCount(1);
+
+ template.sendBody("seda:foo", "Hello World");
+ template.sendBody("seda:bar", "Bye World");
+
+ assertMockEndpointsSatisfied();
+
+ MBeanServer mbeanServer = getMBeanServer();
+
+ // there should be 4 processors
+ Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=processors,*"), null);
+ // there should only be 2 error handler types as route 1 and route 3 uses the same default error handler
+ assertEquals(4, set.size());
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/8578b3fd/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringManagedTransactedProcessorTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringManagedTransactedProcessorTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringManagedTransactedProcessorTest.xml
new file mode 100644
index 0000000..87b0457
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringManagedTransactedProcessorTest.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+ ">
+
+ <!-- require a spring transaction manager so that transacted DSL can find and use it -->
+ <import resource="../../spring/interceptor/transactionalClientDataSource.xml" />
+
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+ <jmxAgent id="agent"/>
+
+ <route id="foo">
+ <from uri="seda:foo"/>
+ <to uri="log:foo" id="foo1"/>
+ <to uri="mock:foo" id="foo2"/>
+ </route>
+
+ <route id="bar">
+ <from uri="seda:bar"/>
+ <transacted/>
+ <to uri="log:bar" id="bar1"/>
+ <to uri="mock:bar" id="bar2"/>
+ </route>
+ </camelContext>
+
+</beans>