Support > Wagby Developer Network(R7) > Batch processing > Basics of Batch Processing
ja | en

"Batch processing" created as another program can be linked with Wagby.

"Batch processing" means to perform some processing at the timing of button press or time specification.We will assume that database updating is involved in particular.

Developers can grasp the table structure of all the applications developed by Wagby.The table schema based on the model design is also automatically generated.Therefore, you can reference/update the table from another program.Based on this idea, we explain four ways to realize batch processing.

method Characteristic Points to consider
Stored procedure type It is completed in the database.The trigger function provided by the database and the scheduler function can also be used.(*) It is not possible to refer to Java objects prepared in the JVM.It is necessary to control locks and caches provided by Wagby from this batch program.
External program type You can use languages ‚Äč‚Äčother than Java.Call a program created with .NET or RPG, for example.
Java You can reuse Java code generated by Wagby. Job execution control is not performed.
Java (using SpringBatch) You can reuse Java code generated by Wagby. Job execution control is provided by the framework. I need to learn SpringBatch 's style.
Some database products have schedule execution function.Apart from Wagby, it is to use the unique features of the database.

When implementing batch processing with "stored procedure" or "external program (other than Java)", you need to consider locking and caching.Let's talk about locking here.

If the batch process to be realized falls under the following, you do not need to consider locking.

  • It does not involve updating/deleting data.For example, only referring to the value of the table, or only to register additional data.
  • Table managed by WagbyOther than.Data conflict does not occur with users using Wagby.
  • It is guaranteed that updating from Wagby will not be done while batch processing is running.For example, in a night batch,I switched Wagby to maintenance mode so as not to accept logon,Such.

In other cases, updating by batch processing is also executed in a state where there is a user using Wagby (may update).In this case, you need to properly lock the data and control write conflicts.

Optimistic lock and pessimistic lock

Wagby isYou can choose optimistic locks and pessimistic locks.From the viewpoint of creating a batch processing program, there are the following differences.

Lock method Optimistic lock Pessimist lock
Implementation method The table generated by Wagby includes "version control column".In the batch processing program, the value (numerical value) of this column is stored at the time of reading, and this value is updated by adding it to the where clause.If other users were updating this data, updating the data will fail because the version value has changed. Change the behavior of the lock manager provided by Wagby.Normally, lock objects are managed in memory, but they are written to the jfclockobject table.In the batch processing program, if there is a lock key in the jfclockobject table, do not update it.

In general, from the viewpoint of creating a batch processing program, the difficulty level of optimistic lock control is low.Although Wagby's standard is "pessimistic lock", it is a good idea to consider changing to an optimistic locking model that is also updated simultaneously from the batch processing program.

In either case, please suppress update/deletion when lock contention is detected in the batch processing program.This will keep your data safe.

When creating in Java

Even if it is written in Java, lock control is necessary if it is a program that directly executes SQL without using the Service class automatically generated by Wagby.

Lock control can be omitted if it is a program that reuses Service class automatically generated by Wagby.(All of these are controlled automatically by the Service class.This will be described in detail later.

Wagby keeps the value read from the database as a cache in the memory.This reduces the number of SQL occurrences and improves application performance.

Therefore, when implementing batch processing with "stored procedure" or "(external program other than (Java)"), it is necessary to clear the cache of the model that updated.

Using the REST API

From an external program,REST API to clear cacheYou can call.This method is the easiest.

Using the Service object

If the program that reuses the Service class automatically generated by Wagby is used, the cache clear processing can be omitted.(All of these are controlled automatically by the Service class.This will be described in detail later.