Skip to content

Commit

Permalink
Shows adding a custom thread pool in a Java RouteBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
RickJWagner committed Nov 17, 2017
1 parent f70c770 commit 2be369b
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 0 deletions.
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>
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 }");






}

}
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);
}
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 + " :-) ");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<forge/>
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>

0 comments on commit 2be369b

Please sign in to comment.