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 2016/06/06 10:14:07 UTC
[1/2] camel git commit: CAMEL-10022: camel-spring-boot health
indicator.
Repository: camel
Updated Branches:
refs/heads/master e4275a462 -> 9fcd94a2f
CAMEL-10022: camel-spring-boot health indicator.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9fcd94a2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9fcd94a2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9fcd94a2
Branch: refs/heads/master
Commit: 9fcd94a2f54232381c317464326a261ee991b3cd
Parents: 970f585
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Jun 6 12:00:47 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Jun 6 12:13:58 2016 +0200
----------------------------------------------------------------------
components/camel-spring-boot/pom.xml | 6 +++
.../health/CamelHealthAutoConfiguration.java | 38 ++++++++++++++
.../boot/health/CamelHealthIndicator.java | 53 +++++++++++++++++++
.../main/resources/META-INF/spring.factories | 3 +-
.../spring/boot/health/CamelHealthTest.java | 55 ++++++++++++++++++++
.../camel/spring/boot/health/MyCamelRoute.java | 29 +++++++++++
6 files changed, 183 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/9fcd94a2/components/camel-spring-boot/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/pom.xml b/components/camel-spring-boot/pom.xml
index 1e7515e..c8e2fb0 100644
--- a/components/camel-spring-boot/pom.xml
+++ b/components/camel-spring-boot/pom.xml
@@ -46,6 +46,12 @@
<optional>true</optional>
<version>${spring-boot-version}</version>
</dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-actuator</artifactId>
+ <optional>true</optional>
+ <version>${spring-boot-version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
http://git-wip-us.apache.org/repos/asf/camel/blob/9fcd94a2/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/CamelHealthAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/CamelHealthAutoConfiguration.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/CamelHealthAutoConfiguration.java
new file mode 100644
index 0000000..772ced1
--- /dev/null
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/CamelHealthAutoConfiguration.java
@@ -0,0 +1,38 @@
+/**
+ * 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.spring.boot.health;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.springframework.boot.actuate.health.HealthIndicator;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@AutoConfigureAfter(CamelAutoConfiguration.class)
+public class CamelHealthAutoConfiguration {
+
+ @Bean
+ @ConditionalOnClass({CamelContext.class})
+ @ConditionalOnMissingBean(CamelHealthIndicator.class)
+ public HealthIndicator camelHealthIndicator(CamelContext camelContext) {
+ return new CamelHealthIndicator(camelContext);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/9fcd94a2/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/CamelHealthIndicator.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/CamelHealthIndicator.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/CamelHealthIndicator.java
new file mode 100644
index 0000000..eb02115
--- /dev/null
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/health/CamelHealthIndicator.java
@@ -0,0 +1,53 @@
+/**
+ * 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.spring.boot.health;
+
+import org.apache.camel.CamelContext;
+import org.springframework.boot.actuate.health.AbstractHealthIndicator;
+import org.springframework.boot.actuate.health.Health;
+import org.springframework.boot.actuate.health.HealthIndicator;
+import org.springframework.stereotype.Component;
+
+/**
+ * Camel {@link HealthIndicator}.
+ */
+@Component
+public class CamelHealthIndicator extends AbstractHealthIndicator {
+
+ private CamelContext camelContext;
+
+ public CamelHealthIndicator(CamelContext camelContext) {
+ this.camelContext = camelContext;
+ }
+
+ @Override
+ protected void doHealthCheck(Health.Builder builder) throws Exception {
+ if (camelContext == null) {
+ builder.unknown();
+ } else {
+ builder.withDetail("version", camelContext.getVersion());
+ builder.withDetail("contextStatus", camelContext.getStatus().name());
+ if (camelContext.getStatus().isStarted()) {
+ builder.up();
+ } else if (camelContext.getStatus().isStopped()) {
+ builder.down();
+ } else {
+ builder.unknown();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/9fcd94a2/components/camel-spring-boot/src/main/resources/META-INF/spring.factories
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/resources/META-INF/spring.factories b/components/camel-spring-boot/src/main/resources/META-INF/spring.factories
index 58bee94..05fc73e 100644
--- a/components/camel-spring-boot/src/main/resources/META-INF/spring.factories
+++ b/components/camel-spring-boot/src/main/resources/META-INF/spring.factories
@@ -16,4 +16,5 @@
#
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-org.apache.camel.spring.boot.CamelAutoConfiguration
\ No newline at end of file
+org.apache.camel.spring.boot.CamelAutoConfiguration,\
+org.apache.camel.spring.boot.health.CamelHealthAutoConfiguration
http://git-wip-us.apache.org/repos/asf/camel/blob/9fcd94a2/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/health/CamelHealthTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/health/CamelHealthTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/health/CamelHealthTest.java
new file mode 100644
index 0000000..f356ee6
--- /dev/null
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/health/CamelHealthTest.java
@@ -0,0 +1,55 @@
+/**
+ * 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.spring.boot.health;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.actuate.health.Health;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.test.SpringApplicationConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@EnableAutoConfiguration
+@SpringBootApplication
+@SpringApplicationConfiguration(classes = {CamelAutoConfiguration.class, CamelHealthAutoConfiguration.class, MyCamelRoute.class})
+public class CamelHealthTest extends Assert {
+
+ @Autowired
+ CamelHealthIndicator indicator;
+
+ @Autowired
+ CamelContext camelContext;
+
+ @Test
+ public void shouldHaveHealth() throws Exception {
+ Health health = indicator.health();
+ assertNotNull(health);
+
+ String code = health.getStatus().getCode();
+ assertEquals("UP", code);
+
+ String version = (String) health.getDetails().get("version");
+ assertEquals(camelContext.getVersion(), version);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/9fcd94a2/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/health/MyCamelRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/health/MyCamelRoute.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/health/MyCamelRoute.java
new file mode 100644
index 0000000..2bdd6d2
--- /dev/null
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/health/MyCamelRoute.java
@@ -0,0 +1,29 @@
+/**
+ * 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.spring.boot.health;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.stereotype.Component;
+
+@Component
+public class MyCamelRoute extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("timer:foo").to("log:foo");
+ }
+}
[2/2] camel git commit: camel-pdf should propagate
headers/attachments so they are not lost.
Posted by da...@apache.org.
camel-pdf should propagate headers/attachments so they are not lost.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/970f5853
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/970f5853
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/970f5853
Branch: refs/heads/master
Commit: 970f5853745234f5619d6660d7f107b462b1d69f
Parents: e4275a4
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Jun 6 11:22:48 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Jun 6 12:13:58 2016 +0200
----------------------------------------------------------------------
.../main/java/org/apache/camel/component/pdf/PdfProducer.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/970f5853/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/PdfProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/PdfProducer.java b/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/PdfProducer.java
index 72ef67d..be60aff 100644
--- a/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/PdfProducer.java
+++ b/components/camel-pdf/src/main/java/org/apache/camel/component/pdf/PdfProducer.java
@@ -76,6 +76,10 @@ public class PdfProducer extends DefaultProducer {
default:
throw new IllegalArgumentException(String.format("Unknown operation %s", pdfConfiguration.getOperation()));
}
+ // propagate headers
+ exchange.getOut().setHeaders(exchange.getIn().getHeaders());
+ exchange.getOut().setAttachments(exchange.getIn().getAttachments());
+ // and set result
exchange.getOut().setBody(result);
}