How do I configure a transaction timeout in WebSphere Liberty Batch?

烈酒焚心 提交于 2019-12-05 12:03:31

(Edit 2016-12-02: Reworked with an explanation of the defaulting behavior when a timeout value of '0' is set for the application transaction).

Overview

Let me describe the application-level options and how that interacts with the server-level timeout.

In a chunk step in WebSphere Liberty Java Batch, you can either set an application-level timeout, or set a timeout value of '0' to default to a server-level timeout.

In addition, you can also set an upper bound for any non-zero application-level timeout value through a separate server-level setting.

Application-level timeout

The chunk transaction timeout can be set either:

In XML (static)

At the step level in JSL with special step property: javax.transaction.global.timeout (seconds)

E.g.

<step id="MyStep"> 
   <properties> 
      <!-- In seconds -->
      <property name="javax.transaction.global.timeout" value="120"/>   

If not explicitly defined in XML, it defaults to 180 (seconds).

In Java (dynamic)

If you need more dynamic/programmatic control you can implement a custom CheckpointAlgorithm and write its checkpointTimeout() to return whatever you want (a different value for each chunk even if you really wanted).

Server(JVM)-level timeouts

Setting an upper bound for application timeout values

You can prevent the application from setting too great a timeout value.

In the server config (server.xml) use propogatedOrBMTTranLifetimeTimeout :

<transaction propogatedOrBMTTranLifetimeTimeout="90s"/>

This will act as an upper bound on any non-zero application timeout value, either via javax.transaction.global.timeout or your checkpointTimeout() method,

Default timeout when application timeout is not set

In the case that the javax.transaction.global.timeout is set to '0' or the case that your checkpointTimeout() method returns '0', you will get a default timeout from the server.

This timeout value defaults to 120 seconds.

To change in the server config (server.xml) use totalTranLifetimeTimeout, e.g.:

<transaction totalTranLifetimeTimeout="60s"/>

Note:

As mentioned above, though, if javax.transaction.global.timeout isn't set at all the application timeout defaults to 180, and so the totalTranLifetimeTimeout does NOT come into play.

Other notes / references

Note: the WDT tool's Design View makes working with and remembering these server config attribute values much easier.

Mapping to WebSphere Application Server traditional config

The propogatedOrBMTTranLifetimeTimeout attribute here basically maps to the Maximum transaction timeout in traditional, while the totalTranLifetimeTimeout maps more obviously the Total transaction lifetime timeout in traditional.

Some nice examples are described within this documentation which are still largely relevant in Liberty.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!