Author: jstrachan
Date: Thu May 17 09:07:49 2007
New Revision: 538991
URL: http://svn.apache.org/viewvc?view=rev&rev=538991
Log:
refactored the example to match the name 'example' rather than 'sample'
Added:
activemq/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/
activemq/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/
- copied from r538981,
activemq/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/samples/jmstofile/
activemq/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java
(with props)
Removed:
activemq/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileSample.java
activemq/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/samples/
Modified:
activemq/camel/trunk/examples/camel-example-jms-file/pom.xml
Modified: activemq/camel/trunk/examples/camel-example-jms-file/pom.xml
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-jms-file/pom.xml?view=diff&rev=538991&r1=538990&r2=538991
==============================================================================
--- activemq/camel/trunk/examples/camel-example-jms-file/pom.xml (original)
+++ activemq/camel/trunk/examples/camel-example-jms-file/pom.xml Thu May 17
09:07:49 2007
@@ -18,7 +18,7 @@
-->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0">
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
@@ -34,45 +34,21 @@
<dependencies>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-core</artifactId>
- <type>test-jar</type>
- </dependency>
-
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-jms</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-spring</artifactId>
- <optional>true</optional>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jms_1.1_spec</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>apache-activemq</artifactId>
- </dependency>
-
-
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-jms</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>apache-activemq</artifactId>
+ </dependency>
+
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Added:
activemq/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java?view=auto&rev=538991
==============================================================================
---
activemq/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java
(added)
+++
activemq/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java
Thu May 17 09:07:49 2007
@@ -0,0 +1,89 @@
+/**
+ *
+ * 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.example.jmstofile;
+
+import org.apache.camel.component.jms.JmsComponent;
+import javax.jms.ConnectionFactory;
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.camel.CamelTemplate;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+
+
+/**
+ * An example class for demonstrating some of the basics behind camel
+ *
+ * This example will send some text messages on to a JMS Queue, consume them
and
+ * persist them to disk
+ *
+ * @version $Revision: 529902 $
+ *
+ */
+public class CamelJmsToFileExample {
+
+ public static void main(String args[]) throws Exception{
+ // START SNIPPET: e1
+ CamelContext context=new DefaultCamelContext();
+ // END SNIPPET: e1
+ // Set up the ActiveMQ JMS Components
+ // START SNIPPET: e2
+ ConnectionFactory connectionFactory=new
ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
+ // note we can explicity name the component
+
context.addComponent("test-jms",JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
+ // END SNIPPET: e2
+ // Add some configuration by hand ...
+ // START SNIPPET: e3
+ context.addRoutes(new RouteBuilder(){
+
+ public void configure(){
+ from("test-jms:queue:test.queue").to("file://test");
+ // set up a listener on the file component
+ from("file://test").process(new Processor(){
+
+ public void process(Exchange e){
+ System.out.println("Received exchange: "+e.getIn());
+ }
+ });
+ }
+ });
+ // END SNIPPET: e3
+ // Camel template - a handy class for kicking off exchanges
+ // START SNIPPET: e4
+ CamelTemplate template =new CamelTemplate(context);
+ // END SNIPPET: e4
+ // Now everything is set up - lets start the context
+ context.start();
+ // now send some test text to a component - for this case a JMS Queue
+ // The text get converted to JMS messages - and sent to the Queue
test.queue
+ // The file component is listening for messages from the Queue
test.queue, consumes
+ // them and stores them to disk. The content of each file will be the
test test we sent here.
+ // The listener on the file component gets notfied when new files are
found ...
+ // that's it!
+ // START SNIPPET: e5
+ for(int i=0;i<10;i++){
+ template.sendBody("test-jms:queue:test.queue","Test Message: "+i);
+ }
+ // END SNIPPET: e5
+ Thread.sleep(1000);
+ context.stop();
+ }
+}
\ No newline at end of file
Propchange:
activemq/camel/trunk/examples/camel-example-jms-file/src/main/java/org/apache/camel/example/jmstofile/CamelJmsToFileExample.java
------------------------------------------------------------------------------
svn:eol-style = native