initial checkin
This commit is contained in:
14
.gitignore
vendored
Normal file
14
.gitignore
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Maven
|
||||||
|
target
|
||||||
|
pom.xml.versionsBackup
|
||||||
|
|
||||||
|
# Eclipse
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.settings
|
||||||
|
|
||||||
|
# Visual Studio Code
|
||||||
|
.vscode
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
/.idea/
|
221
pom.xml
Normal file
221
pom.xml
Normal file
@@ -0,0 +1,221 @@
|
|||||||
|
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>com.inteligr8.activiti</groupId>
|
||||||
|
<artifactId>mq-activiti-ext</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>MQ Activiti Extension</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.compiler.source>11</maven.compiler.source>
|
||||||
|
<maven.compiler.target>11</maven.compiler.target>
|
||||||
|
<maven.compiler.release>11</maven.compiler.release>
|
||||||
|
|
||||||
|
<aps.version>2.4.1</aps.version>
|
||||||
|
<spring.version>5.3.29</spring.version>
|
||||||
|
<activiti.version>7.11.0</activiti.version>
|
||||||
|
<jackson.version>2.13.5</jackson.version>
|
||||||
|
|
||||||
|
<rabbitmq.version>5.12.0</rabbitmq.version>
|
||||||
|
<activemq.version>5.18.3</activemq.version>
|
||||||
|
<activemq.jms.version>2.31.2</activemq.jms.version>
|
||||||
|
|
||||||
|
<!-- for testin -->
|
||||||
|
<cxf.version>3.0.12</cxf.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- APS and Activiti -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.activiti</groupId>
|
||||||
|
<artifactId>activiti-app-rest</artifactId>
|
||||||
|
<version>${aps.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
|
||||||
|
<!-- none of these are needed for builds -->
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<!-- extra repository needed for this -->
|
||||||
|
<groupId>org.alfresco.officeservices</groupId>
|
||||||
|
<artifactId>aoservices</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<!-- extra repository needed for this -->
|
||||||
|
<groupId>com.activiti</groupId>
|
||||||
|
<artifactId>aspose-transformation</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<!-- avoiding log4j-api vulnerabilities -->
|
||||||
|
<groupId>org.elasticsearch</groupId>
|
||||||
|
<artifactId>elasticsearch</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<!-- avoiding old spring-context-support -->
|
||||||
|
<groupId>com.ryantenney.metrics</groupId>
|
||||||
|
<artifactId>metrics-spring</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<!-- avoiding old spring-* versions -->
|
||||||
|
<groupId>org.activiti</groupId>
|
||||||
|
<artifactId>activiti-spring</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.activiti</groupId>
|
||||||
|
<artifactId>activiti-api-process-runtime</artifactId>
|
||||||
|
<version>${activiti.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.activiti</groupId>
|
||||||
|
<artifactId>activiti-api-task-runtime</artifactId>
|
||||||
|
<version>${activiti.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MQ -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.rabbitmq</groupId>
|
||||||
|
<artifactId>amqp-client</artifactId>
|
||||||
|
<version>${rabbitmq.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.activemq</groupId>
|
||||||
|
<artifactId>activemq-client</artifactId>
|
||||||
|
<version>${activemq.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.activemq</groupId>
|
||||||
|
<artifactId>artemis-jms-client</artifactId>
|
||||||
|
<version>${activemq.jms.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Testing only -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.13.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-test</artifactId>
|
||||||
|
<version>${spring.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpclient</artifactId>
|
||||||
|
<version>4.5.9</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<!-- avoids log4j dependency -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.11.0</version>
|
||||||
|
</plugin>
|
||||||
|
<!-- avoids struts dependency -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-site-plugin</artifactId>
|
||||||
|
<version>3.12.1</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<version>3.6.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>assemble-jar</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals><goal>single</goal></goals>
|
||||||
|
<configuration>
|
||||||
|
<descriptorRefs>
|
||||||
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
|
</descriptorRefs>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>io.repaint.maven</groupId>
|
||||||
|
<artifactId>tiles-maven-plugin</artifactId>
|
||||||
|
<version>2.36</version>
|
||||||
|
<extensions>true</extensions>
|
||||||
|
<configuration>
|
||||||
|
<tiles>
|
||||||
|
<!-- Documentation: https://bitbucket.org/inteligr8/ootbee-beedk/src/stable/beedk-aps-ext-rad-tile -->
|
||||||
|
<tile>com.inteligr8.ootbee:beedk-aps-ext-rad-tile:[1.0.16,1.1)</tile>
|
||||||
|
</tiles>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>apidoc</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<filesets>
|
||||||
|
<fileset>
|
||||||
|
<directory>${basedir}/apidocs</directory>
|
||||||
|
</fileset>
|
||||||
|
</filesets>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
<version>3.4.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>generate-doclet</id>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
|
<goals><goal>javadoc</goal></goals>
|
||||||
|
<configuration>
|
||||||
|
<doclet>com.inteligr8.activiti.doclet.ActivitiDoclet</doclet>
|
||||||
|
<docletArtifact>
|
||||||
|
<groupId>com.inteligr8.activiti</groupId>
|
||||||
|
<artifactId>activiti-api-doclet</artifactId>
|
||||||
|
<version>1.0.4</version>
|
||||||
|
</docletArtifact>
|
||||||
|
<useStandardDocletOptions>false</useStandardDocletOptions>
|
||||||
|
<destDir>apidocs</destDir>
|
||||||
|
<reportOutputDirectory>${basedir}</reportOutputDirectory>
|
||||||
|
<additionalOptions>
|
||||||
|
<additionalOption>--title 'API Documentation'</additionalOption>
|
||||||
|
<additionalOption>--apiName '${project.name}</additionalOption>
|
||||||
|
</additionalOptions>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>alfresco-public</id>
|
||||||
|
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>activiti-releases</id>
|
||||||
|
<url>https://artifacts.alfresco.com/nexus/content/repositories/activiti-enterprise-releases</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
</project>
|
74
rad.ps1
Normal file
74
rad.ps1
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
|
||||||
|
function discoverArtifactId {
|
||||||
|
$script:ARTIFACT_ID=(mvn -q -Dexpression=project"."artifactId -DforceStdout help:evaluate)
|
||||||
|
}
|
||||||
|
|
||||||
|
function rebuild {
|
||||||
|
echo "Rebuilding project ..."
|
||||||
|
mvn process-classes
|
||||||
|
}
|
||||||
|
|
||||||
|
function start_ {
|
||||||
|
echo "Rebuilding project and starting Docker containers to support rapid application development ..."
|
||||||
|
mvn -Drad process-classes
|
||||||
|
}
|
||||||
|
|
||||||
|
function start_log {
|
||||||
|
echo "Rebuilding project and starting Docker containers to support rapid application development ..."
|
||||||
|
mvn -Drad "-Ddocker.showLogs" process-classes
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop_ {
|
||||||
|
discoverArtifactId
|
||||||
|
echo "Stopping Docker containers that supported rapid application development ..."
|
||||||
|
docker container ls --filter name=${ARTIFACT_ID}-*
|
||||||
|
echo "Stopping containers ..."
|
||||||
|
docker container stop (docker container ls -q --filter name=${ARTIFACT_ID}-*)
|
||||||
|
echo "Removing containers ..."
|
||||||
|
docker container rm (docker container ls -aq --filter name=${ARTIFACT_ID}-*)
|
||||||
|
}
|
||||||
|
|
||||||
|
function tail_logs {
|
||||||
|
param (
|
||||||
|
$container
|
||||||
|
)
|
||||||
|
|
||||||
|
discoverArtifactId
|
||||||
|
docker container logs -f (docker container ls -q --filter name=${ARTIFACT_ID}-${container})
|
||||||
|
}
|
||||||
|
|
||||||
|
function list {
|
||||||
|
discoverArtifactId
|
||||||
|
docker container ls --filter name=${ARTIFACT_ID}-*
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($args[0]) {
|
||||||
|
"start" {
|
||||||
|
start_
|
||||||
|
}
|
||||||
|
"start_log" {
|
||||||
|
start_log
|
||||||
|
}
|
||||||
|
"stop" {
|
||||||
|
stop_
|
||||||
|
}
|
||||||
|
"restart" {
|
||||||
|
stop_
|
||||||
|
start_
|
||||||
|
}
|
||||||
|
"rebuild" {
|
||||||
|
rebuild
|
||||||
|
}
|
||||||
|
"tail" {
|
||||||
|
tail_logs $args[1]
|
||||||
|
}
|
||||||
|
"containers" {
|
||||||
|
list
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
echo "Usage: .\rad.ps1 [ start | start_log | stop | restart | rebuild | tail {container} | containers ]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Completed!"
|
||||||
|
|
71
rad.sh
Normal file
71
rad.sh
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
discoverArtifactId() {
|
||||||
|
ARTIFACT_ID=`mvn -q -Dexpression=project.artifactId -DforceStdout help:evaluate`
|
||||||
|
}
|
||||||
|
|
||||||
|
rebuild() {
|
||||||
|
echo "Rebuilding project ..."
|
||||||
|
mvn process-classes
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
echo "Rebuilding project and starting Docker containers to support rapid application development ..."
|
||||||
|
mvn -Drad process-classes
|
||||||
|
}
|
||||||
|
|
||||||
|
start_log() {
|
||||||
|
echo "Rebuilding project and starting Docker containers to support rapid application development ..."
|
||||||
|
mvn -Drad -Ddocker.showLogs process-classes
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
discoverArtifactId
|
||||||
|
echo "Stopping Docker containers that supported rapid application development ..."
|
||||||
|
docker container ls --filter name=${ARTIFACT_ID}-*
|
||||||
|
echo "Stopping containers ..."
|
||||||
|
docker container stop `docker container ls -q --filter name=${ARTIFACT_ID}-*`
|
||||||
|
echo "Removing containers ..."
|
||||||
|
docker container rm `docker container ls -aq --filter name=${ARTIFACT_ID}-*`
|
||||||
|
}
|
||||||
|
|
||||||
|
tail_logs() {
|
||||||
|
discoverArtifactId
|
||||||
|
docker container logs -f `docker container ls -q --filter name=${ARTIFACT_ID}-$1`
|
||||||
|
}
|
||||||
|
|
||||||
|
list() {
|
||||||
|
discoverArtifactId
|
||||||
|
docker container ls --filter name=${ARTIFACT_ID}-*
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
start_log)
|
||||||
|
start_log
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
stop
|
||||||
|
;;
|
||||||
|
restart)
|
||||||
|
stop
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
rebuild)
|
||||||
|
rebuild
|
||||||
|
;;
|
||||||
|
tail)
|
||||||
|
tail_logs $2
|
||||||
|
;;
|
||||||
|
containers)
|
||||||
|
list
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: ./rad.sh [ start | start_log | stop | restart | rebuild | tail {container} | containers ]"
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "Completed!"
|
||||||
|
|
@@ -0,0 +1,12 @@
|
|||||||
|
package com.activiti.extension.conf;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ComponentScan(basePackages = {
|
||||||
|
"com.inteligr8.activiti.mq"
|
||||||
|
})
|
||||||
|
public class MqSpringComponentScanner {
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,69 @@
|
|||||||
|
package com.inteligr8.activiti.mq;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.security.KeyManagementException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
import org.activiti.engine.ProcessEngine;
|
||||||
|
import org.activiti.engine.delegate.DelegateExecution;
|
||||||
|
import org.activiti.engine.delegate.JavaDelegate;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.activiti.domain.idm.EndpointConfiguration;
|
||||||
|
import com.activiti.service.api.EndpointService;
|
||||||
|
import com.rabbitmq.client.AMQP;
|
||||||
|
import com.rabbitmq.client.BasicProperties;
|
||||||
|
import com.rabbitmq.client.Channel;
|
||||||
|
import com.rabbitmq.client.Connection;
|
||||||
|
import com.rabbitmq.client.ConnectionFactory;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class MqPublishActivity implements JavaDelegate {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ProcessEngine services;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EndpointService endpointService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(DelegateExecution execution) {
|
||||||
|
MqPublishActivityExecution mqExecution = new MqPublishActivityExecution(this.services, execution);
|
||||||
|
mqExecution.validate();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Connection mqcon = this.getConnection(mqExecution.getMqConnectorId());
|
||||||
|
Channel mqchannel = this.getChannel(mqcon);
|
||||||
|
|
||||||
|
BasicProperties props = new AMQP.BasicProperties();
|
||||||
|
mqchannel.basicPublish(mqExecution.getMqOutgoingQueue(), null, null, message.toByteArray());
|
||||||
|
} catch (TimeoutException te) {
|
||||||
|
} catch (IOException ie) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Connection getConnection(String connectorId) throws TimeoutException, IOException {
|
||||||
|
EndpointConfiguration endpointConfig = this.endpointService.getConfigurationByName(connectorId);
|
||||||
|
if (endpointConfig == null)
|
||||||
|
throw new IllegalStateException("The '" + connectorId + "' endpoint is not defined");
|
||||||
|
|
||||||
|
ConnectionFactory conFactory = new ConnectionFactory();
|
||||||
|
conFactory.setUsername(endpointConfig.getBasicAuth().getUsername());
|
||||||
|
conFactory.setPassword(endpointConfig.getBasicAuth().getPassword());
|
||||||
|
try {
|
||||||
|
conFactory.setUri(endpointConfig.getUrl());
|
||||||
|
return conFactory.newConnection();
|
||||||
|
} catch (KeyManagementException kme) {
|
||||||
|
} catch (NoSuchAlgorithmException nsae) {
|
||||||
|
} catch (URISyntaxException use) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Channel getChannel(Connection mqcon) throws IOException {
|
||||||
|
return mqcon.createChannel();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,51 @@
|
|||||||
|
package com.inteligr8.activiti.mq;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.activiti.bpmn.model.FieldExtension;
|
||||||
|
import org.activiti.bpmn.model.FlowElement;
|
||||||
|
import org.activiti.bpmn.model.ServiceTask;
|
||||||
|
import org.activiti.engine.ProcessEngine;
|
||||||
|
import org.activiti.engine.delegate.DelegateExecution;
|
||||||
|
|
||||||
|
public class MqPublishActivityExecution {
|
||||||
|
|
||||||
|
private final ProcessEngine services;
|
||||||
|
private final DelegateExecution execution;
|
||||||
|
private final ServiceTask task;
|
||||||
|
private final Map<String, String> fieldMap = new HashMap<String, String>();
|
||||||
|
|
||||||
|
public MqPublishActivityExecution(ProcessEngine services, DelegateExecution execution) {
|
||||||
|
this.services = services;
|
||||||
|
this.execution = execution;
|
||||||
|
|
||||||
|
FlowElement flowElement = this.execution.getCurrentFlowElement();
|
||||||
|
if (!(flowElement instanceof ServiceTask))
|
||||||
|
throw new IllegalStateException("This should never happen");
|
||||||
|
this.task = (ServiceTask) flowElement;
|
||||||
|
|
||||||
|
for (FieldExtension field : this.task.getFieldExtensions())
|
||||||
|
this.fieldMap.put(field.getId(), field.getStringValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validate() {
|
||||||
|
if (this.fieldMap.get("mqConnectorId") == null)
|
||||||
|
throw new IllegalStateException("The '" + this.execution.getCurrentActivityId() + "' activity must define an 'MQ Connector ID'");
|
||||||
|
if (this.fieldMap.get("mqOutgoingQueue") == null)
|
||||||
|
throw new IllegalStateException("The '" + this.execution.getCurrentActivityId() + "' activity must define an 'MQ Outgoing Queue'");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMqConnectorId() {
|
||||||
|
return this.fieldMap.get("mqConnectorId");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMqOutgoingQueue() {
|
||||||
|
return this.fieldMap.get("mqOutgoingQueue");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMqOutgoingReplyQueue() {
|
||||||
|
return this.fieldMap.get("mqOutgoingReplyQueue");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user