Activiti createTaskQuery (). ProcessInstanceId возвращает пустой - PullRequest
0 голосов
/ 11 октября 2019

Я использую activiti со следующими зависимостями maven.

<dependency>
    <groupId>org.activiti</groupId>
    <artifactId>activiti-cdi</artifactId>
    <version>5.17.0</version>
    <exclusions>
        <exclusion>
            <groupId>com.google.collections</groupId>
            <artifactId>google-collections</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.activiti</groupId>
    <artifactId>activiti-image-generator</artifactId>
    <version>5.17.0</version>
</dependency>

Вот activiti.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="transactionManager" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" value="java:jboss/TransactionManager"></property>
        <property name="resourceRef" value="true" />
    </bean>

    <!-- process engine configuration -->
    <bean id="processEngineConfiguration" class="org.activiti.cdi.CdiJtaProcessEngineConfiguration">
        <property name="dataSourceJndiName" value="asdfasdf" />
        <property name="databaseType" value="oracle" />
        <property name="transactionManager" ref="transactionManager" />
        <property name="transactionsExternallyManaged" value="true" />
        <property name="transactionsExternallyManaged" value="false" />
        <property name="jobExecutorActivate" value="true" />
        <property name="jdbcMaxActiveConnections" value="10" />
        <property name="jdbcMaxIdleConnections" value="10" />
        <property name="jdbcMaxCheckoutTime" value="20000" />
        <property name="jdbcMaxWaitTime" value="20000 " />
        <property name="history" value="audit" />
    </bean>
</beans>

Все отлично работает, но я не могу получить задачу с taskService.createTaskQuery().processInstanceIdпосле выполнения startProcessInstanceKey в той же транзакции.

Вот пример кода.

@Inject
protected RuntimeService runtimeService;

@Inject
protected TaskService taskService;

....

ProcessInstance instance = runtimeService.startProcessInstanceByKey(processDefinitionKey, getVariables());
Task task = taskService.createTaskQuery().processInstanceId(instance .getId).singleResult();
//task = null ?????.

Не могли бы вы помочь мне решить проблему?

...