dockerisation du kie-wb

pymma/pymma-kie-platform#22
Utilisation d'un reverse proxy server java comme proxy
pymma/pymma-kie-platform#22
Utilisation d'un reverse proxy server java comme proxu
This commit is contained in:
Nicolas Héron 2019-03-04 16:54:36 +01:00
commit 30ccfa9604
16 changed files with 273 additions and 156 deletions

View file

@ -31,8 +31,6 @@
<name>Chtijbug :: Business Proxy :: app</name> <name>Chtijbug :: Business Proxy :: app</name>
<!-- Spring-Boot and Camel BOM --> <!-- Spring-Boot and Camel BOM -->
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>

View file

@ -24,8 +24,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
public class DroolsBusinessProxyServer { public class DroolsBusinessProxyServer {
/** /**
* Main method to start the application. * Main method to start the application.
*/ */

View file

@ -13,12 +13,13 @@ import javax.annotation.Resource;
public class AdminRouter extends RouteBuilder { public class AdminRouter extends RouteBuilder {
@Resource
KieServiceCommon kieServiceCommon;
@Value("${server.port}") @Value("${server.port}")
private int serverPort; private int serverPort;
@Value("${camel.component.servlet.mapping.context-path}") @Value("${camel.component.servlet.mapping.context-path}")
private String contextPath; private String contextPath;
@Resource
KieServiceCommon kieServiceCommon;
@Override @Override
public void configure() throws Exception { public void configure() throws Exception {
System.out.println("coucou"); System.out.println("coucou");
@ -32,7 +33,7 @@ public class AdminRouter extends RouteBuilder {
.contextPath(contextPath.substring(0, contextPath.length() - 2)) .contextPath(contextPath.substring(0, contextPath.length() - 2))
// turn on swagger api-doc // turn on swagger api-doc
.apiContextPath("/api-doc") .apiContextPath("/api-doc")
.apiProperty("api.title","KIE Server :: Core") .apiProperty("api.title", "KIE Server :: Core")
.apiProperty("api.version", "1.0.0"); .apiProperty("api.version", "1.0.0");
rest("/server/details").description("Retrieves containers deployed to this server, optionally filtered by group, artifact, version or status") rest("/server/details").description("Retrieves containers deployed to this server, optionally filtered by group, artifact, version or status")
@ -41,49 +42,5 @@ public class AdminRouter extends RouteBuilder {
.get("/").description("Retrieves KIE Server information - id, name, location, capabilities, messages").outType(KieServerInfo.class) .get("/").description("Retrieves KIE Server information - id, name, location, capabilities, messages").outType(KieServerInfo.class)
.responseMessage().code(200).message("Server Info successfully returned").endResponseMessage() .responseMessage().code(200).message("Server Info successfully returned").endResponseMessage()
.to("bean:kieService?method=getInfo()"); .to("bean:kieService?method=getInfo()");
/** }
rest("/server/containers").description("Retrieves containers deployed to this server, optionally filtered by group, artifact, version or status")
.produces("application/json")
.consumes("application/json")
.get("/").description("Find user by ID").outType(KieContainerResourceList.class)
.param().name("groupId").type(RestParamType.query).required(false).description("optional groupId to filter containers by").dataType("string").endParam()
.param().name("artifactId").type(RestParamType.query).required(false).description("optional artifactId to filter containers by").dataType("string").endParam()
.param().name("version").type(RestParamType.query).required(false).description("optional version to filter containers by").dataType("string").endParam()
.param().name("status").type(RestParamType.query).required(false).description("optional status to filter containers by").dataType("string").endParam()
.responseMessage().code(200).message("containers successfully returned").endResponseMessage()
.to("bean:kieService?method=listContainers(${header.groupId},${header.artifactId},${header.version},${header.status})");
rest("/server/containers").description(" Creates (deploys) new KIE container to this server")
.consumes("application/json")
.produces("application/json")
.put("/{id}").description("Container id to be assigned to deployed KIE Container").type(KieContainerResource.class).outType(KieContainerResource.class)
.param().name("id").type(path).description("Container id to be assigned to deployed KIE Container").dataType("string").endParam()
.param().name("body").type(body).description("KIE Container resource to be deployed as KieContainerResourcee").endParam()
.responseMessage().code(200).message("Container successfully created").endResponseMessage()
.to("bean:kieService?method=createContainer(${header.id},${body})");
rest("/server/containers").description(" Disposes (undeploys) container with given id")
.consumes("application/json")
.produces("application/json")
.delete("/{id}").description("Container id to be disposed (undeployed)r")
.param().name("id").type(path).description("Container id to be disposed (undeployed)").dataType("string").endParam()
.responseMessage().code(200).message("Container successfully created").endResponseMessage()
.to("bean:kieService?method=disposeContainer(${header.id})");
rest("/server/containers/business").description(" Creates (deploys) new KIE container to this server with a business rest interface")
.consumes("application/json")
.produces("application/json")
.post("/{id}/{className}/{processID}").description("Container id to be assigned to deployed KIE Container").type(KieContainerResource.class).outType(KieContainerResource.class)
.param().name("id").type(path).description("Container id to be assigned to deployed KIE Container").dataType("string").endParam()
.param().name("className").type(path).description("Class Name of the Business Service").dataType("string").endParam()
.param().name("processID").type(path).description("Process Id of the Business Service").dataType("string").endParam()
.param().name("body").type(body).description("KIE Container resource to be deployed as KieContainerResourcee").endParam()
.responseMessage().code(200).message("Container successfully created").endResponseMessage()
.to("bean:kieService?method=createContainerWithRestBusinessService(${header.id},${body},${header.className},${header.processID})");
**/
}
} }

View file

@ -5,12 +5,8 @@ import org.springframework.stereotype.Component;
@Component @Component
public class AutodeployRouter extends RouteBuilder { public class AutodeployRouter extends RouteBuilder {
@Override @Override
public void configure() throws Exception { public void configure() throws Exception {
from("quartz2://myGroup/myTimerName?cron=0+0/1+*+?+*+MON-FRI").to("bean:kieService?method=updateConfig()"); from("quartz2://myGroup/myTimerName?cron=0+0/1+*+?+*+MON-FRI").to("bean:kieService?method=updateConfig()");
} }
} }

View file

@ -26,19 +26,14 @@ public class DroolsRouter extends RouteBuilder {
@Override @Override
public void configure() throws Exception { public void configure() throws Exception {
rest("/" + containerId).description(containerId + " Rest service")
.consumes("application/json")
.produces("application/json")
System.out.println("coucou"); .put("/").description("Execute Business Service").type(clazzUser).outType(clazzUser)
// .param().name("containerId").type(path).description("Container ID where the rule artefact id deployed").dataType("integer").endParam()
rest("/" + containerId).description(containerId + " Rest service") .param().name("body").type(body).description("The Data drools should work on").endParam()
.consumes("application/json") .responseMessage().code(200).message("Data drools worked on").endResponseMessage()
.produces("application/json") .to("bean:ruleService?method=runSessionObject(${header.transactionId}," + this.containerId + "," + this.processID + ",${body})");
.put("/").description("Execute Business Service").type(clazzUser).outType(clazzUser)
// .param().name("containerId").type(path).description("Container ID where the rule artefact id deployed").dataType("integer").endParam()
.param().name("body").type(body).description("The Data drools should work on").endParam()
.responseMessage().code(200).message("Data drools worked on").endResponseMessage()
.to("bean:ruleService?method=runSessionObject(${header.transactionId},"+this.containerId+","+this.processID+",${body})");
} }
} }

View file

@ -1,55 +0,0 @@
package org.chtijbug.drools.proxy.camel;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.rest.RestBindingMode;
import org.chtijbug.drools.proxy.service.RuleService;
import org.springframework.beans.factory.annotation.Value;
import javax.annotation.Resource;
import static org.apache.camel.model.rest.RestParamType.body;
import static org.apache.camel.model.rest.RestParamType.path;
//@Component
public class GenericDroolsRouter extends RouteBuilder {
@Value("${server.port}")
private int serverPort;
@Value("${camel.component.servlet.mapping.context-path}")
private String contextPath;
@Resource
RuleService ruleServicee;
@Override
public void configure() throws Exception {
// @formatter:off
// this can also be configured in application.properties
restConfiguration()
.component("servlet")
.bindingMode(RestBindingMode.json)
.dataFormatProperty("prettyPrint", "true")
.enableCORS(true)
.port(serverPort)
.contextPath(contextPath.substring(0, contextPath.length() - 2))
// turn on swagger api-doc
.apiContextPath("/api-doc")
.apiProperty("api.title", "Generic drools API")
.apiProperty("api.version", "1.0.0");
rest("containers/generic/run").description("Drools Generic Rest service")
.consumes("application/json")
.produces("application/json")
.post("/{id}/{processId}/{className}").description("Find user by ID")
.param().name("id").type(path).description("Container ID where the rule are located").dataType("integer").endParam()
.param().name("processId").type(path).description("process ID sot start").dataType("integer").endParam()
.param().name("className").type(path).description("Class name of the top class").dataType("integer").endParam()
.param().name("body").type(body).description("The user data").endParam()
.responseMessage().code(200).message("User successfully returned").endResponseMessage()
.to("bean:ruleService?method=runSession(${header.id},${header.processId},${header.className},${body})");
}
}

View file

@ -53,21 +53,18 @@ public class KieServiceCommon {
private static final Logger logger = LoggerFactory.getLogger(KieServiceCommon.class); private static final Logger logger = LoggerFactory.getLogger(KieServiceCommon.class);
@Autowired
CamelContext camelContext;
private KieServerImpl server; private KieServerImpl server;
private MarshallerHelper marshallerHelper; private MarshallerHelper marshallerHelper;
private KieServerRegistry registry; private KieServerRegistry registry;
private ObjectMapper mapper = new ObjectMapper(); private ObjectMapper mapper = new ObjectMapper();
private DroolsChtijbugRulesExecutionService droolsChtijbugRulesExecutionService = null; private DroolsChtijbugRulesExecutionService droolsChtijbugRulesExecutionService = null;
private DroolsChtijbugKieServerExtension droolsChtijbugKieServerExtension; private DroolsChtijbugKieServerExtension droolsChtijbugKieServerExtension;
@Inject @Inject
private ContainerRepository containerRepository; private ContainerRepository containerRepository;
@Inject @Inject
private RuntimeRepository runtimeRepository; private RuntimeRepository runtimeRepository;
@Autowired
CamelContext camelContext;
@Value("${server.port}") @Value("${server.port}")
private int serverPort; private int serverPort;
@ -95,20 +92,19 @@ public class KieServiceCommon {
@PostConstruct @PostConstruct
private void initCamelBusinessRoutes() { private void initCamelBusinessRoutes() {
String serverName = System.getProperty("org.kie.server.id"); String serverName = System.getProperty("org.kie.server.id");
String sftpPort=System.getProperty("org.chtijbug.server.sftpPort"); String sftpPort = System.getProperty("org.chtijbug.server.sftpPort");
List<RuntimePersist> itIsMes = runtimeRepository.findByServerName(serverName); List<RuntimePersist> itIsMes = runtimeRepository.findByServerName(serverName);
if (itIsMes.size()==0){ if (itIsMes.size() == 0) {
ServiceResponse<KieServerInfo> result = server.getInfo(); ServiceResponse<KieServerInfo> result = server.getInfo();
String version = result.getResult().getVersion(); String version = result.getResult().getVersion();
String hostName="localhost"; String hostName = "localhost";
try { try {
InetAddress inetAddress = InetAddress.getLocalHost(); InetAddress inetAddress = InetAddress.getLocalHost();
hostName=inetAddress.getHostName(); hostName = inetAddress.getHostName();
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
logger.info("initCamelBusinessRoutes.getLocalHost", e); logger.info("initCamelBusinessRoutes.getLocalHost", e);
} }
//org.chtijbug.server.sftpPort RuntimePersist runtimePersist = new RuntimePersist(serverName, version, "http://" + hostName + ":" + serverPort, String.valueOf(serverPort), sftpPort);
RuntimePersist runtimePersist = new RuntimePersist(serverName,version,"http://"+hostName+":"+serverPort,String.valueOf(serverPort),sftpPort);
runtimeRepository.save(runtimePersist); runtimeRepository.save(runtimePersist);
} }
try { try {
@ -155,7 +151,6 @@ public class KieServiceCommon {
} }
public KieServerImpl getServer() { public KieServerImpl getServer() {
return server; return server;
} }
@ -184,8 +179,8 @@ public class KieServiceCommon {
public void updateConfig() throws Exception { public void updateConfig() throws Exception {
String serverName = System.getProperty("org.kie.server.id"); String serverName = System.getProperty("org.kie.server.id");
List<ContainerPojoPersist> containers= containerRepository.findByServerNameAndStatus(serverName, ContainerPojoPersist.STATUS.TODEPLOY.toString()); List<ContainerPojoPersist> containers = containerRepository.findByServerNameAndStatus(serverName, ContainerPojoPersist.STATUS.TODEPLOY.toString());
for (ContainerPojoPersist element:containers){ for (ContainerPojoPersist element : containers) {
//this.disposeContainer(element.getContainerId()); //this.disposeContainer(element.getContainerId());
KieContainerResource newContainer = new KieContainerResource(); KieContainerResource newContainer = new KieContainerResource();
@ -194,13 +189,14 @@ public class KieServiceCommon {
newContainer.getReleaseId().setArtifactId(element.getArtifactId()); newContainer.getReleaseId().setArtifactId(element.getArtifactId());
newContainer.getReleaseId().setGroupId(element.getGroupId()); newContainer.getReleaseId().setGroupId(element.getGroupId());
newContainer.getReleaseId().setVersion(element.getVersion()); newContainer.getReleaseId().setVersion(element.getVersion());
this.createContainer(element.getContainerId(),newContainer); this.createContainer(element.getContainerId(), newContainer);
this.initCamelBusinessRoute(element); this.initCamelBusinessRoute(element);
element.setStatus(ContainerPojoPersist.STATUS.UP.toString()); element.setStatus(ContainerPojoPersist.STATUS.UP.toString());
containerRepository.save(element); containerRepository.save(element);
} }
} }
public KieContainerResource createContainerWithRestBusinessService(String id, KieContainerResource container, String className, String processID) { public KieContainerResource createContainerWithRestBusinessService(String id, KieContainerResource container, String className, String processID) {

View file

@ -27,18 +27,13 @@ import java.util.Set;
@Service("ruleService") @Service("ruleService")
public class RuleService { public class RuleService {
private static final Logger logger = LoggerFactory.getLogger(RuleService.class);
private DroolsChtijbugRulesExecutionService droolsChtijbugRulesExecutionService = null; private DroolsChtijbugRulesExecutionService droolsChtijbugRulesExecutionService = null;
private DroolsChtijbugKieServerExtension droolsChtijbugKieServerExtension; private DroolsChtijbugKieServerExtension droolsChtijbugKieServerExtension;
private KieServerRegistry registry; private KieServerRegistry registry;
private ObjectMapper mapper = new ObjectMapper(); private ObjectMapper mapper = new ObjectMapper();
private KieServerImpl server; private KieServerImpl server;
private static final Logger logger = LoggerFactory.getLogger(RuleService.class);
public RuleService() { public RuleService() {
this.server = KieServerLocator.getInstance(); this.server = KieServerLocator.getInstance();
@ -57,7 +52,7 @@ public class RuleService {
} }
} }
public Object runSessionObject(String transactionID,String id, String processID, Object input) throws IOException { public Object runSessionObject(String transactionID, String id, String processID, Object input) throws IOException {
KieContainerInstance kci = registry.getContainer(id); KieContainerInstance kci = registry.getContainer(id);
ChtijbugObjectRequest chtijbugObjectRequest = new ChtijbugObjectRequest(); ChtijbugObjectRequest chtijbugObjectRequest = new ChtijbugObjectRequest();
chtijbugObjectRequest.setObjectRequest(input); chtijbugObjectRequest.setObjectRequest(input);
@ -85,11 +80,11 @@ public class RuleService {
if (jsonInString == null) { if (jsonInString == null) {
jsonInString = mapper.writeValueAsString(chtijbutObjectResponse.getSessionLogging()); jsonInString = mapper.writeValueAsString(chtijbutObjectResponse.getSessionLogging());
} }
String fileUUID=null; String fileUUID = null;
if (transactionID==null){ if (transactionID == null) {
fileUUID="noTransactionID"; fileUUID = "noTransactionID";
}else{ } else {
fileUUID=transactionID; fileUUID = transactionID;
} }
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
int year = now.getYear(); int year = now.getYear();
@ -99,8 +94,8 @@ public class RuleService {
int minute = now.getMinute(); int minute = now.getMinute();
int second = now.getSecond(); int second = now.getSecond();
int millis = now.get(ChronoField.MILLI_OF_SECOND); int millis = now.get(ChronoField.MILLI_OF_SECOND);
String fileName=year+"-"+month+"-"+day+"-"+hour+"-"+minute+"-"+second+"-"+millis+"-"+fileUUID.replaceAll("-","")+".json"; String fileName = year + "-" + month + "-" + day + "-" + hour + "-" + minute + "-" + second + "-" + millis + "-" + fileUUID.replaceAll("-", "") + ".json";
File traceFile = new File(fileTemp + "/" +fileName); File traceFile = new File(fileTemp + "/" + fileName);
FileUtils.writeByteArrayToFile(traceFile, jsonInString.getBytes()); FileUtils.writeByteArrayToFile(traceFile, jsonInString.getBytes());
} }
@ -109,7 +104,6 @@ public class RuleService {
} }
private Class getClassFromName(Set<Class<?>> classes, String name) { private Class getClassFromName(Set<Class<?>> classes, String name) {
Class result = null; Class result = null;
for (Class c : classes) { for (Class c : classes) {

View file

@ -19,6 +19,5 @@ server.port=8090
camel.springboot.name=MyCamel camel.springboot.name=MyCamel
# to reconfigure the camel servlet context-path mapping to use /api/* instead of /camel/* # to reconfigure the camel servlet context-path mapping to use /api/* instead of /camel/*
camel.component.servlet.mapping.context-path=/api/* camel.component.servlet.mapping.context-path=/api/*
spring.data.mongodb.database=businessProxyDB spring.data.mongodb.database=businessProxyDB
spring.data.mongodb.host=localhost:27017 spring.data.mongodb.host=localhost:27017

View file

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
<facet type="web" name="Web">
<configuration>
<webroots />
<sourceRoots>
<root url="file://$MODULE_DIR$/src/main/java" />
<root url="file://$MODULE_DIR$/src/main/resources" />
</sourceRoots>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: com.github.mkopylec:charon-spring-boot-starter:3.1.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.1.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.1.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.1.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.1.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.1.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.11.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.11.1" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.25" level="project" />
<orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.3.2" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.23" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.1.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.7" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.7" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.7" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.7" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.7" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.1.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.12" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.12" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.12" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.13.Final" level="project" />
<orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.2.Final" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.4.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.1.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.1.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.1.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.1.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.1.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.1.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.8.1" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.2" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.10" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.11" level="project" />
<orderEntry type="library" name="Maven: org.springframework.retry:spring-retry:1.2.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.1.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.1.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: io.micrometer:micrometer-core:1.1.3" level="project" />
<orderEntry type="library" name="Maven: org.hdrhistogram:HdrHistogram:2.1.9" level="project" />
<orderEntry type="library" name="Maven: org.latencyutils:LatencyUtils:2.0.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-configuration-processor:2.1.0.RELEASE" level="project" />
</component>
</module>

View file

@ -0,0 +1,73 @@
<?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">
<parent>
<artifactId>drools-framework-business-proxy-parent</artifactId>
<groupId>com.pymmasoftware.jbpm</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>drools-framework-business-reverse-proxx</artifactId>
<dependencies>
<dependency>
<groupId>com.github.mkopylec</groupId>
<artifactId>charon-spring-boot-starter</artifactId>
<version>3.1.0</version>
</dependency>
<!-- Spring Boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
<version>1.2.2.RELEASE</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</dependency>
</dependencies>
<!-- Spring-Boot and Camel BOM -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot-version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>

View file

@ -0,0 +1,14 @@
package org.chtijbug.drools.reverseproxy;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DroolsBusinessReverseProxyServer {
public static void main(String[] args) {
SpringApplication.run(DroolsBusinessReverseProxyServer.class, args);
}
}

View file

@ -0,0 +1,50 @@
package org.chtijbug.drools.reverseproxy.mappings;
import com.github.mkopylec.charon.configuration.CharonProperties;
import com.github.mkopylec.charon.configuration.MappingProperties;
import com.github.mkopylec.charon.core.http.HttpClientProvider;
import com.github.mkopylec.charon.core.mappings.MappingsCorrector;
import com.github.mkopylec.charon.core.mappings.MappingsProvider;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
@Component
public class CustomMappingsProvider extends MappingsProvider {
public CustomMappingsProvider(ServerProperties server, CharonProperties charon, MappingsCorrector mappingsCorrector, HttpClientProvider httpClientProvider) {
super(server, charon, mappingsCorrector,httpClientProvider);
}
@Override
protected boolean shouldUpdateMappings(HttpServletRequest httpServletRequest) {
return false;
}
@Override
protected List<MappingProperties> retrieveMappings() {
List<MappingProperties> total = new ArrayList<>();
MappingProperties mappingProperties = new MappingProperties();
total.add(mappingProperties);
mappingProperties.setName("fraud-doc");
mappingProperties.setPath("/fraud-doc");
mappingProperties.getCustomConfiguration().put("connect",200);
mappingProperties.getCustomConfiguration().put("read",200);
mappingProperties.setStripPath(true);
mappingProperties.getDestinations().add("http://macbook-pro-de-nicolas-2.local:8091/api/");
MappingProperties mappingProperties2 = new MappingProperties();
total.add(mappingProperties2);
mappingProperties2.setName("fraud-run");
mappingProperties2.setPath("/fraud-Oney-fraud");
mappingProperties2.getCustomConfiguration().put("connect",200);
mappingProperties2.getCustomConfiguration().put("read",200);
mappingProperties2.setStripPath(true);
mappingProperties2.getDestinations().add("http://macbook-pro-de-nicolas-2.local:8091/api/fraud-Oney-fraud/");
return total;
}
}

View file

@ -22,5 +22,6 @@
<module>drools-framewwork-business-proxy-persistence</module> <module>drools-framewwork-business-proxy-persistence</module>
<module>drools-framework-business-indexer-app</module> <module>drools-framework-business-indexer-app</module>
<module>drools-framework-business-indexer-persistence</module> <module>drools-framework-business-indexer-persistence</module>
<module>drools-framework-business-reverse-proxx</module>
</modules> </modules>
</project> </project>

23
pom.xml
View file

@ -24,8 +24,31 @@
<spring.version>4.3.16.RELEASE</spring.version> <spring.version>4.3.16.RELEASE</spring.version>
<version.thorntail>2.2.1.Final</version.thorntail> <version.thorntail>2.2.1.Final</version.thorntail>
</properties> </properties>
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<env>dev</env>
<docker.Host>unix:///var/run/docker.sock</docker.Host>
</properties>
</profile>
<profile>
<id>docker-pymma</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<env>docker</env>
<docker.Host>http://192.168.1.184:2376</docker.Host>
</properties>
</profile>
</profiles>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>