camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/3] git commit: camel-beanstalk store details in headers instead of exchange.
Date Sun, 21 Sep 2014 09:06:39 GMT
Repository: camel
Updated Branches:
  refs/heads/master 4233318d9 -> 4976ca964


camel-beanstalk store details in headers instead of exchange.


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

Branch: refs/heads/master
Commit: 441311d3a585161c0c1d14ecc59fec3275ff7087
Parents: 4233318
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sun Sep 21 10:40:20 2014 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sun Sep 21 10:41:04 2014 +0200

----------------------------------------------------------------------
 .../camel/component/beanstalk/BeanstalkConsumer.java      | 10 +++++-----
 .../component/beanstalk/BeanstalkExchangeHelper.java      |  4 ----
 .../camel/component/beanstalk/AwaitingConsumerTest.java   |  4 ++--
 .../camel/component/beanstalk/ConsumerCompletionTest.java |  4 ++--
 .../camel/component/beanstalk/ImmediateConsumerTest.java  |  2 +-
 .../beanstalk/integration/ConsumerIntegrationTest.java    |  2 +-
 6 files changed, 11 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/441311d3/components/camel-beanstalk/src/main/java/org/apache/camel/component/beanstalk/BeanstalkConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-beanstalk/src/main/java/org/apache/camel/component/beanstalk/BeanstalkConsumer.java
b/components/camel-beanstalk/src/main/java/org/apache/camel/component/beanstalk/BeanstalkConsumer.java
index ac0e058..b55050f 100644
--- a/components/camel-beanstalk/src/main/java/org/apache/camel/component/beanstalk/BeanstalkConsumer.java
+++ b/components/camel-beanstalk/src/main/java/org/apache/camel/component/beanstalk/BeanstalkConsumer.java
@@ -91,24 +91,24 @@ public class BeanstalkConsumer extends ScheduledPollConsumer {
                 }
 
                 final Exchange exchange = getEndpoint().createExchange(ExchangePattern.InOnly);
-                exchange.setProperty(Headers.JOB_ID, job.getJobId());
+                exchange.getIn().setHeader(Headers.JOB_ID, job.getJobId());
                 exchange.getIn().setBody(job.getData(), byte[].class);
 
                 Map<String, String> jobStats = client.statsJob(job.getJobId());
