Configuring Transaction Settings in jBPM

jBPM 7 is a powerful business process management (BPM) suite that allows organizations to model, automate, and optimize business processes. One crucial aspect of managing these processes effectively is configuring transaction setting such as timeouts. Transaction timeouts help prevent long-running transactions from causing performance issues and resource exhaustion. In this article, we will explore how to configure jBPM 7 transaction timeouts in two common environments: WildFly/JBoss EAP 7 and Spring Boot.

Transaction Timeout in jBPM and WildFly

Before we proceed with the configuration steps, let’s clarify what transaction timeouts are. A transaction timeout defines the maximum time a transaction can remain active before it’s automatically rolled back. This is crucial to maintain system stability, as it prevents resources from being locked up for extended periods, which can lead to performance degradation or system crashes.

When running jBPM on top of WildFly or JBoss EAP 7, you can rely on the Transaction Configuration of the application server. For example:

<core-environment>
    ...
    <timeout>
        <timeout value="300"/> <!-- Set timeout value in seconds -->
    </timeout>
    ...
</core-environment>

This is explained in greater detail in the following article: How to increase the Transaction Timeout in JBoss / WildFly

One thing to consider is that you might have EJB Timers which are partecipating in transactions. If this is the case, make sure that you are setting org.jbpm.ejb.timer.tx to true. Otherwise the timer creation will fail immediately (before the actual transaction timeout) due to the transaction being closed.

A clue that you might be in this scenario is the following WARN message in your logs:

WARN  [org.jboss.jca.core.connectionmanager.listener.TxConnectionListener] (default task-7) IJ000305: Connection error occured: org.jboss.jca.core.connectionmanager.listener.TxConnectionListener@2c9002eb[state=NORMAL managed connection=org.jboss.jca
.adapters.jdbc.xa.XAManagedConnection@2f318931 connection handles=0 lastReturned=1537182686997 lastValidated=1537178036483 lastCheckedOut=1537182688337 trackByTx=true pool=org.jboss.jca.core.connectionmanager.pool.strategy.OnePool@4439be43 mcp=SemaphoreConcurren
tLinkedQueueManagedConnectionPool@61b12a56[pool=ejb_timer-EJB_TIMER] xaResource=XAResourceWrapperImpl@6c390ba1[xaResource=org.jboss.jca.adapters.jdbc.xa.XAManagedConnection@2f318931 pad=false overrideRmValue=null productName=Oracle productVersion=Oracle Database
 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production jndiName=java:jboss/datasources/ejb_timer] txSync=TransactionSynchronization@336037344{tx=Local transaction (delegate=TransactionImple < ac, BasicAction: 0:ffff0a8300ee:-71e3a257:5b9f79b3:bbd status: 
ActionStatus.RUNNING >, owner=Local transaction context for provider JBoss JTA transaction provider) wasTrackByTx=true enlisted=false cancel=false}]: oracle.jdbc.xa.OracleXAException

Transaction Timeout in jBPM and Spring Boot

When running Spring Boot applications and jBPM you need to apply transaction settings differently.

Before Spring Boot 2.1.0 the application properties to configure Narayana Transactions are available in the Spring Boot documentation: https://docs.spring.io/spring-boot/docs/1.5.14.RELEASE/reference/html/common-application-properties.html

On the other hand, starting with the Spring Boot 2.1.0 release the Narayana starter uses the SnowDrop project. The SnowDrop project is basically an integration framework for Spring Boot applications running with JBoss products such as WildFly.

The list of properties you need to use are therefore available here: https://github.com/snowdrop/narayana-spring-boot/blob/main/narayana-spring-boot-core/src/main/java/me/snowdrop/boot/narayana/core/properties/NarayanaProperties.java

In conclusion, if you want to set the Transaction Timeout with Spring Boot and jBPM, you need to use the following property:

narayana.defaultTimeout=1200

Conclusion

Configuring jBPM 7 transaction timeouts is a critical aspect of maintaining system performance and stability in both WildFly and Spring Boot environments. By properly configuring transaction timeouts, you ensure that long-running transactions don’t cause resource bottlenecks or system failures.

In this article, we covered the steps to configure jBPM 7 transaction timeouts on both WildFly and Spring Boot. By following these guidelines, you can ensure that your jBPM-based applications perform optimally and handle transactions effectively, regardless of the runtime environment.

Found the article helpful? if so please follow us on Socials