camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [4/9] git commit: CAMEL-6692: JMS now also enlists topic destinations as managed endpoints in JMX
Date Sat, 31 Aug 2013 10:56:31 GMT
CAMEL-6692: JMS now also enlists topic destinations as managed endpoints in JMX


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d78ee9e5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d78ee9e5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d78ee9e5

Branch: refs/heads/camel-2.12.x
Commit: d78ee9e58d9e6a4a280b6c71733600bcc2da8a71
Parents: 2e21ec7
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sat Aug 31 12:14:39 2013 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Aug 31 12:52:48 2013 +0200

----------------------------------------------------------------------
 .../apache/camel/component/jms/JmsEndpoint.java |  6 --
 .../component/jms/ManagedJmsEndpointTest.java   |  3 +
 .../jms/ManagedJmsEndpointTopicTest.java        | 92 ++++++++++++++++++++
 3 files changed, 95 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d78ee9e5/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
index 664da7c..b3e5ab5 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
@@ -379,12 +379,6 @@ public class JmsEndpoint extends DefaultEndpoint implements HeaderFilterStrategy
 
     @ManagedAttribute
     public boolean isSingleton() {
-        if (isPubSubDomain()) {
-            // topic cannot be singleton, as there may be multiple consumers
-            // on the same topic
-            return false;
-        }
-        // but queues can be singleton
         return true;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/d78ee9e5/components/camel-jms/src/test/java/org/apache/camel/component/jms/ManagedJmsEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/ManagedJmsEndpointTest.java
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/ManagedJmsEndpointTest.java
index f3e15a0..08d82a5 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/ManagedJmsEndpointTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/ManagedJmsEndpointTest.java
@@ -66,6 +66,9 @@ public class ManagedJmsEndpointTest extends CamelTestSupport {
         Boolean singleton = (Boolean) mbeanServer.getAttribute(name, "Singleton");
         assertTrue(singleton.booleanValue());
 
+        Integer running = (Integer) mbeanServer.getAttribute(name, "RunningMessageListeners");
+        assertEquals(1, running.intValue());
+
         Long size = (Long) mbeanServer.invoke(name, "queueSize", null, null);
         assertEquals(0, size.intValue());
 

http://git-wip-us.apache.org/repos/asf/camel/blob/d78ee9e5/components/camel-jms/src/test/java/org/apache/camel/component/jms/ManagedJmsEndpointTopicTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/ManagedJmsEndpointTopicTest.java
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/ManagedJmsEndpointTopicTest.java
new file mode 100644
index 0000000..81cd70c
--- /dev/null
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/ManagedJmsEndpointTopicTest.java
@@ -0,0 +1,92 @@
+/**
+ * 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.component.jms;
+
+import javax.jms.ConnectionFactory;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.management.DefaultManagementNamingStrategy;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
+/**
+ *
+ */
+public class ManagedJmsEndpointTopicTest extends CamelTestSupport {
+
+    @Override
+    protected boolean useJmx() {
+        return true;
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        DefaultManagementNamingStrategy naming = (DefaultManagementNamingStrategy) context.getManagementStrategy().getManagementNamingStrategy();
+        naming.setHostName("localhost");
+        naming.setDomainName("org.apache.camel");
+
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+        context.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
+
+        return context;
+    }
+
+    protected MBeanServer getMBeanServer() {
+        return context.getManagementStrategy().getManagementAgent().getMBeanServer();
+    }
+
+    @Test
+    public void testJmsEndpoint() throws Exception {
+        MBeanServer mbeanServer = getMBeanServer();
+
+        ObjectName name = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=endpoints,name=\"activemq://topic:start\"");
+        String uri = (String) mbeanServer.getAttribute(name, "EndpointUri");
+        assertEquals("activemq://topic:start", uri);
+
+        Boolean singleton = (Boolean) mbeanServer.getAttribute(name, "Singleton");
+        assertTrue(singleton.booleanValue());
+
+        Integer running = (Integer) mbeanServer.getAttribute(name, "RunningMessageListeners");
+        assertEquals(2, running.intValue());
+
+        getMockEndpoint("mock:result").expectedMessageCount(2);
+
+        template.sendBody("activemq:topic:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("activemq:topic:start").routeId("foo").to("log:foo").to("mock:result");
+
+                from("activemq:topic:start").routeId("bar").to("log:bar").to("mock:result");
+            }
+        };
+    }
+
+
+}


Mime
View raw message