-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shows adding a custom thread pool in a Java RouteBuilder
- Loading branch information
1 parent
f70c770
commit 2be369b
Showing
7 changed files
with
212 additions
and
0 deletions.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
Camel_CustomThreadPool_In_RouteBuilder/A_camel_recipientlist/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.switchyard.quickstarts</groupId> | ||
<artifactId>switchyard-quickstart-parent</artifactId> | ||
<version>1.1.1-p5-redhat-1</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<artifactId>A_camel_recipientlist</artifactId> | ||
<name>A_camel_recipientlist</name> | ||
<properties> | ||
<switchyard.version>1.1.1-p5-redhat-1</switchyard.version> | ||
<integration.version></integration.version> | ||
<kie.version></kie.version> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.switchyard</groupId> | ||
<artifactId>switchyard-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.switchyard</groupId> | ||
<artifactId>switchyard-plugin</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.switchyard.components</groupId> | ||
<artifactId>switchyard-component-camel-file</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.switchyard.components</groupId> | ||
<artifactId>switchyard-component-bean</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.switchyard</groupId> | ||
<artifactId>switchyard-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.switchyard.components</groupId> | ||
<artifactId>switchyard-component-test-mixin-cdi</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.switchyard.components</groupId> | ||
<artifactId>switchyard-component-camel</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.switchyard</groupId> | ||
<artifactId>switchyard-transform</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.switchyard</groupId> | ||
<artifactId>switchyard-validate</artifactId> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<finalName>${project.artifactId}</finalName> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.switchyard</groupId> | ||
<artifactId>switchyard-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>configure</goal> | ||
</goals> | ||
<configuration> | ||
<scannerClassNames> | ||
<param>org.switchyard.transform.config.model.TransformSwitchYardScanner</param> | ||
</scannerClassNames> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<!-- Modified by POM Artifact-Version Manipulator version 1.3.6-redhat-4-soa (20c6737) --> | ||
</project> |
55 changes: 55 additions & 0 deletions
55
...ist/src/main/java/org/switchyard/quickstarts/camel/binding/CamelGreetingServiceRoute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.switchyard.quickstarts.camel.binding; | ||
|
||
import java.util.concurrent.ArrayBlockingQueue; | ||
import java.util.concurrent.ThreadPoolExecutor; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.apache.camel.builder.RouteBuilder; | ||
|
||
public class CamelGreetingServiceRoute extends RouteBuilder { | ||
|
||
/** | ||
* The Camel route is configured via this method. The from endpoint is required to be a SwitchYard service. | ||
*/ | ||
|
||
ThreadPoolExecutor tpExecutor = new ThreadPoolExecutor(100, 100, 0, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(2048)); | ||
|
||
public void configure() { | ||
// TODO Auto-generated method stub | ||
from("switchyard://GreetingService") | ||
.log("starting processing of file") | ||
.split().tokenize("\n", 1) | ||
.setHeader("endpointsToBeTriggered",simple("direct:one,direct:two,direct:three,direct:four,direct:five,direct:six")) | ||
.recipientList(header("endpointsToBeTriggered")).executorService(tpExecutor) | ||
.parallelProcessing() | ||
.streaming() | ||
.log("Done with file"); | ||
|
||
|
||
|
||
from("direct:one") | ||
.log("DIRECT ONE "); | ||
|
||
from("direct:two") | ||
.log("DIRECT TWO "); | ||
|
||
from("direct:three") | ||
.log("DIRECT THREE "); | ||
|
||
from("direct:four") | ||
.log("DIRECT FOUR "); | ||
|
||
from("direct:five") | ||
.log("DIRECT FIVE "); | ||
|
||
from("direct:six") | ||
.log("DIRECT SIX }"); | ||
|
||
|
||
|
||
|
||
|
||
|
||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
...recipientlist/src/main/java/org/switchyard/quickstarts/camel/binding/GreetingService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors. | ||
* | ||
* Licensed 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.switchyard.quickstarts.camel.binding; | ||
|
||
public interface GreetingService { | ||
void greet(String name); | ||
} |
27 changes: 27 additions & 0 deletions
27
...pientlist/src/main/java/org/switchyard/quickstarts/camel/binding/GreetingServiceBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors. | ||
* | ||
* Licensed 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.switchyard.quickstarts.camel.binding; | ||
|
||
import org.switchyard.component.bean.Service; | ||
|
||
@Service(GreetingService.class) | ||
public class GreetingServiceBean | ||
implements org.switchyard.quickstarts.camel.binding.GreetingService { | ||
|
||
@Override | ||
public void greet(String name) { | ||
System.out.println("Hello there " + name + " :-) "); | ||
} | ||
} |
Empty file.
1 change: 1 addition & 0 deletions
1
...tomThreadPool_In_RouteBuilder/A_camel_recipientlist/src/main/resources/META-INF/forge.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<forge/> |
24 changes: 24 additions & 0 deletions
24
...readPool_In_RouteBuilder/A_camel_recipientlist/src/main/resources/META-INF/switchyard.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<switchyard xmlns="urn:switchyard-config:switchyard:1.0" xmlns:_1="urn:switchyard-component-bean:config:1.0" xmlns:camel="urn:switchyard-component-camel:config:1.0" xmlns:file="urn:switchyard-component-camel-file:config:1.0" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"> | ||
<sca:composite name="camel-binding" targetNamespace="urn:switchyard-quickstart:camel-binding:0.1.0"> | ||
<sca:service name="GreetingService" promote="GreetingService/GreetingService"> | ||
<file:binding.file> | ||
<operationSelector operationName="greet"/> | ||
<file:directory>/home/rick/Junk/Camel/In</file:directory> | ||
<file:consume> | ||
<file:initialDelay>10</file:initialDelay> | ||
<file:delay>10</file:delay> | ||
<file:delete>true</file:delete> | ||
</file:consume> | ||
</file:binding.file> | ||
</sca:service> | ||
<sca:component name="GreetingService"> | ||
<camel:implementation.camel> | ||
<camel:java class="org.switchyard.quickstarts.camel.binding.CamelGreetingServiceRoute"/> | ||
</camel:implementation.camel> | ||
<sca:service name="GreetingService"> | ||
<sca:interface.java interface="org.switchyard.quickstarts.camel.binding.GreetingService"/> | ||
</sca:service> | ||
</sca:component> | ||
</sca:composite> | ||
</switchyard> |