svn commit: r1160565 - /camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerTemplateTest.java

2011-08-23 Thread davsclaus
Author: davsclaus
Date: Tue Aug 23 06:58:27 2011
New Revision: 1160565

URL: http://svn.apache.org/viewvc?rev=1160565view=rev
Log:
Added unit test based on user forum issue.

Added:

camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerTemplateTest.java
  - copied, changed from r1160554, 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java

Copied: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerTemplateTest.java
 (from r1160554, 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java)
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerTemplateTest.java?p2=camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerTemplateTest.javap1=camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.javar1=1160554r2=1160565rev=1160565view=diff
==
--- 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java
 (original)
+++ 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerTemplateTest.java
 Tue Aug 23 06:58:27 2011
@@ -21,18 +21,13 @@ import java.io.File;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.Producer;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.Before;
 import org.junit.Test;
 
-/**
- * Unit test to test delete option.
- */
-public class FromFtpDeleteFileTest extends FtpServerTestSupport {
+public class FtpConsumerTemplateTest extends FtpServerTestSupport {
 
 protected String getFtpUrl() {
-return ftp://admin@localhost:; + getPort() + 
/deletefile?password=adminbinary=falsedelete=true;
+return ftp://admin@localhost:; + getPort() + 
/template?password=admin;
 }
 
 @Override
@@ -41,29 +36,76 @@ public class FromFtpDeleteFileTest exten
 super.setUp();
 prepareFtpServer();
 }
-
+
+@Override
+public boolean isUseRouteBuilder() {
+return false;
+}
+
+@Test
+public void testConsumerTemplate() throws Exception {
+Exchange exchange = consumer.receive(getFtpUrl(), 5000);
+assertNotNull(exchange);
+assertEquals(hello.txt, 
exchange.getIn().getHeader(Exchange.FILE_NAME));
+assertEquals(Hello World, exchange.getIn().getBody(String.class));
+
+// must done when we are done using the exchange
+consumer.doneUoW(exchange);
+
+Thread.sleep(500);
+
+// poll the same file again
+exchange = consumer.receive(getFtpUrl(), 5000);
+assertNotNull(exchange);
+assertEquals(hello.txt, 
exchange.getIn().getHeader(Exchange.FILE_NAME));
+assertEquals(Hello World, exchange.getIn().getBody(String.class));
+
+// must done when we are done using the exchange
+consumer.doneUoW(exchange);
+
+// file should still exists
+Thread.sleep(500);
+File file = new File(FTP_ROOT_DIR + template/hello.txt);
+file = file.getAbsoluteFile();
+assertTrue(The file should exist:  + file, file.exists());
+}
+
 @Test
-public void testPollFileAndShouldBeDeleted() throws Exception {
-MockEndpoint mock = getMockEndpoint(mock:result);
-mock.expectedMessageCount(1);
-mock.expectedBodiesReceived(Hello World this file will be deleted);
+public void testConsumerTemplateNotDone() throws Exception {
+Exchange exchange = consumer.receive(getFtpUrl(), 5000);
+assertNotNull(exchange);
+assertEquals(hello.txt, 
exchange.getIn().getHeader(Exchange.FILE_NAME));
+assertEquals(Hello World, exchange.getIn().getBody(String.class));
 
-mock.assertIsSatisfied();
+// forget to call done
 
 Thread.sleep(500);
 
-// assert the file is deleted
-File file = new File(FTP_ROOT_DIR + deletefile/hello.txt);
+// try poll the same file again
+Exchange exchange2 = consumer.receive(getFtpUrl(), 2000);
+assertNull(exchange2);
+
+// now done the original exchange
+consumer.doneUoW(exchange);
+
+// now we can poll the file again as we have done the exchange
+exchange2 = consumer.receive(getFtpUrl(), 2000);
+assertNotNull(exchange2);
+assertEquals(hello.txt, 
exchange2.getIn().getHeader(Exchange.FILE_NAME));
+assertEquals(Hello World, exchange2.getIn().getBody(String.class));
+consumer.doneUoW(exchange2);
+
+// file should still exists
+Thread.sleep(500);
+File file = new 

svn commit: r1160588 - in /camel/branches/camel-2.8.x: ./ components/camel-spring/src/main/java/org/apache/camel/spring/ components/camel-test/src/main/java/org/apache/camel/test/junit4/ components/ca

2011-08-23 Thread ningjiang
Author: ningjiang
Date: Tue Aug 23 08:54:54 2011
New Revision: 1160588

URL: http://svn.apache.org/viewvc?rev=1160588view=rev
Log:
Merged revisions 1160547 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk


  r1160547 | ningjiang | 2011-08-23 12:54:59 +0800 (Tue, 23 Aug 2011) | 1 line
  
  CAMEL-4368 Fixed the issue of the debug doesn't work in the 
CamelSpringTestSupport


Added:

camel/branches/camel-2.8.x/components/camel-test/src/test/java/org/apache/camel/test/patterns/DebugSpringTest.java
  - copied, changed from r1160547, 
camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/DebugSpringTest.java

camel/branches/camel-2.8.x/components/camel-testng/src/test/java/org/apache/camel/testng/patterns/DebugSpringTest.java
  - copied, changed from r1160547, 
camel/trunk/components/camel-testng/src/test/java/org/apache/camel/testng/patterns/DebugSpringTest.java
Modified:
camel/branches/camel-2.8.x/   (props changed)

camel/branches/camel-2.8.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java

camel/branches/camel-2.8.x/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java

camel/branches/camel-2.8.x/components/camel-testng/src/main/java/org/apache/camel/testng/CamelSpringTestSupport.java

Propchange: camel/branches/camel-2.8.x/
--
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 23 08:54:54 2011
@@ -1 +1 @@
-/camel/trunk:1155230,1156108,1156260,1156524,1157348,1157798,1157831,1157878,1158153,1159171,1159174,1159457,1159460,1159606,1159867
+/camel/trunk:1155230,1156108,1156260,1156524,1157348,1157798,1157831,1157878,1158153,1159171,1159174,1159457,1159460,1159606,1159867,1160547

Propchange: camel/branches/camel-2.8.x/
--
Binary property 'svnmerge-integrated' - no diff available.

Modified: 
camel/branches/camel-2.8.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java?rev=1160588r1=1160587r2=1160588view=diff
==
--- 
camel/branches/camel-2.8.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
 (original)
+++ 
camel/branches/camel-2.8.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
 Tue Aug 23 08:54:54 2011
@@ -65,7 +65,12 @@ public class SpringCamelContext extends 
 setApplicationContext(applicationContext);
 }
 
+
 public static SpringCamelContext springCamelContext(ApplicationContext 
applicationContext) throws Exception {
+return springCamelContext(applicationContext, true);
+}
+
+public static SpringCamelContext springCamelContext(ApplicationContext 
applicationContext, boolean maybeStart) throws Exception {
 // lets try and look up a configured camel context in the context
 String[] names = 
applicationContext.getBeanNamesForType(SpringCamelContext.class);
 if (names.length == 1) {
@@ -73,7 +78,9 @@ public class SpringCamelContext extends 
 }
 SpringCamelContext answer = new SpringCamelContext();
 answer.setApplicationContext(applicationContext);
-answer.afterPropertiesSet();
+if (maybeStart) {
+answer.afterPropertiesSet();
+}
 return answer;
 }
 

Modified: 
camel/branches/camel-2.8.x/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java?rev=1160588r1=1160587r2=1160588view=diff
==
--- 
camel/branches/camel-2.8.x/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java
 (original)
+++ 
camel/branches/camel-2.8.x/components/camel-test/src/main/java/org/apache/camel/test/junit4/CamelSpringTestSupport.java
 Tue Aug 23 08:54:54 2011
@@ -176,6 +176,7 @@ public abstract class CamelSpringTestSup
 
 @Override
 protected CamelContext createCamelContext() throws Exception {
-return SpringCamelContext.springCamelContext(applicationContext);
+// don't start the springCamelContext if we
+return SpringCamelContext.springCamelContext(applicationContext, 
false);
 }
 }

Copied: 
camel/branches/camel-2.8.x/components/camel-test/src/test/java/org/apache/camel/test/patterns/DebugSpringTest.java
 (from r1160547, 
camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/DebugSpringTest.java)

[CONF] Apache Camel Camel 3.0 - Roadmap

2011-08-23 Thread confluence







Camel 3.0 - Roadmap
Page edited by Christian Schneider


 Changes (1)
 




...
* builder - impl  
h4. Define scope and rules for camel-core packages  In extension to the previous paragraph each camel package should have a clear scope that defines what to put in the package and what not. There should be rules that define what dependencies are allowed for classes in a package. The minimum goal is to guarantee that by following the rules dependency cycles can not happen. Additionally the rules should minimize dependencies between packages to achieve loose coupling between packages and high coherence inside a package.  
h4. Routing engine optimization  
...


Full Content

Camel 3.0 roadmap

This is a roadmap which details the overall and major goals for Camel 3.0. Fell free to discuss this at the Camel Mailing Lists if you have ideas or feedback.

The Camel PMC conducted a survey in Oct 2010 to get a better understanding of how Camel is used and what the priorities for Camel 3.0 should be.

Nothing is committed/confirmedThe items listed on this wiki page is just ideas for the roadmap. Anything is subject for change.
Speak up if you want to ensure a feature is on the roadmap, or if you have new ideas etc.

When development of Camel 3.0 starts we will update status here which items have been implemented in the source code, and which have been discarded/deferred etc.

Clearer Architecture of Camel Core

Goals:

	The camel components should know as little as possible about camel core
	The classes needed to setup camel should be separate from the things needed at run time



So why should this be important? Currently components depend on camel-core as a whole and there are no further rules which classes the components should use and which classes should be private to core. Even classes from the impl package are needed. So this means that any refactoring we do in camel core could affect all components. As camel is growing steadily this can become quite problematic.

Split camel-core into three parts:

api, builder, impl

These should be structured in a way that these big building blocks do not have cyclic dependencies. Any other cycles can be ignored in this step.

Allowed depdencies ( "-" means may use, may depend on):


	* - api
	end user config code - builder
	builder - impl



Define scope and rules for camel-core packages

In extension to the previous paragraph each camel package should have a clear scope that defines what to put in the package and what not. There should be rules that define what dependencies are allowed for classes in a package. The minimum goal is to guarantee that by following the rules dependency cycles can not happen. Additionally the rules should minimize dependencies between packages to achieve loose coupling between packages and high coherence inside a package.

Routing engine optimization

The internal routing engine should be optimized. See more details at Camel 2.x Speed optimizations.

Tighten up route definitions

Currently cross cutting concerns such as error handlers, interceptors, onCompletion etc. can be define anywhere in the route. We should tighten this up and only allow this to be configured in the start of the route. This also ensures when end users use code assistance in their route development, the IDE will not popup a big list which includes these cross cutting concerns. See also next note. (ProcessorDefinition will therefore be trimmed)

More flexible routes at runtime

When routes is added in Camel 2.x architecture, global cross cutting concerns such as error handlers, interceptors, onCompletion etc. is applied when the route is added. We need to separate this and have those applied during routing. The Channel needs to do this and therefore it must be more dynamic than its currently is. And we need to enlist the various global cross cutting concerns by their xxxDefintions in the CamelContext, so we can access them at any time. This allows end users also much more easily to add/remove interceptors, error handlers and whatnot at runtime. And it makes it much easier to add routes generated from JAXB or other sources, as we don't need to prepare or anyhow mold the RouteDefinition given. See ticket CAMEL-3024 for some details. 

Support for asynchronous transactions

When using the asynchronous routing engine it would be desirable of transactional context could be propagated to the new threads.
This requires the TX manager supports suspend/resume on the TX. G.Nodet have worked a bit on this. See CAMEL-2902. Also see CAMEL-2729.

Remove @deprecated

@deprecated features, methods, etc. is to be removed.

Stream caching

We could add support for using HawtDB as the persistent store for streams which overflow to disk 

svn commit: r1160603 - in /camel/trunk/camel-core: pom.xml src/main/java/org/apache/camel/main/package.html

2011-08-23 Thread cschneider
Author: cschneider
Date: Tue Aug 23 10:11:25 2011
New Revision: 1160603

URL: http://svn.apache.org/viewvc?rev=1160603view=rev
Log:
CAMEL-4357 Add package documentation and javadoc grouping

Added:
camel/trunk/camel-core/src/main/java/org/apache/camel/main/package.html   
(with props)
Modified:
camel/trunk/camel-core/pom.xml

Modified: camel/trunk/camel-core/pom.xml
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/pom.xml?rev=1160603r1=1160602r2=1160603view=diff
==
--- camel/trunk/camel-core/pom.xml (original)
+++ camel/trunk/camel-core/pom.xml Tue Aug 23 10:11:25 2011
@@ -274,6 +274,10 @@
   
packagesorg.apache.camel.impl:org.apache.camel.impl.*/packages
 /group
 group
+  titleCamel Starters/title
+  packagesorg.apache.camel.main/packages
+/group
+group
   titleType conversion helper classes/title
   
packagesorg.apache.camel.converter:org.apache.camel.converter.*/packages
 /group

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/main/package.html
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/main/package.html?rev=1160603view=auto
==
--- camel/trunk/camel-core/src/main/java/org/apache/camel/main/package.html 
(added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/main/package.html Tue 
Aug 23 10:11:25 2011
@@ -0,0 +1,26 @@
+!--
+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.
+--
+html
+head
+/head
+body
+
+Application level classes that can be used to instantiate camel. These classes 
may access the impl packages. No other package should depend on the main
+package.
+
+/body
+/html

Propchange: 
camel/trunk/camel-core/src/main/java/org/apache/camel/main/package.html
--
svn:mime-type = text/plain




svn commit: r1160632 - /camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/Netty2978IssueTest.java

2011-08-23 Thread ningjiang
Author: ningjiang
Date: Tue Aug 23 11:20:41 2011
New Revision: 1160632

URL: http://svn.apache.org/viewvc?rev=1160632view=rev
Log:
Enable the test of Netty2978Issue

Modified:

camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/Netty2978IssueTest.java

Modified: 
camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/Netty2978IssueTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/Netty2978IssueTest.java?rev=1160632r1=1160631r2=1160632view=diff
==
--- 
camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/Netty2978IssueTest.java
 (original)
+++ 
camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/Netty2978IssueTest.java
 Tue Aug 23 11:20:41 2011
@@ -32,6 +32,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.properties.PropertiesComponent;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -39,12 +40,11 @@ import org.junit.Test;
 /**
  * @version 
  */
-@Ignore
 public class Netty2978IssueTest extends BaseNettyTest {
 
 @Test
 public void testNetty2978() throws Exception {
-CamelClient client = new CamelClient();
+CamelClient client = new CamelClient(context);
 try {
 for (int i = 0; i  1000; i++) {
 Object reply = client.lookup(i);
@@ -57,7 +57,7 @@ public class Netty2978IssueTest extends 
 
 @Test
 public void testNetty2978Concurrent() throws Exception {
-final CamelClient client = new CamelClient();
+final CamelClient client = new CamelClient(context);
 try {
 final ListCallableString callables = new 
ArrayListCallableString();
 for (int count = 0; count  1000; count++) {
@@ -104,19 +104,18 @@ public class Netty2978IssueTest extends 
 }
 
 private static final class CamelClient {
-private final CamelContext context;
+private final CamelContext camelContext;
 private final Endpoint endpoint;
 private final ProducerTemplate producerTemplate;
 
-public CamelClient() {
-this.context = new DefaultCamelContext();
-this.endpoint = 
context.getEndpoint(netty:tcp://localhost:{{port}}?sync=true);
-this.producerTemplate = context.createProducerTemplate();
+public CamelClient(CamelContext camelContext) {
+this.camelContext = camelContext;
+this.endpoint = 
camelContext.getEndpoint(netty:tcp://localhost:{{port}}?sync=true);
+this.producerTemplate = camelContext.createProducerTemplate();
 }
 
 public void close() throws Exception {
 producerTemplate.stop();
-context.stop();
 }
 
 public String lookup(int num) {




svn commit: r1160637 - in /camel/trunk/components/camel-netty/src: main/java/org/apache/camel/component/netty/NettyConfiguration.java test/java/org/apache/camel/component/netty/NettySingleCodecTest.ja

2011-08-23 Thread ningjiang
Author: ningjiang
Date: Tue Aug 23 11:38:32 2011
New Revision: 1160637

URL: http://svn.apache.org/viewvc?rev=1160637view=rev
Log:
CAMEL-4367 made the Camel-netty option encoder and decoder work

Added:

camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettySingleCodecTest.java
   (with props)
Modified:

camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java

Modified: 
camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java?rev=1160637r1=1160636r2=1160637view=diff
==
--- 
camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
 (original)
+++ 
camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
 Tue Aug 23 11:38:32 2011
@@ -122,6 +122,7 @@ public class NettyConfiguration implemen
 addToHandlersList(decoders, referencedDecoders, 
ChannelUpstreamHandler.class);
 
 // then set parameters with the help of the camel context type 
converters
+EndpointHelper.setReferenceProperties(component.getCamelContext(), 
this, parameters);
 EndpointHelper.setProperties(component.getCamelContext(), this, 
parameters);
 
 // add default encoders and decoders

Added: 
camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettySingleCodecTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettySingleCodecTest.java?rev=1160637view=auto
==
--- 
camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettySingleCodecTest.java
 (added)
+++ 
camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettySingleCodecTest.java
 Tue Aug 23 11:38:32 2011
@@ -0,0 +1,62 @@
+/**
+ * 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.netty;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.junit.Test;
+
+public class NettySingleCodecTest extends BaseNettyTest {
+
+@Override
+protected JndiRegistry createRegistry() throws Exception {
+JndiRegistry registry = super.createRegistry();
+StringEncoder stringEncoder = new StringEncoder();
+
+StringDecoder stringDecoder = new StringDecoder();
+
+registry.bind(encoder, stringEncoder);
+registry.bind(decoder, stringDecoder);
+return registry;
+}
+
+@Test
+public void canSupplySingleCodecToEndpointPipeline() throws Exception {
+String poem = new Poetry().getPoem();
+MockEndpoint mock = getMockEndpoint(mock:single-codec);
+mock.expectedBodiesReceived(poem);
+sendBody(direct:single-codec, poem);
+mock.await(1, TimeUnit.SECONDS);
+mock.assertIsSatisfied();
+
+}
+
+protected RouteBuilder createRouteBuilder() throws Exception {
+return new RouteBuilder() {
+public void configure() throws Exception {
+
from(direct:single-codec).to(netty:tcp://localhost:{{port}}?encoder=#encodersync=false);
+
+
from(netty:tcp://localhost:{{port}}?decoder=#decodersync=false).to(mock:single-codec);
+}
+};
+}
+}
\ No newline at end of file

Propchange: 
camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettySingleCodecTest.java
--
svn:eol-style = native

Propchange: 

svn commit: r1160638 - /camel/trunk/camel-core/src/main/java/org/apache/camel/Main.java

2011-08-23 Thread ningjiang
Author: ningjiang
Date: Tue Aug 23 11:39:04 2011
New Revision: 1160638

URL: http://svn.apache.org/viewvc?rev=1160638view=rev
Log:
Fixed the CS error of Main

Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/Main.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/Main.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/Main.java?rev=1160638r1=1160637r2=1160638view=diff
==
--- camel/trunk/camel-core/src/main/java/org/apache/camel/Main.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/Main.java Tue Aug 23 
11:39:04 2011
@@ -1,3 +1,19 @@
+/**
+ * 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;
 
 /**




svn commit: r1160641 - /camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/Netty2978IssueTest.java

2011-08-23 Thread ningjiang
Author: ningjiang
Date: Tue Aug 23 11:44:35 2011
New Revision: 1160641

URL: http://svn.apache.org/viewvc?rev=1160641view=rev
Log:
Clean up the code of Netty2978IssueTest

Modified:

camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/Netty2978IssueTest.java

Modified: 
camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/Netty2978IssueTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/Netty2978IssueTest.java?rev=1160641r1=1160640r2=1160641view=diff
==
--- 
camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/Netty2978IssueTest.java
 (original)
+++ 
camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/Netty2978IssueTest.java
 Tue Aug 23 11:44:35 2011
@@ -32,9 +32,6 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.properties.PropertiesComponent;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -104,12 +101,10 @@ public class Netty2978IssueTest extends 
 }
 
 private static final class CamelClient {
-private final CamelContext camelContext;
 private final Endpoint endpoint;
 private final ProducerTemplate producerTemplate;
 
 public CamelClient(CamelContext camelContext) {
-this.camelContext = camelContext;
 this.endpoint = 
camelContext.getEndpoint(netty:tcp://localhost:{{port}}?sync=true);
 this.producerTemplate = camelContext.createProducerTemplate();
 }




svn commit: r1160679 [3/3] - in /camel/trunk: camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/component/bean/ camel-core/src/main/java/org/apache/camel/com

2011-08-23 Thread cschneider
Modified: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/Order.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/Order.java?rev=1160679r1=1160678r2=1160679view=diff
==
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/Order.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/wsdl/Order.java
 Tue Aug 23 13:27:43 2011
@@ -1,47 +1,47 @@
-/**
- * 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.cxf.wsdl;
-
-import javax.xml.bind.annotation.XmlRootElement;
-
-public class Order {
-
-String customerName;
-String productName;
-
-public String getCustomerName() {
-return customerName;
-}
-
-public void setCustomerName(String customerName) {
-this.customerName = customerName;
-}
-
-public String getProductName() {
-return productName;
-}
-
-public void setProductName(String productName) {
-this.productName = productName;
-}
-
-@Override
-public String toString() {
-return order[ + customerName + , + productName + ];
-}
-
-}
+/**
+ * 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.cxf.wsdl;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+public class Order {
+
+String customerName;
+String productName;
+
+public String getCustomerName() {
+return customerName;
+}
+
+public void setCustomerName(String customerName) {
+this.customerName = customerName;
+}
+
+public String getProductName() {
+return productName;
+}
+
+public void setProductName(String productName) {
+this.productName = productName;
+}
+
+@Override
+public String toString() {
+return order[ + customerName + , + productName + ];
+}
+
+}

Modified: 
camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/processor/idempotent/hazelcast/HazelcastIdempotentRepository.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/processor/idempotent/hazelcast/HazelcastIdempotentRepository.java?rev=1160679r1=1160678r2=1160679view=diff
==
--- 
camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/processor/idempotent/hazelcast/HazelcastIdempotentRepository.java
 (original)
+++ 
camel/trunk/components/camel-hazelcast/src/main/java/org/apache/camel/processor/idempotent/hazelcast/HazelcastIdempotentRepository.java
 Tue Aug 23 13:27:43 2011
@@ -18,8 +18,8 @@ package org.apache.camel.processor.idemp
 
 import com.hazelcast.core.Hazelcast;
 import com.hazelcast.core.IMap;
-import org.apache.camel.impl.ServiceSupport;
 import org.apache.camel.spi.IdempotentRepository;
+import org.apache.camel.support.ServiceSupport;
 
 public class HazelcastIdempotentRepository extends ServiceSupport implements 
IdempotentRepositoryString {
 

Modified: 
camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsEndpoint.java?rev=1160679r1=1160678r2=1160679view=diff

svn commit: r1160701 - in /camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/holder: CXFHolderRouteTest.java CxfHolderConsumerTest.java

2011-08-23 Thread ningjiang
Author: ningjiang
Date: Tue Aug 23 14:07:55 2011
New Revision: 1160701

URL: http://svn.apache.org/viewvc?rev=1160701view=rev
Log:
Added an unit test for camel-cxf holder based on the camel user mailing list

Added:

camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/holder/CXFHolderRouteTest.java
   (with props)
Modified:

camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/holder/CxfHolderConsumerTest.java

Added: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/holder/CXFHolderRouteTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/holder/CXFHolderRouteTest.java?rev=1160701view=auto
==
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/holder/CXFHolderRouteTest.java
 (added)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/holder/CXFHolderRouteTest.java
 Tue Aug 23 14:07:55 2011
@@ -0,0 +1,52 @@
+/**
+ * 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.cxf.holder;
+
+import java.util.List;
+
+import javax.xml.ws.Holder;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+
+public class CXFHolderRouteTest extends CxfHolderConsumerTest {
+
+protected RouteBuilder createRouteBuilder() {
+return new RouteBuilder() {
+public void configure() {
+from(CXF_ENDPOINT_URI).wireTap(seda:tap).process(new 
Processor() {
+@SuppressWarnings(unchecked)
+public void process(Exchange exchange) throws Exception {
+Message in = exchange.getIn();
+List parameters = in.getBody(List.class);
+int amount = (Integer) parameters.remove(1);
+HolderString customer = 
(HolderString)parameters.get(1);
+if (customer.value.length() == 0) {
+customer.value = newCustomer;
+}
+parameters.add(0, Ordered ammount  + amount);
+exchange.getOut().setBody(parameters);
+}
+});
+from(seda:tap).to(log:myEndpoint);
+}
+};
+}
+
+}

Propchange: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/holder/CXFHolderRouteTest.java
--
svn:eol-style = native

Propchange: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/holder/CXFHolderRouteTest.java
--
svn:keywords = Rev Date

Modified: 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/holder/CxfHolderConsumerTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/holder/CxfHolderConsumerTest.java?rev=1160701r1=1160700r2=1160701view=diff
==
--- 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/holder/CxfHolderConsumerTest.java
 (original)
+++ 
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/holder/CxfHolderConsumerTest.java
 Tue Aug 23 14:07:55 2011
@@ -63,11 +63,6 @@ public class CxfHolderConsumerTest exten
 
 @Test
 public void testInvokingServiceFromCXFClient() throws Exception {
-if (Version.getCurrentVersion().equals(2.4.1)) {
-// This test will be failed with CXF 2.4.1, as 
-// the inObjects and outObjects of HolderOutInterceptor are equals
-return;   
-}
 JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
 ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
 clientBean.setAddress(ADDRESS);




[CONF] Apache Camel Articles

2011-08-23 Thread confluence







Articles
Page edited by Jean-Baptiste Onofré


 Changes (2)
 




...
* [Error handling in Camel for JMS consumer endpoint|http://tmielke.blogspot.com/2011/07/error-handling-in-camel-for-jms.html] by Torsten Mielke explains some of the options you have for error handling when using [JMS]. * [Use remote EJB in Camel routes|http://blog.nanthrax.net/2011/08/use-a-remote-ejb-in-camel-routes/] by Jean-Baptiste Onofré explains how to use an EJB hosted in a remote J2EE application server in a Camel route hosted in Apache ServiceMix. 
* [Use Camel, CXF and Karaf to implement batches|http://blog.nanthrax.net/2011/08/use-camel-cxf-and-karaf-to-implement-batches/] by Jean-Baptiste Onofré explains how to control a Camel route from another route and a JAX-RS server using CXF, package into an OSGi bundle ready to run in Apache Karaf. 
  
...
* [Hadrian Zbarcea|http://camelbot.blogspot.com/] \- also blogs about Camel. * [Marcelo Jarbalis Blog|http://marcelojabali.blogspot.com/] \- Marcelo works in the fields and blogs about Camel and integration. 
* [Jean-Baptiste Onofrés Blog|http://blog.nanthrax.net] \- JB blogs about Camel, CXF, Karaf, ServiceMix and OSGi in general. 


Full Content

See alsoSee also Camel User Stories.

Articles on Apache Camel


	Wanna try our Apache Camel developer tools for Enterprise Integration Patterns?  by James Strachan
	A bit more meat: Camel applied : JMS to File by Mike McLean
	Matteo wrote a blog entry about using Camel with iBatis
	Knowledge Tree integration using Apache Camel
	Integrating Apache Camel with JBoss ESB by Edgar Ankiewsky
	Simple DSL OSGi bundle example by Andrej Koelewijn
	Realization of EAI Patterns with Apache Camel by Pascal Kolb at the Universität Stuttgart
	Spring Remoting with JMS Example on Amin Abbaspour's Weblog
	Implementing Fuji integration scenario using Camel SE by Louis Polycarpou on using Camel with Open ESB
	Using the Camel aggregator correctly by Torsten Mielke, a great blog entry how to use the Camel aggregator.
	Camel routes and HL7 by Roger Searjeant on using Camel and its HL7 support in the health care space.
	Combining ApacheCamel+BSF to make JBoss ESB polyglot by Edgard Ankiewsky Silva, a JBoss employeer.
	Groovy and Grape - easiest way to send gtalk message with Apache Camel by Andrej Koelewijn how easy it is to use Groovy and Grape to quickly try out new frameworks such as Apache Camel.
	Domain-Specific Languages (DSLs) in Apache Camel (Spanish) by Gema Perdiguero, Tecsisa.
	Apache Camel integration in ServiceMix (Spanish) by Sebastián Gómez, Tecsisa.
	Open Source Integration with Apache Camel and How Fuse IDE Can Help by Jonathan Anstey. Updated article of the Apache Camel: Integration Nirvana. Great for learning what Camel is and what it can do
	Leverage EIP with Apache Camel and Twitter by Bruno Borges
	Apache Camel Reference Card at DZone (the first card out of two) by Claus Ibsen
	Updated Apache Camel Reference Card at DZone by Claus Ibsen, updated for Camel 2.x Reference Card
	Using RSS with Apache Camel by Jeroen Reijn
	Using Groovy and Camel to pool Google Analyst email reports by Mr. Haki
	Using grails-camel plugin to work with Camel in Grails land by Mr. Haki
	Send mail with Apache Camel from Gails by Mr. Haki
	Navigating the Integration Landscape - Claus Ibsen on Apache Camel Claus Ibsen was interviewed at DZone discussing the integration landscape
	Apache Camel: Enterprise Integration met scripttalen en DSLs (Dutch) by Peter Maas, Finalist IT Group.
	Axis 2 ride with Camel how to use Axis 2 with the Camel report incident tutorial by Sagara
	Introduction to the Open eHealth Integration Platform (based on top of Apache Camel) Excellent DZone article by Martin Krasser
	An IRC alerter written using Apache Camel and Java how to easily integrate IRC with Camel to monitor and do alerts.
	Entreprise Integration Pattern with Apache Camel 2.0 by Julien Dechmann, how to use Camel to split and transform CSV files to POJO and XML and sending to a JMS destination
	A Camel based XML payload HTTP polling provider by Christopher Hunt to use Camel with AJAX. Interesting read.
	Camel vs. JBI by Adrian Trenaman.
	Things to consider when selecting between Apache Camel and Apache Servicemix by Ashwin Karpe
	Groovy and Camel for monitoring ActiveMQ by Eric Hauser how to monitor AMQ Advisory queues from a single groovy file.
	Camellos - Discovering Apache Camel by Gunnar Hillert. A very nice and short blog series about Camel showing its powers in a simple and intuitive way. Highly recommended for new users
	Apache Camel alternatives by Gunnar Hillert. He presents a brief overview of other projects in the integration space.
	First steps with Apache Camel on Google App Engine by 

[CONF] Apache Camel Zookeeper

2011-08-23 Thread confluence







Zookeeper
Page  added by Stephen Gargan

 

 ZooKeeper Component
Available as of Camel 2.9

The ZooKeeper component to allow interaction with a ZooKeeper cluster (http://hadoop.apache.org/zookeeper/) and it exposes the following features to Camel.


	Creation of nodes in any of the ZooKeeper create modes.
	Get and Set the data contents of arbitrary cluster nodes.
	Create and retrieve the list the child nodes attached to a particular node.
	A Distributed RoutePoilcy that leverages a Leader election coordinated by ZK to determine if exchanges should get processed.



Maven users will need to add the following dependency to their pom.xml for this component:


dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-zookeeper/artifactId
versionx.x.x/version
!-- use the same version as your Camel core version --
/dependency



URI format



zookeeper://zookeeper-server[:port][/path][?options]



The path from the uri specifies the node in the ZooKeeper server (aka znode) that will be the target of the endpoint.

Options



 Name 
 Default Value 
 Description 


 sessionId 
 null 
 The session id used to identify a connection to the cluster 


 password 
 NULL 
 The password to use when making a connection 


 awaitCreation 
 true 
 should the endpoint await the creation of a node that does not yet exist.


 listChildren 
 false 
 whether the children of the node should be listed


 repeat 
 false 
 should changes to the znode be 'watched' and repeatedly processed. 


 backoff 
 5000 
 the time interval to backoff for after an error before retrying.  


 timeout 
 5000 
 the time interval to wait on connection before timing out. 


 create 
 false 
 should the endpoint create the node if it does not currently exist. 


 createMode 
 EPHEMERAL 
 the create mode that should be used for the newly created node (see below). 





Use cases

Reading from a znode.

The following snippet will read the data from the znode '/somepath/somenode/' provided that it already exists. The data retrieved will
be placed into an exchange and passed onto the rest of the route.


from("direct:write-to-znode").to("zoo://localhost:39913/somepath/somenode");



if the node does not yet exist then a flag can be supplied to have the endpoint await its creation


from("direct:create-and-write-to-znode").to("zoo://localhost:39913/somepath/somenode?awaitCreation=true");



Writing to a znode.

the following snippet will write the payload of the exchange into the znode at '/somepath/somenode/' provided that it already exists 


from("direct:write-to-znode").to("zoo://localhost:39913/somepath/somenode");



For flexibility, the endpoint allows the target znode to be specified dynamically as a message header. If a header keyed by the string 'CamelZooKeeperNode' is present then the value of the header will be used as the path to the znode on the server. For instance using the same route definition above, the following code snippet will write the data not to '/somepath/somenode' but to the path from the header '/somepath/someothernode'



Exchange e = createExchangeWithBody(testPayload);
template.sendBodyAndHeader("direct:write-to-znode", e, "CamelZooKeeperNode", "/somepath/someothernode");



To also create the node if it does not exist the 'create' option should be used.  


from("direct:create-and-write-to-znode").to("zoo://localhost:39913/somepath/somenode?create=true");



ZooKeeper nodes can have different types; they can be 'Ephemeral' or 'Persistent' and 'Sequenced' or 'Unsequenced'. For further information of each type you can check here
By default endpoints will create unsequenced, ephemeral nodes, but the type can be easily manipulated via a uri config parameter or via a special message header. The values expected for the create mode are simply the names from the CreateMode enumeration


	PERSISTENT
	PERSISTENT_SEQUENTIAL
	EPHEMERAL
	EPHEMERAL_SEQUENTIAL



For example to create a persistent znode via the URI config



from("direct:create-and-write-to-persistent-znode").to("zoo://localhost:39913/somepath/somenode?create=truecreateMode=PERSISTENT");



or using the header 'CamelZookeeperCreateMode'



Exchange e = createExchangeWithBody(testPayload);
template.sendBodyAndHeader("direct:create-and-write-to-persistent-znode", e, "CamelZooKeeperCreateMode", "PERSISTENT");




ZooKeeper enabled Route policy.

ZooKeeper allows for very simple and effective leader election out of the box; This component exploits this election capability in a RoutePoilcy to control when and how routes are enabled. This policy would typically be used in fail-over scenarios, to control identical instances of a route across a cluster of Camel based servers. A very common scenarion is a simple 'Master-Slave' setup where there are multiple instances of a route distributed across a cluster but only one of them, that of the master, should be running at a time. If the master fails, a new master should 

[CONF] Apache Camel Zookeeper

2011-08-23 Thread confluence







Zookeeper
Page edited by Stephen Gargan


 Changes (8)
 




...
{code}  
ZooKeeper nodes can have different types; they can be Ephemeral or Persistent and Sequenced or Unsequenced. For further information of each type you can check [here|http://zookeeper.apache.org/doc/trunk/zookeeperProgrammers.html#Ephemeral+Nodes]. By default endpoints will create unsequenced, ephemeral nodes, but the type can be easily manipulated via a uri config parameter or via a special message header. The values expected for the create mode are simply the names from the CreateMode enumeration 
By default endpoints will create unsequenced, ephemeral nodes, but the type can be easily manipulated via a uri config parameter or via a special message header. The values expected for the create mode are simply the names from the CreateMode enumeration 
 
# - PERSISTENT 
# - PERSISTENT_SEQUENTIAL 
# - EPHEMERAL 
# - EPHEMERAL_SEQUENTIAL 
 For example to create a persistent znode via the URI config 
...
ZooKeeper allows for very simple and effective leader election out of the box; This component exploits this election capability in a RoutePoilcy to control when and how routes are enabled. This policy would typically be used in fail-over scenarios, to control identical instances of a route across a cluster of Camel based servers. A very common scenarion is a simple Master-Slave setup where there are multiple instances of a route distributed across a cluster but only one of them, that of the master, should be running at a time. If the master fails, a new master should be elected from the available slaves and the route in this new master should be started.  
The policy uses a common znode path across all instances of the RoutePolicy that will be involved in the election. Each policy writes its id into this node and zookeeper will order the writes in the order it received them. The policy then reads the listing of the node to see what postion of its id; this postion is used to determine if the route should be started or not. The policy is configured at starup with the number of route instances that should be started across the cluster and if its position in the list is less than this value then its route will be started. For a Master-slave scenario, the route is configured with 1 route instance and only the first entry in the listing will start its route. All policies watch for updates to the listing and if the listing changes they recaclulate if their route should be started. For more info on Zookeepers Leader election capability [see|http://zookeeper.apache.org/doc/trunk/recipes.html#sc_leaderElection] 
The policy then reads the listing of the node to see what postion of its id; this postion is used to determine if the route should be started or not. The policy is configured at starup with the number of route instances that should be started across the cluster and if its position in the list is less than this value then its route will be started. For a Master-slave scenario, the route is configured with 1 route instance and only the first entry in the listing will start its route. All policies watch for updates to the listing and if the listing changes they recaclulate if their route should be started. For more info on Zookeepers Leader election capability [see|http://zookeeper.apache.org/doc/trunk/recipes.html#sc_leaderElection]  
 The following example uses the node /someapplication/somepolicy for the election and is set up to start only the top 1 entries in the node listing i.e. elect a master 
...


Full Content

ZooKeeper Component
Available as of Camel 2.9

The ZooKeeper component to allow interaction with a ZooKeeper cluster (http://hadoop.apache.org/zookeeper/) and it exposes the following features to Camel.


	Creation of nodes in any of the ZooKeeper create modes.
	Get and Set the data contents of arbitrary cluster nodes.
	Create and retrieve the list the child nodes attached to a particular node.
	A Distributed RoutePoilcy that leverages a Leader election coordinated by ZK to determine if exchanges should get processed.



Maven users will need to add the following dependency to their pom.xml for this component:


dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-zookeeper/artifactId
versionx.x.x/version
!-- use the same version as your Camel core version --
/dependency



URI format



zookeeper://zookeeper-server[:port][/path][?options]



The path from the uri specifies the node in the ZooKeeper server (aka znode) that will be the target of the endpoint.

Options



 Name 
 Default Value 
 Description 


 sessionId 
 

[CONF] Apache Camel Zookeeper

2011-08-23 Thread confluence







Zookeeper
Page edited by Stephen Gargan


 Changes (1)
 




...
|| Name || Default Value || Description || | {{sessionId}} | {{null}} | The session id used to identify a connection to the cluster | 
| {{password}} | {{NULL}} {{null}} | The password to use when making a connection | 
| {{awaitCreation}} | {{true}} | should the endpoint await the creation of a node that does not yet exist.| | {{listChildren}} | {{false}} | whether the children of the node should be listed| 
...


Full Content

ZooKeeper Component
Available as of Camel 2.9

The ZooKeeper component to allow interaction with a ZooKeeper cluster (http://hadoop.apache.org/zookeeper/) and it exposes the following features to Camel.


	Creation of nodes in any of the ZooKeeper create modes.
	Get and Set the data contents of arbitrary cluster nodes.
	Create and retrieve the list the child nodes attached to a particular node.
	A Distributed RoutePoilcy that leverages a Leader election coordinated by ZK to determine if exchanges should get processed.



Maven users will need to add the following dependency to their pom.xml for this component:


dependency
groupIdorg.apache.camel/groupId
artifactIdcamel-zookeeper/artifactId
versionx.x.x/version
!-- use the same version as your Camel core version --
/dependency



URI format



zookeeper://zookeeper-server[:port][/path][?options]



The path from the uri specifies the node in the ZooKeeper server (aka znode) that will be the target of the endpoint.

Options



 Name 
 Default Value 
 Description 


 sessionId 
 null 
 The session id used to identify a connection to the cluster 


 password 
 null 
 The password to use when making a connection 


 awaitCreation 
 true 
 should the endpoint await the creation of a node that does not yet exist.


 listChildren 
 false 
 whether the children of the node should be listed


 repeat 
 false 
 should changes to the znode be 'watched' and repeatedly processed. 


 backoff 
 5000 
 the time interval to backoff for after an error before retrying.  


 timeout 
 5000 
 the time interval to wait on connection before timing out. 


 create 
 false 
 should the endpoint create the node if it does not currently exist. 


 createMode 
 EPHEMERAL 
 the create mode that should be used for the newly created node (see below). 





Use cases

Reading from a znode.

The following snippet will read the data from the znode '/somepath/somenode/' provided that it already exists. The data retrieved will
be placed into an exchange and passed onto the rest of the route.


from("direct:write-to-znode").to("zoo://localhost:39913/somepath/somenode");



if the node does not yet exist then a flag can be supplied to have the endpoint await its creation


from("direct:create-and-write-to-znode").to("zoo://localhost:39913/somepath/somenode?awaitCreation=true");



Writing to a znode.

the following snippet will write the payload of the exchange into the znode at '/somepath/somenode/' provided that it already exists 


from("direct:write-to-znode").to("zoo://localhost:39913/somepath/somenode");



For flexibility, the endpoint allows the target znode to be specified dynamically as a message header. If a header keyed by the string 'CamelZooKeeperNode' is present then the value of the header will be used as the path to the znode on the server. For instance using the same route definition above, the following code snippet will write the data not to '/somepath/somenode' but to the path from the header '/somepath/someothernode'



Exchange e = createExchangeWithBody(testPayload);
template.sendBodyAndHeader("direct:write-to-znode", e, "CamelZooKeeperNode", "/somepath/someothernode");



To also create the node if it does not exist the 'create' option should be used.  


from("direct:create-and-write-to-znode").to("zoo://localhost:39913/somepath/somenode?create=true");



ZooKeeper nodes can have different types; they can be 'Ephemeral' or 'Persistent' and 'Sequenced' or 'Unsequenced'. For further information of each type you can check here. By default endpoints will create unsequenced, ephemeral nodes, but the type can be easily manipulated via a uri config parameter or via a special message header. The values expected for the create mode are simply the names from the CreateMode enumeration


	PERSISTENT
	PERSISTENT_SEQUENTIAL
	EPHEMERAL
	EPHEMERAL_SEQUENTIAL



For example to create a persistent znode via the URI config



from("direct:create-and-write-to-persistent-znode").to("zoo://localhost:39913/somepath/somenode?create=truecreateMode=PERSISTENT");



or using the header 'CamelZookeeperCreateMode'



Exchange e = createExchangeWithBody(testPayload);