使用变量恢复/启动Activiti任务的Camel路由

时间:2017-04-21 05:45:59

标签: spring-boot apache-camel activiti

我已经用activiti和camel设置了弹簧靴。我正在尝试配置Camel路由以轮询电子邮件以执行以下操作。关于相同的一些例子将非常有用:

  • 恢复激活任务
  • 启动活动任务

例如要恢复用户任务,我们需要将类似下面的内容传递给Acitviti Rest API,该API工作正常

{"action" : "complete", "variables": [ {"name":"id, "value":1}, {"name":"outcome", "value":true} ]}

我从下面开始设置Camel Routes,但不确定如何添加需要传递给activiti进程的变量:

@Component
public class MyCamelMailRouter extends RouteBuilder {
    @Override
    public void configure() throws Exception {
        from("imaps://imap.server.com?username=myemail@example.com&password=xxxxxx&consumer.delay=60000"
                + "&searchTerm.subject=Approving&searchTerm.unseen=true")
                .to("activiti:activationProcess:approval");
    }
}

这是我的maven依赖

<properties>
    <activiti.version>5.22.0</activiti.version>
    <activiti.rest.version>5.17.0</activiti.rest.version>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Camden.SR5</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring-boot-dependencies</artifactId>
            <version>2.18.3</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>com.sony.spe.spt</groupId>
        <artifactId>rpm-services-common</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>

    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>activiti-spring-boot-starter-basic</artifactId>
        <version>${activiti.version}</version>
    </dependency>

    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>spring-boot-starter-rest-api</artifactId>
        <version>${activiti.rest.version}</version>
    </dependency>

    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>activiti-spring-boot-starter-actuator</artifactId>
        <version>${activiti.version}</version>
    </dependency>

    <dependency>
        <groupId>org.activiti</groupId>
        <artifactId>activiti-spring-boot-starter-jpa</artifactId>
        <version>${activiti.version}</version>
    </dependency>

    <dependency>
        <groupId>com.oracle.ojdbc</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.1.0</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-eureka</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-config-client</artifactId>
    </dependency>

    <!-- Camel - start -->
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-spring-boot-starter</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-mail-starter</artifactId>
    </dependency>

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-stream-starter</artifactId>
    </dependency>
    <!-- Camel - end -->

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

以上在春季启动启动期间引发了以下异常,通过各种谷歌搜索引用的一些参考显示我可以使用我使用的符号指向activiti但是作为错误点它默认不存在。任何帮助将不胜感激。

org.apache.camel.spring.boot.CamelSpringBootInitializationException: org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> To[activiti:activationProcess:approval] <<< in route: Route(route1)[[From[imaps://imap.server.com?username=myemail@... because of Failed to resolve endpoint: activiti://activationProcess:approval due to: No component found with scheme: activiti
    at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:124) ~[camel-spring-boot-2.18.3.jar:2.18.3]
    at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:41) ~[camel-spring-boot-2.18.3.jar:2.18.3]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:383) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:337) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:882) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.__refresh(AbstractApplicationContext.java:545) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.jrLockAndRefresh(AbstractApplicationContext.java) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.2.RELEASE.jar:1.5.2.RELEASE]
    at com.workflow.WorkflowApplication.main(WorkflowApplication.java:15) [classes/:na]
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> To[activiti:activationProcess:approval] <<< in route: Route(route1)[[From[imaps://imap.server.com?username=myemail@... because of Failed to resolve endpoint: activiti://activationProcess:approval due to: No component found with scheme: activiti
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1071) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:984) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3401) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3132) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:183) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2961) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2957) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2980) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2957) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2924) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.spring.boot.RoutesCollector.maybeStart(RoutesCollector.java:141) ~[camel-spring-boot-2.18.3.jar:2.18.3]
    at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:116) ~[camel-spring-boot-2.18.3.jar:2.18.3]
    ... 17 common frames omitted
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: activiti://activationProcess:approval due to: No component found with scheme: activiti
    at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:629) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:79) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:211) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:108) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:114) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:62) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:56) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:545) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:506) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:222) ~[camel-core-2.18.3.jar:2.18.3]
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1068) ~[camel-core-2.18.3.jar:2.18.3]
    ... 30 common frames omitted

1 个答案:

答案 0 :(得分:0)

您需要添加activiti-camel组件的JAR / maven依赖项。它不是来自Apache Camel,而是来自Activiti项目,因此请查看依赖项的名称。

你可以看到最后一个堆栈跟踪说没有找到该组件。