camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [camel-k] 01/01: feat(examples): Add a Camel-caffeine Cache java sample
Date Wed, 19 Sep 2018 10:20:57 GMT
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch caffeine-sample
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 20a4821a3aa7547353ef82651cf01f27b2a935fd
Author: Andrea Cosentino <ancosen@gmail.com>
AuthorDate: Wed Sep 19 12:19:53 2018 +0200

    feat(examples): Add a Camel-caffeine Cache java sample
---
 runtime/examples/CaffeineCacheSample.java | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/runtime/examples/CaffeineCacheSample.java b/runtime/examples/CaffeineCacheSample.java
new file mode 100644
index 0000000..b417858
--- /dev/null
+++ b/runtime/examples/CaffeineCacheSample.java
@@ -0,0 +1,27 @@
+import org.apache.camel.builder.RouteBuilder;
+
+public class CaffeineCacheSample extends RouteBuilder {
+  @Override
+  public void configure() throws Exception {
+                from("timer:tick")
+                    .setBody(constant("Hello"))
+                    .setHeader("CamelCaffeineAction", constant("PUT"))
+                    .setHeader("CamelCaffeineKey", constant("1"))
+                    .toF("caffeine-cache://%s", "test")
+                    .log("Result of Action ${header.CamelCaffeineAction} with key ${header.CamelCaffeineKey}
is: ${body}")
+                    .setBody(constant(null))
+                    .setHeader("CamelCaffeineAction", constant("GET"))
+                    .setHeader("CamelCaffeineKey", constant("1"))
+                    .toF("caffeine-cache://%s", "test")
+                    .log("Result of Action ${header.CamelCaffeineAction} with key ${header.CamelCaffeineKey}
is: ${body}")
+                    .setBody(constant(null))
+                    .setHeader("CamelCaffeineAction", constant("INVALIDATE"))
+                    .setHeader("CamelCaffeineKey", constant("1"))
+                    .log("Invalidating entry with key ${header.CamelCaffeineKey}")
+                    .toF("caffeine-cache://%s", "test")
+                    .setHeader("CamelCaffeineAction", constant("GET"))
+                    .setHeader("CamelCaffeineKey", constant("1"))
+                    .toF("caffeine-cache://%s", "test")
+                    .log("The Action ${header.CamelCaffeineAction} with key ${header.CamelCaffeineKey}
has result? ${header.CamelCaffeineActionHasResult}");
+  }
+}


Mime
View raw message