You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/01/22 15:29:41 UTC
[camel] branch master updated: camel3 - controlbus component should
use public camel-api
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 723870b camel3 - controlbus component should use public camel-api
723870b is described below
commit 723870bb17b239a1c2fb3c4f2056d69f3ade5f93
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jan 22 16:24:23 2019 +0100
camel3 - controlbus component should use public camel-api
---
.../component/controlbus/ControlBusProducer.java | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/camel-core/src/main/java/org/apache/camel/component/controlbus/ControlBusProducer.java b/camel-core/src/main/java/org/apache/camel/component/controlbus/ControlBusProducer.java
index 042cdc3..4723534 100644
--- a/camel-core/src/main/java/org/apache/camel/component/controlbus/ControlBusProducer.java
+++ b/camel-core/src/main/java/org/apache/camel/component/controlbus/ControlBusProducer.java
@@ -26,9 +26,10 @@ import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Route;
import org.apache.camel.ServiceStatus;
-import org.apache.camel.builder.ExpressionBuilder;
import org.apache.camel.spi.CamelLogger;
import org.apache.camel.spi.Language;
+import org.apache.camel.spi.RouteContext;
+import org.apache.camel.spi.UnitOfWork;
import org.apache.camel.support.DefaultAsyncProducer;
import org.apache.camel.support.ExchangeHelper;
import org.apache.camel.util.ObjectHelper;
@@ -37,7 +38,6 @@ import org.apache.camel.util.ObjectHelper;
* The control bus producer.
*/
public class ControlBusProducer extends DefaultAsyncProducer {
- private static final Expression ROUTE_ID_EXPRESSION = ExpressionBuilder.routeIdExpression();
private final CamelLogger logger;
@@ -89,6 +89,20 @@ public class ControlBusProducer extends DefaultAsyncProducer {
}
}
+ private static String getRouteId(Exchange exchange) {
+ String answer = null;
+ UnitOfWork uow = exchange.getUnitOfWork();
+ RouteContext rc = uow != null ? uow.getRouteContext() : null;
+ if (rc != null) {
+ answer = rc.getRoute().getId();
+ }
+ if (answer == null) {
+ // fallback and get from route id on the exchange
+ answer = exchange.getFromRouteId();
+ }
+ return answer;
+ }
+
/**
* Tasks to run when processing by language.
*/
@@ -148,7 +162,7 @@ public class ControlBusProducer extends DefaultAsyncProducer {
String id = getEndpoint().getRouteId();
if (ObjectHelper.equal("current", id)) {
- id = ROUTE_ID_EXPRESSION.evaluate(exchange, String.class);
+ id = getRouteId(exchange);
}
Object result = null;
@@ -224,6 +238,7 @@ public class ControlBusProducer extends DefaultAsyncProducer {
logger.log("Error executing ControlBus task [" + task + "]. This exception will be ignored.", e);
}
}
+
}
}