-                if (jobStats != null) {
+                if (jobStats != null && !jobStats.isEmpty()) {
                     for (String key : STATS_KEY_STR) {
                         if (jobStats.containsKey(key)) {
-                            exchange.setProperty(Headers.PREFIX + key, jobStats.get(key).trim());
+                            exchange.getIn().setHeader(Headers.PREFIX + key, jobStats.get(key).trim());
                         }
                     }
 
                     if (jobStats.containsKey("pri")) {
-                        exchange.setProperty(Headers.PRIORITY, Long.parseLong(jobStats.get("pri").trim()));
+                        exchange.getIn().setHeader(Headers.PRIORITY, Long.parseLong(jobStats.get("pri").trim()));
                     }
 
                     for (String key : STATS_KEY_INT) {
                         if (jobStats.containsKey(key)) {
-                            exchange.setProperty(Headers.PREFIX + key, Integer.parseInt(jobStats.get(key).trim()));
+                            exchange.getIn().setHeader(Headers.PREFIX + key, Integer.parseInt(jobStats.get(key).trim()));
                         }
                     }
                 }

http://git-wip-us.apache.org/repos/asf/camel/blob/441311d3/components/camel-beanstalk/src/main/java/org/apache/camel/component/beanstalk/BeanstalkExchangeHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-beanstalk/src/main/java/org/apache/camel/component/beanstalk/BeanstalkExchangeHelper.java
b/components/camel-beanstalk/src/main/java/org/apache/camel/component/beanstalk/BeanstalkExchangeHelper.java
index 9e39369..59177b9 100644
--- a/components/camel-beanstalk/src/main/java/org/apache/camel/component/beanstalk/BeanstalkExchangeHelper.java
+++ b/components/camel-beanstalk/src/main/java/org/apache/camel/component/beanstalk/BeanstalkExchangeHelper.java
@@ -39,10 +39,6 @@ public final class BeanstalkExchangeHelper {
     }
 
     public static long getJobID(final Exchange exchange) throws NoSuchHeaderException {
-        Long jobId = exchange.getProperty(Headers.JOB_ID, Long.class);
-        if (jobId != null) {
-            return jobId;
-        }
         return ExchangeHelper.getMandatoryHeader(exchange, Headers.JOB_ID, Long.class);
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/441311d3/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/AwaitingConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/AwaitingConsumerTest.java
b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/AwaitingConsumerTest.java
index ebef336..fa75a17 100644
--- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/AwaitingConsumerTest.java
+++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/AwaitingConsumerTest.java
@@ -52,7 +52,7 @@ public class AwaitingConsumerTest extends BeanstalkMockTestSupport {
         MockEndpoint result = getMockEndpoint("mock:result");
         result.expectedMessageCount(1);
         result.expectedBodiesReceived(testMessage);
-        result.expectedPropertyReceived(Headers.JOB_ID, jobId);
+        result.expectedHeaderReceived(Headers.JOB_ID, jobId);
         result.message(0).header(Headers.JOB_ID).isEqualTo(jobId);
         result.assertIsSatisfied(100);
 
@@ -75,7 +75,7 @@ public class AwaitingConsumerTest extends BeanstalkMockTestSupport {
         MockEndpoint result = getMockEndpoint("mock:result");
         result.expectedMessageCount(1);
         result.expectedBodiesReceived(testMessage);
-        result.expectedPropertyReceived(Headers.JOB_ID, jobId);
+        result.expectedHeaderReceived(Headers.JOB_ID, jobId);
         result.message(0).header(Headers.JOB_ID).isEqualTo(jobId);
         result.assertIsSatisfied(100);
 

http://git-wip-us.apache.org/repos/asf/camel/blob/441311d3/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConsumerCompletionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConsumerCompletionTest.java
b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConsumerCompletionTest.java
index 4d0a863..0ed59c1 100644
--- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConsumerCompletionTest.java
+++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ConsumerCompletionTest.java
@@ -59,7 +59,7 @@ public class ConsumerCompletionTest extends BeanstalkMockTestSupport {
         MockEndpoint result = getMockEndpoint("mock:result");
         result.expectedMinimumMessageCount(1);
         result.expectedBodiesReceived(testMessage);
-        result.expectedPropertyReceived(Headers.JOB_ID, jobId);
+        result.expectedHeaderReceived(Headers.JOB_ID, jobId);
         result.message(0).header(Headers.JOB_ID).isEqualTo(jobId);
         result.assertIsSatisfied(2000);
 
@@ -106,7 +106,7 @@ public class ConsumerCompletionTest extends BeanstalkMockTestSupport {
         MockEndpoint result = getMockEndpoint("mock:result");
         result.expectedMessageCount(1);
         result.expectedBodiesReceived(testMessage);
-        result.expectedPropertyReceived(Headers.JOB_ID, jobId);
+        result.expectedHeaderReceived(Headers.JOB_ID, jobId);
         result.message(0).header(Headers.JOB_ID).isEqualTo(jobId);
         result.assertIsSatisfied(100);
 

http://git-wip-us.apache.org/repos/asf/camel/blob/441311d3/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ImmediateConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ImmediateConsumerTest.java
b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ImmediateConsumerTest.java
index eb24dd2..3d3248e 100644
--- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ImmediateConsumerTest.java
+++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/ImmediateConsumerTest.java
@@ -58,7 +58,7 @@ public class ImmediateConsumerTest extends BeanstalkMockTestSupport {
         MockEndpoint result = getMockEndpoint("mock:result");
         result.expectedMessageCount(1);
         result.expectedBodiesReceived(testMessage);
-        result.expectedPropertyReceived(Headers.JOB_ID, jobId);
+        result.expectedHeaderReceived(Headers.JOB_ID, jobId);
         result.message(0).header(Headers.JOB_ID).isEqualTo(jobId);
         result.assertIsSatisfied(100);
 

http://git-wip-us.apache.org/repos/asf/camel/blob/441311d3/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/ConsumerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/ConsumerIntegrationTest.java
b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/ConsumerIntegrationTest.java
index c0f37df..764e6b0 100644
--- a/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/ConsumerIntegrationTest.java
+++ b/components/camel-beanstalk/src/test/java/org/apache/camel/component/beanstalk/integration/ConsumerIntegrationTest.java
@@ -39,7 +39,7 @@ public class ConsumerIntegrationTest extends BeanstalkCamelTestSupport {
         final long jobId = writer.put(prio, 0, ttr, Helper.stringToBytes(testMessage));
 
         result.expectedMessageCount(1);
-        result.expectedPropertyReceived(Headers.JOB_ID, jobId);
+        result.expectedHeaderReceived(Headers.JOB_ID, jobId);
         result.message(0).header(Exchange.CREATED_TIMESTAMP).isNotNull();
         result.message(0).header(Headers.JOB_ID).isEqualTo(jobId);
         result.message(0).header(Headers.PRIORITY).isEqualTo(prio);


Mime
View raw message