You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ge...@apache.org on 2008/11/03 15:38:26 UTC
svn commit: r710069 - in
/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src:
main/java/org/apache/servicemix/camel/JbiEndpoint.java
test/java/org/apache/servicemix/camel/JbiProducerTest.java
Author: gertv
Date: Mon Nov 3 06:38:25 2008
New Revision: 710069
URL: http://svn.apache.org/viewvc?rev=710069&view=rev
Log:
SM-1671: DeploymentException on shutdown when multiple routes target the same endpoint
Added:
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiProducerTest.java (with props)
Modified:
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiEndpoint.java
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiEndpoint.java?rev=710069&r1=710068&r2=710069&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiEndpoint.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiEndpoint.java Mon Nov 3 06:38:25 2008
@@ -30,6 +30,8 @@
import org.apache.camel.impl.DefaultEndpoint;
import org.apache.camel.impl.DefaultProducer;
import org.apache.camel.util.URISupport;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* Represents an {@link org.apache.camel.Endpoint} for interacting with JBI
@@ -62,6 +64,8 @@
}
protected class JbiProducer extends DefaultProducer<Exchange> implements AsyncProcessor {
+
+ private final Log log = LogFactory.getLog(JbiProducer.class);
private CamelConsumerEndpoint consumer;
@@ -72,15 +76,18 @@
@Override
public void start() throws Exception {
consumer = new CamelConsumerEndpoint(jbiComponent.getBinding(), JbiEndpoint.this);
- //consumer.start();
jbiComponent.addEndpoint(consumer);
super.start();
}
@Override
public void stop() throws Exception {
- //consumer.stop();
- jbiComponent.removeEndpoint(consumer);
- super.stop();
+ if (isStopped()) {
+ log.debug("Camel producer for " + super.getEndpoint() + " has already been stopped");
+ } else {
+ log.debug("Stopping Camel producer for " + super.getEndpoint());
+ jbiComponent.removeEndpoint(consumer);
+ super.stop();
+ }
}
public void process(Exchange exchange) throws Exception {
Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiProducerTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiProducerTest.java?rev=710069&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiProducerTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiProducerTest.java Mon Nov 3 06:38:25 2008
@@ -0,0 +1,64 @@
+/*
+ * 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.servicemix.camel;
+
+import java.util.List;
+
+import javax.jbi.management.DeploymentException;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.servicemix.jbi.container.ActivationSpec;
+
+/**
+ * Test for {@link JbiEndpoint.JbiProducer}
+ */
+public class JbiProducerTest extends JbiTestSupport {
+
+ /*
+ * Ensure that no exceptions get thrown when shutting down the routes
+ */
+ public void testShutdown() throws Exception {
+ client.stop();
+ try {
+ camelContext.stop();
+ } catch (DeploymentException e) {
+ fail("Shutdown should not throw " + e);
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ // testing shutdown, so will do this manually
+ }
+
+ @Override
+ protected RouteBuilder createRoutes() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ // two routes that target the same service endpoint
+ from("jbi:service:urn:test:service1").to("jbi:service:urn:test:target-service");
+ from("jbi:service:urn:test:service2").to("jbi:service:urn:test:target-service");
+ }
+ };
+ }
+
+ @Override
+ protected void appendJbiActivationSpecs(List<ActivationSpec> activationSpecList) {
+ // no additional activation specs required
+ }
+}
Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiProducerTest.java
------------------------------------------------------------------------------
svn:eol-style = native