You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/10/29 18:00:55 UTC
[camel-spring-boot-examples] 02/02: Added License and changed
packages
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot-examples.git
commit 0ab42abc4131a58e44fc10c5c8103d3a6d12cde6
Author: Farid Guliyev <fg...@gmail.com>
AuthorDate: Tue Oct 27 11:28:35 2020 -0400
Added License and changed packages
---
.../README.adoc | 2 +-
.../camel/springboot/example}/Application.java | 2 +-
.../springboot/example/CustomLoadBalancer.java} | 32 ++++++++++++++--------
.../springboot/example}/LoadBalancerEIPRouter.java | 18 +++++++++++-
.../camel/springboot/example/MyException.java} | 16 +++++------
.../main/java/sample/camel/CustomLoadBalancer.java | 23 ----------------
.../src/main/java/sample/camel/MyException.java | 11 --------
.../springboot/example}/LoadBalancerEIPTest.java | 19 +++++++++++--
8 files changed, 64 insertions(+), 59 deletions(-)
diff --git a/camel-example-spring-boot-load-balancer-eip/README.adoc b/camel-example-spring-boot-load-balancer-eip/README.adoc
index ad02800..867fd32 100644
--- a/camel-example-spring-boot-load-balancer-eip/README.adoc
+++ b/camel-example-spring-boot-load-balancer-eip/README.adoc
@@ -2,7 +2,7 @@
This example shows several examples of Load Balancer EIP with Apache Camel application using Spring Boot.
-1. Round-robin - The exchanges are selected from in a round robin fashion. This is a well known and classic policy, which spreads the load evenly.
+1. Round-robin - The exchanges are selected in a round robin fashion. This is a well known and classic policy, which spreads the load evenly.
2. Random load - A random endpoint is selected for each exchange.
3. Sticky - Sticky load balancing using an Expression to calculate a correlation key to perform the sticky load balancing; rather like jsessionid in the web or JMSXGroupID in JMS.
4. Topic - Topic which sends to all destinations (rather like JMS Topics)
diff --git a/camel-example-spring-boot-load-balancer-eip/src/main/java/sample/camel/Application.java b/camel-example-spring-boot-load-balancer-eip/src/main/java/org/apache/camel/springboot/example/Application.java
similarity index 96%
copy from camel-example-spring-boot-load-balancer-eip/src/main/java/sample/camel/Application.java
copy to camel-example-spring-boot-load-balancer-eip/src/main/java/org/apache/camel/springboot/example/Application.java
index 4eeaa6d..c13be12 100644
--- a/camel-example-spring-boot-load-balancer-eip/src/main/java/sample/camel/Application.java
+++ b/camel-example-spring-boot-load-balancer-eip/src/main/java/org/apache/camel/springboot/example/Application.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package sample.camel;
+package org.apache.camel.springboot.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
diff --git a/camel-example-spring-boot-load-balancer-eip/src/main/java/sample/camel/Application.java b/camel-example-spring-boot-load-balancer-eip/src/main/java/org/apache/camel/springboot/example/CustomLoadBalancer.java
similarity index 55%
copy from camel-example-spring-boot-load-balancer-eip/src/main/java/sample/camel/Application.java
copy to camel-example-spring-boot-load-balancer-eip/src/main/java/org/apache/camel/springboot/example/CustomLoadBalancer.java
index 4eeaa6d..b19598f 100644
--- a/camel-example-spring-boot-load-balancer-eip/src/main/java/sample/camel/Application.java
+++ b/camel-example-spring-boot-load-balancer-eip/src/main/java/org/apache/camel/springboot/example/CustomLoadBalancer.java
@@ -14,16 +14,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package sample.camel;
+package org.apache.camel.springboot.example;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.apache.camel.AsyncCallback;
+import org.apache.camel.Exchange;
+import org.apache.camel.processor.loadbalancer.LoadBalancerSupport;
-@SpringBootApplication
-public class Application {
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-
-}
+public class CustomLoadBalancer extends LoadBalancerSupport {
+ @Override
+ public boolean process(Exchange exchange, AsyncCallback callback) {
+ String body = exchange.getIn().getBody(String.class);
+ try {
+ if ("AE".contains(body)){
+ getProcessors().get(0).process(exchange);
+ } else if ("BCD".contains(body))
+ getProcessors().get(1).process(exchange);
+ }
+ catch (Exception e) {
+ exchange.setException(e);
+ }
+ callback.done(true);
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/camel-example-spring-boot-load-balancer-eip/src/main/java/sample/camel/LoadBalancerEIPRouter.java b/camel-example-spring-boot-load-balancer-eip/src/main/java/org/apache/camel/springboot/example/LoadBalancerEIPRouter.java
similarity index 76%
rename from camel-example-spring-boot-load-balancer-eip/src/main/java/sample/camel/LoadBalancerEIPRouter.java
rename to camel-example-spring-boot-load-balancer-eip/src/main/java/org/apache/camel/springboot/example/LoadBalancerEIPRouter.java
index a8d7cb2..b9dfeb4 100644
--- a/camel-example-spring-boot-load-balancer-eip/src/main/java/sample/camel/LoadBalancerEIPRouter.java
+++ b/camel-example-spring-boot-load-balancer-eip/src/main/java/org/apache/camel/springboot/example/LoadBalancerEIPRouter.java
@@ -1,4 +1,20 @@
-package sample.camel;
+/*
+ * 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.springboot.example;
import org.apache.camel.builder.RouteBuilder;
diff --git a/camel-example-spring-boot-load-balancer-eip/src/main/java/sample/camel/Application.java b/camel-example-spring-boot-load-balancer-eip/src/main/java/org/apache/camel/springboot/example/MyException.java
similarity index 72%
rename from camel-example-spring-boot-load-balancer-eip/src/main/java/sample/camel/Application.java
rename to camel-example-spring-boot-load-balancer-eip/src/main/java/org/apache/camel/springboot/example/MyException.java
index 4eeaa6d..0b71bfe 100644
--- a/camel-example-spring-boot-load-balancer-eip/src/main/java/sample/camel/Application.java
+++ b/camel-example-spring-boot-load-balancer-eip/src/main/java/org/apache/camel/springboot/example/MyException.java
@@ -14,16 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package sample.camel;
+package org.apache.camel.springboot.example;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
+public class MyException extends RuntimeException {
-@SpringBootApplication
-public class Application {
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
+ MyException() {
+ }
+ MyException(String message) {
+ super(message);
+ }
}
diff --git a/camel-example-spring-boot-load-balancer-eip/src/main/java/sample/camel/CustomLoadBalancer.java b/camel-example-spring-boot-load-balancer-eip/src/main/java/sample/camel/CustomLoadBalancer.java
deleted file mode 100644
index 90229ec..0000000
--- a/camel-example-spring-boot-load-balancer-eip/src/main/java/sample/camel/CustomLoadBalancer.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package sample.camel;
-
-import org.apache.camel.AsyncCallback;
-import org.apache.camel.Exchange;
-import org.apache.camel.processor.loadbalancer.LoadBalancerSupport;
-
-public class CustomLoadBalancer extends LoadBalancerSupport {
- @Override
- public boolean process(Exchange exchange, AsyncCallback callback) {
- String body = exchange.getIn().getBody(String.class);
- try {
- if ("AE".contains(body)){
- getProcessors().get(0).process(exchange);
- } else if ("BCD".contains(body))
- getProcessors().get(1).process(exchange);
- }
- catch (Exception e) {
- exchange.setException(e);
- }
- callback.done(true);
- return true;
- }
-}
\ No newline at end of file
diff --git a/camel-example-spring-boot-load-balancer-eip/src/main/java/sample/camel/MyException.java b/camel-example-spring-boot-load-balancer-eip/src/main/java/sample/camel/MyException.java
deleted file mode 100644
index bb6f94f..0000000
--- a/camel-example-spring-boot-load-balancer-eip/src/main/java/sample/camel/MyException.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package sample.camel;
-
-public class MyException extends RuntimeException {
-
- MyException() {
- }
-
- MyException(String message) {
- super(message);
- }
-}
diff --git a/camel-example-spring-boot-load-balancer-eip/src/test/java/LoadBalancerEIPTest.java b/camel-example-spring-boot-load-balancer-eip/src/test/java/org/apache/camel/springboot/example/LoadBalancerEIPTest.java
similarity index 89%
rename from camel-example-spring-boot-load-balancer-eip/src/test/java/LoadBalancerEIPTest.java
rename to camel-example-spring-boot-load-balancer-eip/src/test/java/org/apache/camel/springboot/example/LoadBalancerEIPTest.java
index a998dff..541a869 100644
--- a/camel-example-spring-boot-load-balancer-eip/src/test/java/LoadBalancerEIPTest.java
+++ b/camel-example-spring-boot-load-balancer-eip/src/test/java/org/apache/camel/springboot/example/LoadBalancerEIPTest.java
@@ -1,4 +1,20 @@
-package com.fg7;
+/*
+ * 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.springboot.example;
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
@@ -6,7 +22,6 @@ import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import sample.camel.Application;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;