#173 Added new pattern, tests

This commit is contained in:
adkm
2017-10-16 19:33:15 +02:00
parent 04dd93f8bc
commit 9c7ee5ed1d
8 changed files with 231 additions and 0 deletions

View File

@ -0,0 +1,45 @@
package com.iluwatar.eip.splitter;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
/**
*
* <p>
* </p>
*/
@SpringBootApplication
public class App {
/**
* Program entry point. It starts Spring Boot application and using Apache Camel it auto-configures routes.
*
* @param args command line args
*/
public static void main(String[] args) throws Exception {
// Run Spring Boot application and obtain ApplicationContext
ConfigurableApplicationContext context = SpringApplication.run(App.class, args);
// Get CamelContext from ApplicationContext
CamelContext camelContext = (CamelContext) context.getBean("camelContext");
// Add a new routes that will handle endpoints form SplitterRoute class.
camelContext.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("{{endpoint}}").log("ENDPOINT: ${body}");
}
});
// Add producer that will send test message to an entry point in WireTapRoute
String[] stringArray = {"Test item #1", "Test item #2", "Test item #3"};
camelContext.createProducerTemplate().sendBody("{{entry}}", stringArray);
SpringApplication.exit(context);
}
}

View File

@ -0,0 +1,26 @@
package com.iluwatar.eip.splitter.routes;
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;
/**
* Sample splitter route definition.
*
* <p>
* </p>
*
* In this example input/output endpoints names are stored in <i>application.properties</i> file.
*/
@Component
public class SplitterRoute extends RouteBuilder {
/**
* Configures the route
* @throws Exception in case of exception during configuration
*/
@Override
public void configure() throws Exception {
// Main route
from("{{entry}}").split().body().to("{{endpoint}}");
}
}

View File

@ -0,0 +1,2 @@
entry=direct:entry
endpoint=direct:endpoint