Repository: camel Updated Branches: refs/heads/master 952ae9646 -> 634c4d77c
Fixed CS Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/634c4d77 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/634c4d77 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/634c4d77 Branch: refs/heads/master Commit: 634c4d77c3c3b536e1907f6688437cd122b83625 Parents: 054515d Author: Claus Ibsen <davscl...@apache.org> Authored: Wed Feb 8 10:40:26 2017 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed Feb 8 10:40:53 2017 +0100 ---------------------------------------------------------------------- .../camel-example-loan-broker-cxf/README.md | 2 +- examples/camel-example-loan-broker-cxf/pom.xml | 6 +- .../BankResponseAggregationStrategy.java | 2 +- .../org/apache/camel/loanbroker/Client.java | 6 +- .../camel/loanbroker/CreditScoreProcessor.java | 2 +- .../apache/camel/loanbroker/ReplyProcessor.java | 4 +- .../org/apache/camel/loanbroker/bank/Bank.java | 2 +- .../camel/loanbroker/credit/CreditAgency.java | 4 +- .../META-INF/spring/webServiceCamelContext.xml | 17 +++-- .../src/main/resources/features.xml | 42 +++++++----- .../src/main/resources/log4j2.properties | 13 ++-- .../src/main/resources/logging.properties | 24 ++----- .../camel/loanbroker/LoanBrokerWSTest.java | 8 +-- .../src/test/resources/log4j2.properties | 23 +++---- .../camel-example-loan-broker-jms/README.md | 2 +- .../org/apache/camel/loanbroker/Client.java | 4 +- .../org/apache/camel/loanbroker/LoanBroker.java | 26 +++---- .../camel/loanbroker/LoanBrokerRoute.java | 18 ++--- .../camel/loanbroker/bank/BankProcessor.java | 2 +- .../main/resources/META-INF/spring/client.xml | 54 ++++++++------- .../main/resources/META-INF/spring/server.xml | 72 ++++++++++---------- .../camel/loanbroker/LoanBrokerQueueTest.java | 67 +++++++++--------- .../src/test/resources/log4j2.properties | 23 +++---- .../mention/TwitterSalesforceApplication.java | 2 + 24 files changed, 209 insertions(+), 216 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-cxf/README.md ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-cxf/README.md b/examples/camel-example-loan-broker-cxf/README.md index ed5366e..6ca423b 100644 --- a/examples/camel-example-loan-broker-cxf/README.md +++ b/examples/camel-example-loan-broker-cxf/README.md @@ -1,4 +1,4 @@ -# Loan Broker Example +# Loan Broker Example with Apache CXF ### Introduction This example shows how to use Camel to implement the EIP's loan broker example, http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-cxf/pom.xml ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-cxf/pom.xml b/examples/camel-example-loan-broker-cxf/pom.xml index 121f97f..662a676 100644 --- a/examples/camel-example-loan-broker-cxf/pom.xml +++ b/examples/camel-example-loan-broker-cxf/pom.xml @@ -58,7 +58,7 @@ <artifactId>cxf-rt-transports-http-jetty</artifactId> <version>${cxf-version}</version> </dependency> - + <dependency> <groupId>org.apache.xbean</groupId> <artifactId>xbean-spring</artifactId> @@ -69,7 +69,7 @@ </exclusion> </exclusions> </dependency> - + <!-- logging --> <dependency> <groupId>org.apache.logging.log4j</groupId> @@ -155,7 +155,7 @@ </build> <profiles> - <profile> + <profile> <id>WS.LoanBroker</id> <properties> <target.main.class>org.apache.camel.loanbroker.LoanBroker</target.main.class> http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/BankResponseAggregationStrategy.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/BankResponseAggregationStrategy.java b/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/BankResponseAggregationStrategy.java index f4805bc..2ee0260 100644 --- a/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/BankResponseAggregationStrategy.java +++ b/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/BankResponseAggregationStrategy.java @@ -21,7 +21,7 @@ import org.apache.camel.loanbroker.bank.BankQuote; //START SNIPPET: aggregating // This POJO aggregator is supported since Camel 2.12 public class BankResponseAggregationStrategy { - + public BankQuote aggregate(BankQuote oldQuote, BankQuote newQuote) { if (oldQuote != null && oldQuote.getRate() <= newQuote.getRate()) { return oldQuote; http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/Client.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/Client.java b/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/Client.java index ccaf369..c760372 100644 --- a/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/Client.java +++ b/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/Client.java @@ -26,9 +26,9 @@ import org.apache.cxf.frontend.ClientProxyFactoryBean; */ //START SNIPPET: client public final class Client { - - //Change the port to the one on which Loan broker is listening. - + + //Change the port to the one on which Loan broker is listening. + private static String url = "http://localhost:9008/loanBroker"; private Client() { http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/CreditScoreProcessor.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/CreditScoreProcessor.java b/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/CreditScoreProcessor.java index 0296357..9794cdb 100644 --- a/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/CreditScoreProcessor.java +++ b/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/CreditScoreProcessor.java @@ -46,7 +46,7 @@ public class CreditScoreProcessor implements Processor { clientBean.setAddress(creditAgencyAddress); clientBean.setServiceClass(CreditAgencyWS.class); clientBean.setBus(BusFactory.getDefaultBus()); - return (CreditAgencyWS)proxyFactory.create(); + return (CreditAgencyWS) proxyFactory.create(); } @SuppressWarnings("unchecked") http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/ReplyProcessor.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/ReplyProcessor.java b/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/ReplyProcessor.java index 231f28d..e6be083 100644 --- a/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/ReplyProcessor.java +++ b/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/ReplyProcessor.java @@ -24,11 +24,11 @@ import org.apache.camel.loanbroker.bank.BankQuote; * Processor to set the reply message for the loan broker web service */ public class ReplyProcessor implements Processor { - + @Override public void process(Exchange exchange) throws Exception { BankQuote quote = exchange.getIn().getBody(BankQuote.class); - + String answer = "The best rate is " + quote.toString(); exchange.getOut().setBody(answer); } http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/bank/Bank.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/bank/Bank.java b/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/bank/Bank.java index 13151e1..7c499ba 100644 --- a/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/bank/Bank.java +++ b/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/bank/Bank.java @@ -31,7 +31,7 @@ public class Bank implements BankWS { } public BankQuote getQuote(String ssn, double loanAmount, int loanDuration, int creditHistory, int creditScore) { - Double rate = primeRate + (double)(loanDuration / 12) / 10 + Math.random() * 10 / 10; + Double rate = primeRate + (double) (loanDuration / 12) / 10 + Math.random() * 10 / 10; // Wait for a while try { Thread.sleep(1000); http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/credit/CreditAgency.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/credit/CreditAgency.java b/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/credit/CreditAgency.java index 93a531a..bedb24d 100644 --- a/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/credit/CreditAgency.java +++ b/examples/camel-example-loan-broker-cxf/src/main/java/org/apache/camel/loanbroker/credit/CreditAgency.java @@ -20,12 +20,12 @@ package org.apache.camel.loanbroker.credit; public class CreditAgency implements CreditAgencyWS { public int getCreditHistoryLength(String ssn) { - int creditScore = (int)(Math.random() * 600 + 300); + int creditScore = (int) (Math.random() * 600 + 300); return creditScore; } public int getCreditScore(String ssn) { - int creditHistoryLength = (int)(Math.random() * 19 + 1); + int creditHistoryLength = (int) (Math.random() * 19 + 1); return creditHistoryLength; } http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-cxf/src/main/resources/META-INF/spring/webServiceCamelContext.xml ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-cxf/src/main/resources/META-INF/spring/webServiceCamelContext.xml b/examples/camel-example-loan-broker-cxf/src/main/resources/META-INF/spring/webServiceCamelContext.xml index 5e1cf06..5373601 100644 --- a/examples/camel-example-loan-broker-cxf/src/main/resources/META-INF/spring/webServiceCamelContext.xml +++ b/examples/camel-example-loan-broker-cxf/src/main/resources/META-INF/spring/webServiceCamelContext.xml @@ -68,8 +68,8 @@ <jaxws:endpoint id="bankService3" implementor="#bank3" address="http://localhost:${bank3.port}/bank3"/> - - + + <!-- loan broker web service --> <cxf:cxfEndpoint id="loanBroker" address="http://localhost:${loan_broker.port}/loanBroker" @@ -79,9 +79,12 @@ <camel:camelContext id="webService"> <!-- define endpoints for the banks --> - <camel:endpoint id="bank1WS" uri="cxf://http://localhost:${bank1.port}/bank1?serviceClass=org.apache.camel.loanbroker.bank.BankWS"/> - <camel:endpoint id="bank2WS" uri="cxf://http://localhost:${bank2.port}/bank2?serviceClass=org.apache.camel.loanbroker.bank.BankWS"/> - <camel:endpoint id="bank3WS" uri="cxf://http://localhost:${bank3.port}/bank3?serviceClass=org.apache.camel.loanbroker.bank.BankWS"/> + <camel:endpoint id="bank1WS" + uri="cxf://http://localhost:${bank1.port}/bank1?serviceClass=org.apache.camel.loanbroker.bank.BankWS"/> + <camel:endpoint id="bank2WS" + uri="cxf://http://localhost:${bank2.port}/bank2?serviceClass=org.apache.camel.loanbroker.bank.BankWS"/> + <camel:endpoint id="bank3WS" + uri="cxf://http://localhost:${bank3.port}/bank3?serviceClass=org.apache.camel.loanbroker.bank.BankWS"/> <camel:route id="loanBrokerRoute"> <camel:from uri="cxf:bean:loanBroker"/> @@ -99,9 +102,9 @@ <bean id="creditScoreProcessor" class="org.apache.camel.loanbroker.CreditScoreProcessor"> <constructor-arg index="0" value="http://localhost:${credit_agency.port}/creditAgency"/> </bean> - + <bean id="replyProcessor" class="org.apache.camel.loanbroker.ReplyProcessor"/> - + <!-- strategy to assemble the bank responses --> <bean id="bankResponse" class="org.apache.camel.loanbroker.BankResponseAggregationStrategy"/> http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-cxf/src/main/resources/features.xml ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-cxf/src/main/resources/features.xml b/examples/camel-example-loan-broker-cxf/src/main/resources/features.xml index ab20efa..79ffc67 100644 --- a/examples/camel-example-loan-broker-cxf/src/main/resources/features.xml +++ b/examples/camel-example-loan-broker-cxf/src/main/resources/features.xml @@ -1,23 +1,29 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- 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. --> +<!-- + 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. +--> <features> - <repository>mvn:org.apache.camel.karaf/apache-camel/${project.version}/xml/features - </repository> + <repository>mvn:org.apache.camel.karaf/apache-camel/${project.version}/xml/features + </repository> - <feature name='camel-example-loan-broker' version='${project.version}'> - <feature version="${project.version}">camel</feature> - <feature version="${project.version}">camel-cxf</feature> - <bundle>mvn:org.apache.camel/camel-example-loan-broker/${project.version} - </bundle> - </feature> + <feature name='camel-example-loan-broker' version='${project.version}'> + <feature version="${project.version}">camel</feature> + <feature version="${project.version}">camel-cxf</feature> + <bundle>mvn:org.apache.camel/camel-example-loan-broker/${project.version} + </bundle> + </feature> </features> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-cxf/src/main/resources/log4j2.properties ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-cxf/src/main/resources/log4j2.properties b/examples/camel-example-loan-broker-cxf/src/main/resources/log4j2.properties index a937db3..f9a4829 100644 --- a/examples/camel-example-loan-broker-cxf/src/main/resources/log4j2.properties +++ b/examples/camel-example-loan-broker-cxf/src/main/resources/log4j2.properties @@ -14,10 +14,9 @@ ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- - -appender.stdout.type = Console -appender.stdout.name = stdout -appender.stdout.layout.type = PatternLayout -appender.stdout.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n -rootLogger.level = INFO -rootLogger.appenderRef.stdout.ref = stdout +appender.stdout.type=Console +appender.stdout.name=stdout +appender.stdout.layout.type=PatternLayout +appender.stdout.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n +rootLogger.level=INFO +rootLogger.appenderRef.stdout.ref=stdout http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-cxf/src/main/resources/logging.properties ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-cxf/src/main/resources/logging.properties b/examples/camel-example-loan-broker-cxf/src/main/resources/logging.properties index 41f062c..12bd10e 100644 --- a/examples/camel-example-loan-broker-cxf/src/main/resources/logging.properties +++ b/examples/camel-example-loan-broker-cxf/src/main/resources/logging.properties @@ -25,50 +25,40 @@ # with the java.util.logging.config.file system property. # For example java -Djava.util.logging.config.file=myfile ############################################################ - ############################################################ # Global properties ############################################################ - # "handlers" specifies a comma separated list of log Handler # classes. These handlers will be installed during VM startup. # Note that these classes must be on the system classpath. # By default we only configure a ConsoleHandler, which will only # show messages at the INFO and above levels. #handlers= java.util.logging.ConsoleHandler - # To also add the FileHandler, use the following line instead. #handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler - # Default global logging level. # This specifies which kinds of events are logged across # all loggers. For any given facility this global level # can be overriden by a facility specific level # Note that the ConsoleHandler also has a separate level # setting to limit messages printed to the console. -.level= WARNING - +.level=WARNING ############################################################ # Handler specific properties. # Describes specific configuration info for Handlers. ############################################################ - # default file output is in user's home directory. -java.util.logging.FileHandler.pattern = %h/java%u.log -java.util.logging.FileHandler.limit = 50000 -java.util.logging.FileHandler.count = 1 -java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter - +java.util.logging.FileHandler.pattern=%h/java%u.log +java.util.logging.FileHandler.limit=50000 +java.util.logging.FileHandler.count=1 +java.util.logging.FileHandler.formatter=java.util.logging.XMLFormatter # Limit the message that are printed on the console to INFO and above. -java.util.logging.ConsoleHandler.level = WARNING -java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter - - +java.util.logging.ConsoleHandler.level=WARNING +java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter ############################################################ # Facility specific properties. # Provides extra control for each logger. ############################################################ - # For example, set the com.xyz.foo logger to only log SEVERE # messages: #com.xyz.foo.level = SEVERE http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-cxf/src/test/java/org/apache/camel/loanbroker/LoanBrokerWSTest.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-cxf/src/test/java/org/apache/camel/loanbroker/LoanBrokerWSTest.java b/examples/camel-example-loan-broker-cxf/src/test/java/org/apache/camel/loanbroker/LoanBrokerWSTest.java index d84880f..906116b 100644 --- a/examples/camel-example-loan-broker-cxf/src/test/java/org/apache/camel/loanbroker/LoanBrokerWSTest.java +++ b/examples/camel-example-loan-broker-cxf/src/test/java/org/apache/camel/loanbroker/LoanBrokerWSTest.java @@ -19,8 +19,6 @@ package org.apache.camel.loanbroker; import java.io.File; import java.io.FileOutputStream; -import org.apache.camel.loanbroker.Client; -import org.apache.camel.loanbroker.LoanBrokerWS; import org.apache.camel.test.AvailablePortFinder; import org.apache.camel.test.spring.CamelSpringTestSupport; import org.junit.BeforeClass; @@ -29,14 +27,14 @@ import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class LoanBrokerWSTest extends CamelSpringTestSupport { - + private static String url; - + @BeforeClass public static void setupFreePort() throws Exception { // find a free port number, and write that in the custom.properties file // which we will use for the unit tests, to avoid port number in use problems - int port = AvailablePortFinder.getNextAvailable(); + int port = AvailablePortFinder.getNextAvailable(); String bank1 = "bank1.port=" + port; port = AvailablePortFinder.getNextAvailable(); String bank2 = "bank2.port=" + port; http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-cxf/src/test/resources/log4j2.properties ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-cxf/src/test/resources/log4j2.properties b/examples/camel-example-loan-broker-cxf/src/test/resources/log4j2.properties index c6d2618..83758d9 100644 --- a/examples/camel-example-loan-broker-cxf/src/test/resources/log4j2.properties +++ b/examples/camel-example-loan-broker-cxf/src/test/resources/log4j2.properties @@ -14,16 +14,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - -appender.file.type = File -appender.file.name = file -appender.file.fileName = target/camel-example-loan-broker-test.log -appender.file.layout.type = PatternLayout -appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n -appender.out.type = Console -appender.out.name = out -appender.out.layout.type = PatternLayout -appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n -rootLogger.level = INFO -rootLogger.appenderRef.file.ref = file +appender.file.type=File +appender.file.name=file +appender.file.fileName=target/camel-example-loan-broker-test.log +appender.file.layout.type=PatternLayout +appender.file.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n +appender.out.type=Console +appender.out.name=out +appender.out.layout.type=PatternLayout +appender.out.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n +rootLogger.level=INFO +rootLogger.appenderRef.file.ref=file http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-jms/README.md ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-jms/README.md b/examples/camel-example-loan-broker-jms/README.md index cc0cfff..8588af2 100644 --- a/examples/camel-example-loan-broker-jms/README.md +++ b/examples/camel-example-loan-broker-jms/README.md @@ -1,4 +1,4 @@ -# Loan Broker Example +# Loan Broker Example with JMS ### Introduction This example shows how to use Camel to implement the EIP's loan broker example, http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/Client.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/Client.java b/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/Client.java index d5e066d..2aad6cf 100644 --- a/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/Client.java +++ b/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/Client.java @@ -28,8 +28,8 @@ public final class Client { } public static void main(String args[]) throws Exception { - - AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext("META-INF/spring/client.xml"); + + AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext("META-INF/spring/client.xml"); CamelContext context = applicationContext.getBean("camel", CamelContext.class); context.start(); http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/LoanBroker.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/LoanBroker.java b/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/LoanBroker.java index a0a497b..560745e 100644 --- a/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/LoanBroker.java +++ b/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/LoanBroker.java @@ -23,24 +23,20 @@ import org.apache.camel.spring.Main; */ public final class LoanBroker { - private LoanBroker() { - } + private LoanBroker() { + } - // START SNIPPET: starting - public static void main(String... args) throws Exception { + // START SNIPPET: starting + public static void main(String... args) throws Exception { - Main main = new Main(); - // configure the location of the Spring XML file - - main.setApplicationContextUri("META-INF/spring/server.xml"); + Main main = new Main(); + // configure the location of the Spring XML file - main.addRouteBuilder(new LoanBrokerRoute()); + main.setApplicationContextUri("META-INF/spring/server.xml"); + main.addRouteBuilder(new LoanBrokerRoute()); - main.run(); - - //TODO Do we need to add timer to stop after 5 mins as in the previous example. - - } - // END SNIPPET: starting + main.run(); + } + // END SNIPPET: starting } http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/LoanBrokerRoute.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/LoanBrokerRoute.java b/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/LoanBrokerRoute.java index 479df79..1da7a88 100644 --- a/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/LoanBrokerRoute.java +++ b/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/LoanBrokerRoute.java @@ -30,14 +30,14 @@ public class LoanBrokerRoute extends RouteBuilder { public void configure() { // START SNIPPET: dsl-2 from("jms:queue:loan") - // let the credit agency do the first work - .process(new CreditAgencyProcessor()) - // send the request to the three banks - .multicast(new BankResponseAggregationStrategy()).parallelProcessing() - .to("jms:queue:bank1", "jms:queue:bank2", "jms:queue:bank3") - .end() - // and prepare the reply message - .process(new ReplyProcessor()); + // let the credit agency do the first work + .process(new CreditAgencyProcessor()) + // send the request to the three banks + .multicast(new BankResponseAggregationStrategy()).parallelProcessing() + .to("jms:queue:bank1", "jms:queue:bank2", "jms:queue:bank3") + .end() + // and prepare the reply message + .process(new ReplyProcessor()); // Each bank processor will process the message and put the response message back from("jms:queue:bank1").process(new BankProcessor("bank1")); @@ -45,5 +45,5 @@ public class LoanBrokerRoute extends RouteBuilder { from("jms:queue:bank3").process(new BankProcessor("bank3")); // END SNIPPET: dsl-2 } - + } http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/bank/BankProcessor.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/bank/BankProcessor.java b/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/bank/BankProcessor.java index 9b142f3..5bdeb5d 100644 --- a/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/bank/BankProcessor.java +++ b/examples/camel-example-loan-broker-jms/src/main/java/org/apache/camel/loanbroker/bank/BankProcessor.java @@ -33,7 +33,7 @@ public class BankProcessor implements Processor { public void process(Exchange exchange) throws Exception { String ssn = exchange.getIn().getHeader(Constants.PROPERTY_SSN, String.class); Integer historyLength = exchange.getIn().getHeader(Constants.PROPERTY_HISTORYLENGTH, Integer.class); - double rate = primeRate + (double)(historyLength / 12) / 10 + (Math.random() * 10) / 10; + double rate = primeRate + (double) (historyLength / 12) / 10 + (Math.random() * 10) / 10; // set reply details as headers exchange.getOut().setHeader(Constants.PROPERTY_BANK, bankName); http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-jms/src/main/resources/META-INF/spring/client.xml ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-jms/src/main/resources/META-INF/spring/client.xml b/examples/camel-example-loan-broker-jms/src/main/resources/META-INF/spring/client.xml index f85bbf7..2d86378 100644 --- a/examples/camel-example-loan-broker-jms/src/main/resources/META-INF/spring/client.xml +++ b/examples/camel-example-loan-broker-jms/src/main/resources/META-INF/spring/client.xml @@ -1,34 +1,36 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- 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. --> +<!-- + 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. +--> <beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:u="http://www.springframework.org/schema/util" - xmlns:broker="http://activemq.apache.org/schema/core" - xsi:schemaLocation=" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd - http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"> - - <!-- create a CamelContext --> - <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring" /> + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - <bean id="jms" class="org.apache.camel.component.jms.JmsComponent"> - <property name="connectionFactory"> - <bean class="org.apache.activemq.ActiveMQConnectionFactory"> - <property name="brokerURL" value="tcp://localhost:51616" /> - </bean> - </property> - </bean> + <!-- create a CamelContext --> + <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"/> + <bean id="jms" class="org.apache.camel.component.jms.JmsComponent"> + <property name="connectionFactory"> + <bean class="org.apache.activemq.ActiveMQConnectionFactory"> + <property name="brokerURL" value="tcp://localhost:51616"/> + </bean> + </property> + </bean> </beans> http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-jms/src/main/resources/META-INF/spring/server.xml ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-jms/src/main/resources/META-INF/spring/server.xml b/examples/camel-example-loan-broker-jms/src/main/resources/META-INF/spring/server.xml index 3d3e072..c46f2b3 100644 --- a/examples/camel-example-loan-broker-jms/src/main/resources/META-INF/spring/server.xml +++ b/examples/camel-example-loan-broker-jms/src/main/resources/META-INF/spring/server.xml @@ -1,45 +1,47 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- 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. --> +<!-- + 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. +--> <beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:u="http://www.springframework.org/schema/util" - xmlns:broker="http://activemq.apache.org/schema/core" - xsi:schemaLocation=" - http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:broker="http://activemq.apache.org/schema/core" + xsi:schemaLocation="http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd - http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"> - <!-- create a CamelContext --> - <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring" /> - - - <bean id="jms" class="org.apache.camel.component.jms.JmsComponent"> - <property name="connectionFactory"> - <bean class="org.apache.activemq.ActiveMQConnectionFactory"> - <property name="brokerURL" value="vm://myBroker?broker.persistent=false&broker.useJmx=false"/> - </bean> - </property> - </bean> + <!-- create a CamelContext --> + <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"/> - <!-- lets configure the ActiveMQ JMS broker server --> - <broker:broker useJmx="true" persistent="false" brokerName="myBroker"> - <broker:transportConnectors> - <!-- expose a VM transport for in-JVM transport between AMQ and Camel on the server side --> - <broker:transportConnector name="vm" uri="vm://myBroker"/> - <!-- expose a TCP transport for clients to use --> - <broker:transportConnector name="tcp" uri="tcp://localhost:51616"/> - </broker:transportConnectors> - </broker:broker> + <bean id="jms" class="org.apache.camel.component.jms.JmsComponent"> + <property name="connectionFactory"> + <bean class="org.apache.activemq.ActiveMQConnectionFactory"> + <property name="brokerURL" value="vm://myBroker?broker.persistent=false&broker.useJmx=false"/> + </bean> + </property> + </bean> + <!-- lets configure the ActiveMQ JMS broker server --> + <broker:broker useJmx="true" persistent="false" brokerName="myBroker"> + <broker:transportConnectors> + <!-- expose a VM transport for in-JVM transport between AMQ and Camel on the server side --> + <broker:transportConnector name="vm" uri="vm://myBroker"/> + <!-- expose a TCP transport for clients to use --> + <broker:transportConnector name="tcp" uri="tcp://localhost:51616"/> + </broker:transportConnectors> + </broker:broker> </beans> http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-jms/src/test/java/org/apache/camel/loanbroker/LoanBrokerQueueTest.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-jms/src/test/java/org/apache/camel/loanbroker/LoanBrokerQueueTest.java b/examples/camel-example-loan-broker-jms/src/test/java/org/apache/camel/loanbroker/LoanBrokerQueueTest.java index 7691e55..6fefaf8 100644 --- a/examples/camel-example-loan-broker-jms/src/test/java/org/apache/camel/loanbroker/LoanBrokerQueueTest.java +++ b/examples/camel-example-loan-broker-jms/src/test/java/org/apache/camel/loanbroker/LoanBrokerQueueTest.java @@ -18,8 +18,6 @@ package org.apache.camel.loanbroker; import org.apache.camel.CamelContext; import org.apache.camel.ProducerTemplate; -import org.apache.camel.loanbroker.Constants; -import org.apache.camel.loanbroker.LoanBrokerRoute; import org.apache.camel.test.junit4.TestSupport; import org.junit.After; import org.junit.Before; @@ -28,38 +26,37 @@ import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class LoanBrokerQueueTest extends TestSupport { - private AbstractApplicationContext applicationContext; - protected CamelContext camelContext; - protected ProducerTemplate template; - - @Before - public void startServices() throws Exception { - applicationContext = new ClassPathXmlApplicationContext("META-INF/spring/server.xml"); - camelContext = getCamelContext(); - camelContext.addRoutes(new LoanBrokerRoute()); - template = camelContext.createProducerTemplate(); - camelContext.start(); - } - - @After - public void stopServices() throws Exception { - if (camelContext != null) { - camelContext.stop(); - } - } - - @Test - public void testClientInvocation() throws Exception { - String out = template.requestBodyAndHeader("jms:queue:loan", null, Constants.PROPERTY_SSN, "Client-A", - String.class); - - log.info("Result: {}", out); - assertNotNull(out); - assertTrue(out.startsWith("The best rate is [ssn:Client-A bank:bank")); - } - - protected CamelContext getCamelContext() throws Exception { - return applicationContext.getBean("camel", CamelContext.class); - } + private AbstractApplicationContext applicationContext; + private CamelContext camelContext; + private ProducerTemplate template; + + @Before + public void startServices() throws Exception { + applicationContext = new ClassPathXmlApplicationContext("META-INF/spring/server.xml"); + camelContext = getCamelContext(); + camelContext.addRoutes(new LoanBrokerRoute()); + template = camelContext.createProducerTemplate(); + camelContext.start(); + } + + @After + public void stopServices() throws Exception { + if (camelContext != null) { + camelContext.stop(); + } + } + + @Test + public void testClientInvocation() throws Exception { + String out = template.requestBodyAndHeader("jms:queue:loan", null, Constants.PROPERTY_SSN, "Client-A", String.class); + + log.info("Result: {}", out); + assertNotNull(out); + assertTrue(out.startsWith("The best rate is [ssn:Client-A bank:bank")); + } + + protected CamelContext getCamelContext() throws Exception { + return applicationContext.getBean("camel", CamelContext.class); + } } http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-loan-broker-jms/src/test/resources/log4j2.properties ---------------------------------------------------------------------- diff --git a/examples/camel-example-loan-broker-jms/src/test/resources/log4j2.properties b/examples/camel-example-loan-broker-jms/src/test/resources/log4j2.properties index c6d2618..83758d9 100644 --- a/examples/camel-example-loan-broker-jms/src/test/resources/log4j2.properties +++ b/examples/camel-example-loan-broker-jms/src/test/resources/log4j2.properties @@ -14,16 +14,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # - -appender.file.type = File -appender.file.name = file -appender.file.fileName = target/camel-example-loan-broker-test.log -appender.file.layout.type = PatternLayout -appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n -appender.out.type = Console -appender.out.name = out -appender.out.layout.type = PatternLayout -appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n -rootLogger.level = INFO -rootLogger.appenderRef.file.ref = file +appender.file.type=File +appender.file.name=file +appender.file.fileName=target/camel-example-loan-broker-test.log +appender.file.layout.type=PatternLayout +appender.file.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n +appender.out.type=Console +appender.out.name=out +appender.out.layout.type=PatternLayout +appender.out.layout.pattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n +rootLogger.level=INFO +rootLogger.appenderRef.file.ref=file http://git-wip-us.apache.org/repos/asf/camel/blob/634c4d77/examples/camel-example-twitter-salesforce/src/main/java/org/apache/camel/example/mention/TwitterSalesforceApplication.java ---------------------------------------------------------------------- diff --git a/examples/camel-example-twitter-salesforce/src/main/java/org/apache/camel/example/mention/TwitterSalesforceApplication.java b/examples/camel-example-twitter-salesforce/src/main/java/org/apache/camel/example/mention/TwitterSalesforceApplication.java index b2f60c8..3ea6044 100644 --- a/examples/camel-example-twitter-salesforce/src/main/java/org/apache/camel/example/mention/TwitterSalesforceApplication.java +++ b/examples/camel-example-twitter-salesforce/src/main/java/org/apache/camel/example/mention/TwitterSalesforceApplication.java @@ -19,6 +19,7 @@ package org.apache.camel.example.mention; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +//CHECKSTYLE:OFF @SpringBootApplication public class TwitterSalesforceApplication { @@ -30,3 +31,4 @@ public class TwitterSalesforceApplication { } } +//CHECKSTYLE:ON