Author: davsclaus
Date: Sun Jan 18 22:52:43 2009
New Revision: 735619

URL: http://svn.apache.org/viewvc?rev=735619&view=rev
Log:
CAMEL-1269: Added STOP command. However graceful shutdown using JMS still 
hangs. 

Added:
    
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientStop.java
   (contents, props changed)
      - copied, changed from r734935, 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClient.java
    
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/server/GracefulShutdownService.java
   (with props)
Modified:
    activemq/camel/trunk/examples/camel-example-spring-jms/pom.xml
    
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/server/ServerRoutes.java
    
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server.xml
    
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/camel-client.xml

Modified: activemq/camel/trunk/examples/camel-example-spring-jms/pom.xml
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-spring-jms/pom.xml?rev=735619&r1=735618&r2=735619&view=diff
==============================================================================
--- activemq/camel/trunk/examples/camel-example-spring-jms/pom.xml (original)
+++ activemq/camel/trunk/examples/camel-example-spring-jms/pom.xml Sun Jan 18 
22:52:43 2009
@@ -48,7 +48,7 @@
         </dependency>
         <dependency>
             <groupId>org.apache.activemq</groupId>
-            <artifactId>activemq-core</artifactId>
+            <artifactId>activemq-camel</artifactId>
         </dependency>
         <!-- END SNIPPET: e1 -->
 
@@ -122,6 +122,13 @@
             </properties>
         </profile>
         <profile>
+            <id>CamelClientStop</id>
+            <properties>
+                <!-- we start using our own class to control what we do in the 
main -->
+                
<target.main.class>org.apache.camel.example.client.CamelClientStop</target.main.class>
+            </properties>
+        </profile>
+        <profile>
             <id>CamelClientRemoting</id>
             <properties>
                 <!-- we start using our own class to control what we do in the 
main -->

Copied: 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientStop.java
 (from r734935, 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClient.java)
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientStop.java?p2=activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientStop.java&p1=activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClient.java&r1=734935&r2=735619&rev=735619&view=diff
==============================================================================
--- 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClient.java
 (original)
+++ 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientStop.java
 Sun Jan 18 22:52:43 2009
@@ -22,12 +22,12 @@
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 /**
- * Client that uses the {...@link ProducerTemplate} to easily exchange 
messages with the Server.
+ * Client that uses the {...@link org.apache.camel.ProducerTemplate} to easily 
exchange messages with the Server.
  * <p/>
  * Requires that the JMS broker is running, as well as CamelServer
  */
-public final class CamelClient {
-    private CamelClient() {
+public final class CamelClientStop {
+    private CamelClientStop() {
         // Helper class
     }
 
@@ -40,13 +40,9 @@
         // get the camel template for Spring template style sending of 
messages (= producer)
         ProducerTemplate camelTemplate = (ProducerTemplate) 
context.getBean("camelTemplate");
 
-        System.out.println("Invoking the multiply with 22");
-        // as opposed to the CamelClientRemoting example we need to define the 
service URI in this java code
-        int response = (Integer)camelTemplate.sendBody("jms:queue:numbers", 
ExchangePattern.InOut, 22);
-        System.out.println("... the result is: " + response);
-
-        System.exit(0);
+        System.out.println("Invoking with STOP command");
+        camelTemplate.sendBody("activemq:queue:stop", ExchangePattern.InOnly, 
"STOP");
     }
     // END SNIPPET: e1
 
-}
+}
\ No newline at end of file

Propchange: 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientStop.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientStop.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientStop.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Added: 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/server/GracefulShutdownService.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/server/GracefulShutdownService.java?rev=735619&view=auto
==============================================================================
--- 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/server/GracefulShutdownService.java
 (added)
+++ 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/server/GracefulShutdownService.java
 Sun Jan 18 22:52:43 2009
@@ -0,0 +1,16 @@
+package org.apache.camel.example.server;
+
+import org.apache.camel.spring.Main;
+import org.springframework.stereotype.Service;
+
+/**
+ * Service for stopping the server.
+ */
+...@service(value = "shutdown")
+public class GracefulShutdownService {
+
+    public void shutdown(String payload) throws Exception {
+        System.out.println("Stopping Server as we recieved a " + payload + " 
command");
+        Main.getInstance().stop();
+    }
+}

Propchange: 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/server/GracefulShutdownService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/server/GracefulShutdownService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/server/ServerRoutes.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/server/ServerRoutes.java?rev=735619&r1=735618&r2=735619&view=diff
==============================================================================
--- 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/server/ServerRoutes.java
 (original)
+++ 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/server/ServerRoutes.java
 Sun Jan 18 22:52:43 2009
@@ -42,7 +42,10 @@
         //from("jms:queue:numbers").beanRef("multiplier", "multiply");
 
         // the same as above but expressed as a URI configuration
-        //from("jms:queue:numbers").to("bean:multiplier?methodName=multiply");
+        
//from("activemq:queue:numbers").to("bean:multiplier?methodName=multiply");
+
+        // the STOP command
+        from("jms:queue:stop").to("shutdown");
     }
 
 }

Modified: 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server.xml
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server.xml?rev=735619&r1=735618&r2=735619&view=diff
==============================================================================
--- 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server.xml
 (original)
+++ 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/META-INF/spring/camel-server.xml
 Sun Jan 18 22:52:43 2009
@@ -55,14 +55,9 @@
     <!-- END SNIPPET: e4 -->
 
     <!-- START SNIPPET: e5 -->
-    <!-- lets configure the Camel JMS consumer to use the ActiveMQ broker 
declared above -->
-    <bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
-        <property name="connectionFactory">
-            <bean class="org.apache.activemq.ActiveMQConnectionFactory">
-                <!-- use the vm protocol as the JMS broker is running in the 
same jvm as Camel -->
-                <property name="brokerURL" value="vm://localhost"/>
-            </bean>
-        </property>
+    <!-- lets configure the Camel ActiveMQ to use the ActiveMQ broker declared 
above -->
+    <bean id="jms" 
class="org.apache.activemq.camel.component.ActiveMQComponent">
+        <property name="brokerURL" value="tcp://localhost:61616"/>
     </bean>
     <!-- END SNIPPET: e5 -->
 

Modified: 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/camel-client.xml
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/camel-client.xml?rev=735619&r1=735618&r2=735619&view=diff
==============================================================================
--- 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/camel-client.xml
 (original)
+++ 
activemq/camel/trunk/examples/camel-example-spring-jms/src/main/resources/camel-client.xml
 Sun Jan 18 22:52:43 2009
@@ -32,12 +32,8 @@
 
     <!-- START SNIPPET: e3 -->
     <!-- Camel JMSProducer to be able to send messages to a remote Active MQ 
server -->
-    <bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
-        <property name="connectionFactory">
-            <bean class="org.apache.activemq.ActiveMQConnectionFactory">
-                <property name="brokerURL" value="tcp://localhost:61616"/>
-            </bean>
-        </property>
+    <bean id="jms" 
class="org.apache.activemq.camel.component.ActiveMQComponent">
+        <property name="brokerURL" value="tcp://localhost:61616"/>
     </bean>
     <!-- END SNIPPET: e3 -->
 


Reply via email to