MASARYK U N I V E R S I T Y FACULTY OF INFORMATICS Big data processing with Spring Batch Bachelor's Thesis FILIP KOLLAR Brno, Spring 2023 MASARYK U N I V E R S I T Y FACULTY OF INFORMATICS Big data processing with Spring Batch Bachelor's Thesis FILIP KOLLÁR Advisor: prof. RNDr. Tomas Pitner, Ph.D. Centre of education, research and innovation in information and communication technologies Brno, Spring 2023 Declaration Hereby I declare that this paper is m y original authorial work, which I have worked out o n m y o w n . A l l sources, references, a n d literature used or excerpted during elaboration of this work are properly cited and listed i n complete reference to the due source. Filip Kollár Advisor: prof. R N D r . Tomáš Pitner, P h . D . iii Acknowledgements Firstly, I a m grateful to m y thesis advisor R N D r . Tomáš Pitner, Ph.D., for letting me work w i t h this topic a n d for his insights a n d guidance throughout the process of writing this thesis. Secondly, I w o u l d like to thank the people at InQool for providing an e a s y - t o - w o r k - w i t h environment a n d an opportunity to expand my knowledge a n d skills. I also thank Norbert Bodnár, a m u c h more experienced colleague f r o m InQool. W e w o r k e d o n the Kramerius+ project together, a n d although he has far more experience, he always discussed ideas and solutions w i t h me as an equal, contributing to my personal growth. Last, of all, I a m grateful to m y family. They p r o v i d e d me w i t h the opportunity to attend this university. I a m also thankful to all my friends for their encouragement. iv Abstract The main goal of this thesis is to describe how Spring Batch was used to reimplement and improve Kramerius+. Kramerius+ application builds u p o n a web application Kramerius a system powering digital libraries. Kramerius+ is an application that uses external natural language processing tools to enrich and export publications that contain large amounts of text data. Kramerius+ stores the enriched data to be used for better searching capabilities inside the text. The practical outcome of this thesis is refactoring Kramerius+, an application w i t h a REST A P I , to use the Spring Batch framework. The thesis showcases the framework and h o w it is used i n Kramerius+. Kramerius + is developed by an industrial partner of the Faculty of Computer Science - InQool a.s, i n cooperation w i t h the Library of the C z e c h A c a d e m y of Sciences, the National Digital Library of the Czech Republic, and the Moravian Library i n Brno. Keywords Kramerius, Kramerius+, TEI, A L T O , Publication, U P P i p e , NameTag, Spring Batch, Spring Boot, Job, Step, Batch, X M L , message broker, text data, metadata v Contents 1 Kramerius+ A p p l i c a t i o n Description 3 1.1 Input Documents and Data Storage 3 1.2 Utilizing Spring Batch i n Kramerius+ 5 2 Batch Processing Theory 7 2.1 Structure of a Job 7 2.1.1 Kramerius+ Job Abstraction 8 2.2 Step Configuration 9 2.3 Spring Batch Job Infrastructure 10 3 D e s i g n i n g Jobs 12 3.1 W r o n g Design Example 12 3.2 Flow of a Job 13 3.3 Stateful Components i n Spring Batch 15 3.3.1 Job and Step Metadata 16 3.3.2 Listeners 16 4 Kramerius+ Services 18 4.1 Requests and Their Entities 19 4.1.1 Enrichment Request 19 4.1.2 Export Requests 22 4.2 Kramerius+ Application Structure 24 4.3 Job Operation 25 4.3.1 Request Job control 25 4.3.2 Message Broker Comparison 26 5 Implementation of Jobs and Other Structures 29 5.1 Step Building 29 5.1.1 Closer Specification of Status 29 5.2 Job Building 31 5.2.1 Fault tolerance i n Kramerius+ Jobs 31 Bibliography 36 vi List of Figures 1.1 Kramerius+ data flow diagram 5 2.1 Spring Batch reference model [5] 8 2.2 Spring Batch interface hierarchy [5] 10 3.1 Enrichment External - three-step design 12 3.2 Enrichment External - single step design 13 3.3 Example of conditional flow from Kramerius+ 15 3.4 Listeners i n JobExecution 17 3.5 Listeners inside chunks 18 4.1 Enrichment request example 20 4.2 Class diagram of enrichment entities 22 4.3 Export request example - A L T O format 23 4.4 Export Entities class diagram 23 4.5 Kramerius+ implementation of enqueuing service - the message producer 27 4.6 The Kramerius+ implementation of a message consumer 28 5.1 Example of Step building - the ExportPagesText step from Kramerius+ 30 5.2 Example implementaion of StepListener from Kramerius+ 32 5.3 StepRunReport entity used to persist errors 33 5.4 StepError - a persistent representation of an exception . . 34 vii Introduction M o d e r n enterprise-grade application development is made possible through the usage of various frameworks and application development tools. Computer science engineers build u p o n previously built instruments to make even more powerful ones. This task is repeated to acquire higher abstraction, w h i c h provides a developer m a k i n g an application for a specific purpose w i t h a toolkit that simplifies development. M y aim is to introduce one of these tools and explain Kramerius+ processes and h o w these processes benefit from using this tool. The tool i n question is Spring Batch, a processing framework designed for b u i l d i n g batch applications. It provides many utilities used to set u p robust automatic jobs that r u n w i t h m i n i m a l user interaction. Kramerius+ is a web application that processes publication data i n Kramerius, a digital library. The thesis is written i n cooperation w i t h one of the industrial partners of the Faculty of Informatics - InQool. Chapter 1 introduces Kramerius + and its utilization of the Spring Batch framework. The following two chapters explain the core concepts of the Spring Batch. The m a i n focus of Chapter 2 is to describe h o w a job looks and is managed inside the framework. The chapter shows the internal structure of the framework for job operation and storage. It also talks about h o w Kramerius+ or any application can b u i l d on top of the native Spring Batch job structure. Chapter 3 shows the design of jobs. It describes h o w jobs are configured, introduces scopes for various job-related components, and introduces listeners. Chapter 4 is focused on Kramerius+. It thoroughly explains the design for the implementation of its two primary use cases and explains job operation w i t h message brokers. Chapter 5 mentions some implementation details of Kramerius+ jobs. It showcases various Kramerius + specific mechanisms used to extend the fault tolerance that Spring Batch offers. 1 The outcome is a Java-based REST A P I 1 that accepts requests that launch batch jobs that enrich or export digital publications. 1. A REST API is an application programming interface that conforms to the design principles of the REST or representational state transfer architectural style. [1] 2 1 Kramerius+ Application Description This chapter introduces the Kramerius+ web application connected to Kramerius, a digital library open-source system designed for digitized library collections [2]. Kramerius+ retrieves data from Kramerius and uses external natural language processing tools to enrich publications. Its two most prominent use cases were to enrich publications by adding metadata and to index publications for better searching capabilities using this metadata. However, this changed, and now Kramerius+ supports two primary use cases enrichment and export. Indexing became a part of a different module of the D L 4 D H project. Enrichment and export operations have more specific subtypes, determining what tools w i l l be used. In general, enrichment processes aim to append metadata to existing data from Kramerius. O n the other hand, export operations take data saved i n either Kramerius or Kramerius+ and create zip archives containing the publication and its metadata i n multiple formats. 1.1 Input Documents and Data Storage This section describes Kramerius+ input documents and the need for internal data storage for metadata created by its enrichment jobs. A s previously mentioned, Kramerius + utilizes the existing A P I - Kramerius l Inside Kramerius, the two most important objects are publications and pages. Publications come i n different structures depending on the type of publication. A t the tree's root, there is always a publication object containing metadata about the publication. It also includes a list of ids of other objects representing its children. Based on the type of publication, its tree has a variable height, and the last layer - the leaves are always page objects. Pages do not have subtypes or children; they are always the same, regardless of publication type - they only contain streams. 1. A n application programming interface is a way for two or more computer programs to communicate with each other. 3 i . KRAMERIUS+ APPLICATION DESCRIPTION To access an object on the Kramerius A P I , its ID needs to be specified, after w h i c h Kramerius returns a J S O N 2 containing its metadata. For pages, we can also access a list of their streams by adding a postfix - streams. This w i l l result i n a list of available data streams for the specific page. The most c o m m o n ones are T E X T _ O C R3 - containing raw text content of the page, and B I B L O _ M O D S 4 - containing bibliographic data. The most utilized format i n Kramerius+ is A L T O 5 . Data from this format is extracted and used internally inside Kramerius+. A publication does not have streams. It only contains metadata. A s mentioned before, publications are tree structures. For example, monographs either include pages directly or monograph units that include pages. Periodical trees have a variable amount of layers. Periodicals mostly contain periodical volumes representing years inside a magazine and then periodical items representing individual issues of the magazine containing pages directly. Kramerius+ saves the entire structure, including pages (excluding their streams), inside a non-relational database - M o n g o D B . The primary purpose of this storage is to append additional metadata to publications and pages. This metadata is mainly used by other m o d ules inside the D L 4 D H project or to create exports i n Kramerius+. 2. JavaScript object notation language 3. Optical character recognition of text 4. Bibliographic modifiers 5. A n XML-based text format [3], X M L - Extensible Markup Language 4 i . KRAMERIUS+ APPLICATION DESCRIPTION Enrichment TEI Publications along with page data =ririi;lňi (iiiiiliraliii'i ^rilpaje .:: User A V ( J \ interface graphical .. .j . .. j ... Enriched publication and page data Publication and p: External NLP lools, NDK III requests to display di A Publication and page dala Enrfched publication and page data V ( 1 N ( \ ^1 Enrichment I Data and metadata provision, Enrichment aihianceri searchingEnrichment I J Figure 1.1: Kramerius+ data flow diagram 1.2 Utilizing Spring Batch in Kramerius+ Processes i n Kramerius+ are complex, and they work w i t h large amounts of data, which was an issue before Kramerius+ was designed to use Spring Batch. The main concerns were stability and speed. Implementing all the logic for enriching and exporting inside the service layer w o u l d be almost impossible, resulting i n low performance and stability. Spring Batch has many responsibilities. A running job that might fail and throw an exception w o u l d not violate the state of the running application. It w o u l d only influence the execution of the specific job. Spring Batch handles errors and also enables the configuration of skipping or retrying logic for invalid records. For example, y o u can skip invalid records by configuring a skip policy for a job. Spring Batch also offers retry logic configuration. This can be used w h e n retrieving data from an API. For example, the A P I might become unavailable for a moment, so trying again might result i n success. 5 i . KRAMERIUS+ APPLICATION DESCRIPTION A s mentioned above, speed was also a concern. Spring Batch offers a configuration of batch sizes. That means data is coupled and processed i n desired amounts. This coupling is most efficient w h e n it comes to processing pages. Processing data i n pre-defined batch sizes resolved many problems. Previously the application w o u l d force the J V M 6 to r u n out of allocated memory w h e n fetching all publication pages or even w h e n obtaining pages one by one. Publication processing does not require coupling and speed since they only contain some metadata. Lastly, there is a monitoring concern. W h e n a user creates a request for multiple publications, errors are bound to occur. The pages inside Kramerius tend to miss streams sometimes. The Kramerius A P I might become unavailable d u r i n g processing, or even some of the tools Kramerius+ uses for processing might return data that cannot be parsed and saved. Because of this, monitoring a job's state is necessary. Spring Batch handles monitoring and provides constructs to improve the extent to w h i c h jobs are monitored. 6. J V M - Java Virtual Machine 6 2 Batch Processing Theory This chapter serves as a basic overview of h o w batch jobs w o r k containing some specifics for Spring Batch. M a n y patterns s h o w n here are shared among different batch-processing APIs. These frameworks commonly support X M L - b a s e d job configuration; i n Kramerius+, all configuration is done programmatically i n Java. Spring Batch's newest version, 5.0, requires Java 17. However, Kramerius+ still runs on an older version: 2.6.5, along w i t h Java 11. A batch application must be robust due to the sheer volume of data it processes. It must do this w i t h m i n i m a l user interaction and w i t h m a x i m u m verbosity. M a n n i n g describes the following requirements for batch applications [4]: • Large Data Volume - Batch applications must be able to handle large amounts of data • Automation - the application requires minimal user interaction. User intervention is a last resort • Robustness - handling minor faults effortlessly and failing on major faults gracefully • Reliability - batch applications need to be well monitored • Performance - jobs inside batch applications need to be well scalable and not interfere w i t h each other 2.1 Structure of a Job The central entity i n Spring Batch is a Job. A Job is an entity that encapsulates an entire batch process [5]. A Job is composed of Steps. A Step should be designed to logically encapsulate a sequential phase i n a Job. Steps can be partitioned for extra scalability. Steps are built from processing units to be task-oriented 1 (Tasklets) or chunk-oriented 2 (ItemReader, ItemProcessor, ItemWriters). 1. Completing a single task that is not necessarily repeated 2. Split data into batches, complete a task over a single batch or chunk 7 2. BATCH PROCESSING THEORY Jobl_3unctier 1 * X i 1 • I I ItemProcessor JobRepDsitory Figure 2.1: Spring Batch reference model [5] The first component, Job, is an interface. It is abstract. It represents a logical task that can be repeated, but to r u n , it needs specifics JobParameters 3 . For example, a Job could be reading records from a file and writing them to a database, an abstract task representing a Job. If a Job is to run, it needs parameters, such as a file name. After parameters are identified, a Joblnstance is created. Joblnstance represents a specific Job run. The same Job may, for example, fail and be needed to restart. This scenario is w h y JobExecution is defined - it represents a single attempt at running a Joblnstance. This entity contains m u c h helpful metadata for a batch application user, such as timestamps and statuses. This entity also provides a w a y to pass data inside the context of its execution - ExecutionContext. It is implemented as a map and should only be used for small amounts of data. Jobs are built from Steps, which are sequential independent phases of a Job [5]. Steps contain specific configurations describing h o w to read and write data, or they can even execute some processing logic on the data after reading it. Steps also come with StepExecutions they are analogic to Jobs and JobExecutions. StepContexts are also analogic to JobContexts. 2.1.1 Kramerius+ Job Abstraction Kramerius+ has requirements surpassing the capabilities of Spring Batch's Job infrastructure, so Kramerius+ needed an additional abstraction over Spring Batch Joblnstance. The two main things that this 3. A wrapper class for a map containing key-value pairs 8 2. BATCH PROCESSING THEORY abstraction adds are StepRunReports - an entity that monitors errors that happen during the processing of a publication. The second one is a launch status. StepRunReports are a persistent way of logging failures that occur d u r i n g publication processing. Throughout Kramerius+'s development, many cases occurred where data was i n an illegal or unexpected format. So it became necessary to save details about errors occurring on specific pages or publications. Launch status was created for the sake of user-friendliness. Kramerius+ jobs often have prerequisites for their runs. To avoid launching jobs that could never be completed or even to prevent illegal states of data in the application, Kramerius+ validates that a job can be run. Information about a launch attempt persists inside the LaunchStatus entity embedded inside Krameriusjoblnstance. 2.2 Step Configuration Tasklets are used w h e n configuring Steps meant to complete a single task. They are created by implementing the Tasklet interface. Tasklet Steps can be replaced by chunk oriented and vice-versa. Chunk-oriented steps split data into configured chunk sizes, which is practical w h e n reading paginated data. They are built f r o m three components: ItemReader, ItemProcessor, and ItemWriter. These interfaces only serve to separate concerns logically. It is possible to use the ItemReader for the entire task, but not only w i l l this lead to messy code, but it w o u l d also make chunk size configuration irrelevant because the writing logic w o u l d be executed o n each item one by one. The ItemReader interface serves as a contract for a component that will read items to be processed. Spring Batch offers various implementations that can be used w i t h m i n i m a l configuration 4 . ItemReader implementation should only read items. Additional logic should be left for the ItemProcessor. Returning null means that there are no more items to be read. Next comes the ItemProcessor. Items read by ItemReader are passed to this component. They can be used to validate and filter data and to execute business logic. They are vastly used i n Kramerius+. For better 4. File readers, JDBC based database readers 9 2. BATCH PROCESSING THEORY logical decomposition, Batch offers the CompositeltemProcessor i n terface. This interface is handy w h e n performing multiple operations on data and allows the programmer to split and isolate the concerns of each processor. Lastly, the Item Writer interface allows for implementing components responsible for saving read and processed data. A n ItemWriter w i l l always receive the data i n a chunk of configured size. 2.3 Spring Batch Job Infrastructure This subsection introduces components that service Jobs. Spring Batch provides default implementation and configures most of the required beans. Spring Batch infrastructure is built o n four p r i m a r y interfaces: JobRepository, JobExplorer, Job Launcher, and JobOperator. These i n terfaces provide control and overview for Jobs. Spring Batch entities are abstracted well, and using its high-level interfaces takes care of nested entity creations. operations Figure 2.2: Spring Batch interface hierarchy [5] JobRepository provides C R U D 5 operations that communicate w i t h the data layer. It is responsible for all Job metadata entities. It is a high- 5. Create, read, update, delete 10 2. BATCH PROCESSING THEORY level interface that works w i t h entities directly. For JobRepository Kramerius+ uses the H 2 database technology i n embedded mode. It is fast and S Q L based. This technology also provides a browser-based console application w h i c h makes access simple and does not require additional software to view tables [6]. The next one: JobExplorer, offers encapsulation by only providing reading operations. It is used to v i e w metadata about Spring Batch entities. JobLauncher is an interface directly above the JobRepository. It only has one method: r u n w i t h a Job and its JobParameters as input parameters. It is a high-level interface, and its implementations should take care of all overhead and entity creation that running a Job requires. Its default implementation: SimpleJobLauncher, does precisely this, but for Kramerius+, a more custom one was needed. JobOperator combines all of the interfaces described above. It is low-level, working with primitive types for its return and input values. It provides additional control methods besides running for Jobs, such as stop and restart. 11 3 Designing Jobs This chapter serves as an overview of designing Jobs i n the Spring Batch framework. Analysis and design of an application are crucial w h e n it comes to b u i l d i n g a sizeable m o d e r n system. W h i l e Job creation is a problem of a m u c h smaller scale, the analysis of its purpose and the design of its components can help avoid faults. Later i n the chapter, ways of configuring Spring Batch Jobs for non-linear flow and parallelization are mentioned. 3.1 Wrong Design Example W h e n designing the Enrichment External Job inside Kramerius+, a mistake was made where the b a d decomposition of a Job into Steps created extra concerns and slowed the Job down. Enrichment External Job uses three tools to enrich page content: A L T O metadata extraction 1 , U D P i p e external tool [7], and NameTag tool [8]. Each of these tools was isolated into a processor i n a Step resulting i n three steps i n total. MongoPageRearier: readQ > Page -r\r crPageFramnltoProcessor: process(Page item) -> Page MongoPageWriter: vjrite(List void Step - EnrichPagesFromAltoStep MnngoPageReadet: reari() > Page EnrichPageUDPipePro process(Page item) -> Page MongoPageWriter: write(List items) -> void Step - Enrich PagesUDPipeStep Jab - EnrichmentExternal MongoPageReader: readQ > Page EnrichPageNameTagPro process(Page item) -> Page MongoPageWriter: write(List items) -> void Step - EorichPagesMameTagStep Figure 3.1: Enrichment External - three-step design The first problem was that all of these tools used the content of a page. A Step starts by reading data and ends by writing data. Decomposition into three steps means reading and writing the data three times instead of once. N o t only is this slowing the Job d o w n , but it also creates room for failure. 1. Extraction of data from documents in the previously mentioned ALTO format 12 3- DESIGNING JOBS The second problem violates the principle that Batch dictates. The principle i n question: A Step is a domain object that encapsulates an independent, sequential phase of a batch job. In enrichment external, after processing the data by a tool, the output is passed to the second tool, and so on. This means they depend on each other and should not be separated into individual Steps. Spring Batch even offers support for this by grouping ItemProcessors into a CompositeltemProcessor. Using the CompositeltemProcessor massively reduces the boilerplate code configuring a Job requires.2 This processor implementation is not type-safe, meaning the compile w i l l not detect type mismatches, w h i c h may lead to r u n time failures.Figure 3.2 MongoPageReader: read() -> Page EnrichPageFromAltoProcessor: process(Page item) -> Page EnrichPageUDPipeProcessor: process(Page item) -> Page EnrichPageNameTag Processor: process(Page item) -> Page EnrichPageExternalCompOsitePrOcessOr MongoPage Writer: write(List items) -> void Step - EnrichPagesExternalStep Job - EnrichmentExternal Figure 3.2: Enrichment External - single step design 3.2 Flow of a Job Spring Batch uses multiple different implementations of Job. The i m plementation depends on how the Job is built, mainly on the transitions between Steps. The most straightforward flow of a job is a sequence of sequential Steps.3 . This implementation puts Steps into a list and iterates through 2. Additional Steps do not need to be configured and added to the Job 3. Simplejob implementation is used in these cases 13 3- DESIGNING JOBS them, disregarding their exit statuses. However, if an exception is thrown, the Job still transitions into a failed state. Spring Batch offers conditional flow configuration 4 , meaning a Step may lead to multiple different Steps or even be stopped depending on the outcome of the Step. O n the inside, the implementation models the individual Steps as nodes i n a graph and exit statuses as edges between these nodes. It automatically creates a node representing the failed and successful state of the Job. Same as Simplejob implementation, throwing an exception automatically transitions the Job into a failed state. Spring Batch also supports Step partitioning and executing Steps in parallel. There are five ways to parallelize work in Spring Batch: dividing work via multithreaded steps, parallel execution of full steps, asynchronous ItemProcessor/ItemWriter configurations, remote chunking, and partitioning of Steps. [9] A practical example of utilizing FlowSteps are export operations in Kramerius+. W h i l e exporting files, they are continuously created into a temporary directory that needs to be z i p p e d . After finishing the Job, temporary files need to be cleaned up. However the files still need to be cleaned even if there is a failure in the Job and they are not completed. 4. The Job builder automatically transitions to a FlowJobBuilder and upon building a FlowJob is returned 14 3- DESIGNING JOBS Flow of an export job in Kramerius+ Color reflects ExilSlalus of Step, GREEN = SUCCESS, RED = FAILED Figure 3.3: Example of conditional flow from Kramerius+ 3.3 Stateful Components in Spring Batch One of the integral aspects of Spring Framework that Spring Batch is a part of is Spring's Inversion of Control Container (IoC) and beans. [10] Spring instantiates classes marked as beans inside the IoC container. By default, a bean is scoped as a singleton - meaning there is just one instance i n the container. Some consider this type of design an anti-pattern because it introduces an application-level global state [11]. Each bean is used i n many others as a dependency. The best practice is to make these beans stateless. However, this technique can not be used w h e n implementing components used by Jobs and Steps. These entities have a state that is relevant to a specific context. It is impossible to design these inside the singleton scope. Spring Batchs components require state. For example, Spring Batch collects various metadata about Step components. Like read, process, write, and commit counts. Spring Batch provides syntactic sugar 5 for Job and Step scopes. Instead of annotating a component as @Scope(value= "job", proxyMode=targetClass), it is simpler to write ©JobScope or ©StepScope. 5. Meaning syntax that is designed to make things easier to read 15 3- DESIGNING JOBS This mechanism allows Spring to instantiate components on Job or Step startup, allowing for parameters and configuration specification at a Job or Step runtime. It also allows the existence of Job and Step instance-specific data like JobParameters and Contexts for both entities, respectively. 3.3.1 Job and Step Metadata JobParameters are what defines Joblnstances i n Spring Batch. Each Joblnstance must be set apart by a unique identification set of identifying JobParameters. They must be able to be compared to each other easily. They are restricted to simple types: String, double, boolean, Date, and Long. This same rule applies to contexts, but contexts do not identify a Job. In practice, contexts are the most useful for us w h e n passing around data created i n processing, for example, filenames or created entity ids. Both contexts and parameters are serialized and persisted for safety. Context and JobParameter values can be injected into Step or Jobscoped components for usage, using Springs ©Value annotation. For JobParameters, use SpEL 6 : $jobParameters[paramName]. JobExecutionContext is addressed as jobExecutionContext, and StepExecutionContext is stepExecutionContext. 3.3.2 Listeners Spring Batch offers listeners for various of its aspects. These listeners provide hooks into different parts of a lifecycle of these aspects. [9]. Each of these callbacks is executed as early and late as possible i n the lifecycle of Spring Batch objects. These aspects can be utilized for different use cases, for example: • M o n i t o r i n g or notifying - Kramerius+ primarily utilizes this case. It uses these callbacks to m o d i f y Step exit statuses to reflect the outcome of a StepExecution. Otherwise, it is used for logging. Some systems c o u l d even utilize emailing or other types of notifications 6. Spring Expression Language 16 3- DESIGNING JOBS betoreStep betoreChunkbetoreStep betoreChunk Lifecycle of a signle chunk or batch onChunkError StepExecution lifecycle JobExecutiort lifecycle Figure 3.4: Listeners i n JobExecution • Initializations - i n before methods, if some preparations need to be done before a Job or Step is executed, may be used for file creation as well • Cleanup - for example, remove created files i n after methods Spring Batchs implementation of a Step registers user-defined listeners that implement provided interfaces and calls the methods at an appropriate time. Defining more custom listener interfaces w i t h additional methods w o u l d require a custom implementation of a Step. Listener methods can also be configured through annotations. 17 beforeCliunk afterChunk Figure 3.5: Listeners inside chunks 4 Kramerius+ Services A s mentioned previously, Kramerius+ is a web application that offers its services through a REST A P I . W h e n Kramerius+ endpoints receive a request, a cascade of operations is executed, depending on the endpoint. Some endpoints require complex operations, like starting enrichment or exports. Others are meant to control the Jobs launched by these operations. Moreover, there are some read APIs to retrieve data about requests and Jobs or retrieve files. This chapter talks about h o w Kramerius+ services request creation and runs its Jobs. Creating entities for a single request and launching its Jobs is complicated because of the structure input documents come in. 18 4- KRAMERIUS+ SERVICES 4.1 Requests and Their Entities Kramerius+ supports two main types of operations, enrichment and export, w i t h their specific subtypes. These operations can be performed over publication ids found i n Kramerius. 4.1.1 Enrichment Request The first type of request is enrichment. Enrichment is an operation that appends metadata and para data 1 to existing publication data fetched from Kramerius, then stores it inside a M o n g o D B database for later i n Kramerius+. There are three types of enrichment Jobs. The first type - Enrichment External utilizes previously mentioned public tools U D P i p e 2 and NameTag 3 . O n the inside, Kramerius+ uses Spring's WebClient to post requests to these tools, then retrieves the data and parses it internally into objects that are further processed or finally serialized and stored. The second type - Enrichment TEI 4 . TEI is a consortium that collectively develops and maintains a standard for the representation of texts i n digital form. Its chief deliverable is a set of Guidelines that specify encoding methods for machine-readable texts, chiefly in the humanities, social sciences, and linguistics. [12] Kramerius+ takes internally stored publication data and sends it to the A P I of the application TEI converter 5 , w h i c h converts all the data, including pages, into the TEI format and saves them as a file for later use. Lastly, there is enrichment N D K6 . This type of enrichment is done by extracting publication metadata from files provided by the National Library of the Czech Republic. Kramerius + finds the matching file for a specific digital object and extracts the needed data internally. These X M L documents are large, and only some elements inside them are relevant, which means they need to be parsed, and needed data needs to be extracted. 1. Para data - data about metadata, UDPipe and NameTag return timestamps of usage and their version on use 2. N L P tool for tokenization and lemmatization of text in C o N L L - U format [7] 3. N L P tool for recognition of named entities[8] 4. Text Encoding Initiative 5. A python-based application, developed as a part of the D L 4 D H project[13] 6. (National Digital Library - translation: Národná digitální knihovna) 19 4. KRAMERIUS+ SERVICES 1 { 2 "name " : "Example Enrichment Request", 3 " p u b l i c a t i o n l d s " : [ 4 "uuid:0c94cf70-188a-lle4-8f64-005056827e5 "uuid:fd326900 -7245 -11e9-b253-00505 682' 5 ] , 6 "conf igs": [ 7 8 9 { "jobType" : "override" "ENRICHMENT_EXTERNAL" , : true 10 11 { 12 " j obType " : "ENRICHMENT_TEI" 13 } , 14 { 15 " j obType" : "ENRICHMENT_NDK" 16 } 17 ] 18 } Figure 4.1: Enrichment request example Enrichment request requires the following parameters: a list of publication ids and configurations - a configuration can be External, TEI, or N D K . For organization purposes, the user can specify a name for the request. There is also an override parameter for enrichment operations specifying whether the request is allowed to overwrite existing enrichment data. X M L Parsing Approaches S A X - simple A P I for X M L , the most w i d e l y adopted A P I for X M L , and is considered the standard. It uses an event-driven mechanism, m a k i n g it fast and lowering its m e m o r y consumption. It does not require an immediate internal Java representation of an object but instead parses the X M L document top-down and reports encountered 20 4. KRAMERIUS+ SERVICES nodes to the application. The application provides an event handler an object responding to an encounter of the specific element. [14] D O M - the document object m o d e l parses the X M L b y deserializing 7 the document into a Java object. This mechanism is more straightforward than S A X . The D O M parses and maps a document into a tree rooted at a document node, which provides the application w i t h a structure that can be searched, read, or updated. [14] Kramerius+ needs to retrieve specific information f r o m the document, assign it to the relevant digital object, and save it into the database. Even though a D O M can take up to ten times the size of the original X M L document [15], it is the more convenient implementation to use for this use case. S A X usage w o u l d be more appropriate for streaming the X M L data and, as such, is preferable just for m a p p i n g files onto objects that are inserted into a database. The enrichment process is built on three entities: • EnrichmentRequest contains configs f r o m the request, it references its child entities - EnrichmentRequestltem, and a Job w h i c h creates the request • EnrichmentRequestltem - this entity is specific to one of the publication IDs that was specified i n the request. It also contains some metadata and its child elements - EnrichmentChains. • EnrichmentChain - the lowest entity represents a chain of Jobs that must be executed on a single publication ID. Since publications come i n tree structures sometimes, it is necessary to have an entity responsible for the enrichment of each node i n the tree. Pages are processed within the Job processing their parent publication, meaning they do not have an EnrichmentChain w i t h Jobs assigned. They are processed w i t h i n the Job processing their direct parent. A l l entities are created w h e n a request is submitted i n the create request Job, and the first Job i n each EnrichmentChain is enqueued i n the last Step of its creation. They are enqueued i n the same order as they are created. 7. Deserialization - building data structured in some format into a transient object 21 4. KRAMERIUS+ SERVICES Enrich mentRequ est 1 Enrichm en tRequ estltem 1 Enrich mentChain -owner: User -name : String -publicationlds : List -state : En urn -createRequestJobld : String 1 -publicationId : String -publicationTitie : String -model : Enum Harder: Long -enrichmentRequestkl : String -state : Enum 1 -publicationkl : String -publicationTitie : String -model : Enum -owner: User -name : String -publicationlds : List -state : En urn -createRequestJobld : String -publicationId : String -publicationTitie : String -model : Enum Harder: Long -enrichmentRequestkl : String -state : Enum -order: Long -reqijestltemld : String -joblds : List Figure 4.2: Class diagram of enrichment entities 4.1.2 Export Requests Export i n Kramerius+ comes i n five different formats. However, unlike enrichment, users cannot request multiple formats for one publication ID set. Requests only take i n one config, which specifies the format of the export and also specifies different parameters that are specific to the format. For example, the user can specify a delimiter for the C S V format. The following formats are supported: • text - a plaintext format, pages create .txt files. • A L T O - the previously mentioned X M L - b a s e d format. • C S V - standard inline format, one line per token i n each page file. • J S O N - the JavaScript Object Notation format. • TEI - a single X M L file i n TEI format. To create this file, Kramerius+ uses TEI converter The export operation also comes with two specific Jobs. First is the analogic operation to enrichment request creation - export request creation. The second only applies to export since it creates an individual zip archive for each publication. These archives are later merged into one zip archive containing all individual archives - merge Job. 22 4- KRAMERIUS+ SERVICES 1 { 2 "name" : "Export Request Example", 3 "conf ig " : { 4 "jobType": "EXP0RT_ALT0" 5 } , 6 " p u b l i c a t i o n l d s " : ["uuid : 9d73aa50 -4083 -11 ed-80d2-5 ef 3f c9bb22f " , "uuid:fd326900 -7245 -11e9-b253-00505 6827e52 " ] 7 } Figure 4.3: Export request example - A L T O format The export operation is built o n the following entities: • ExportRequest - specifies the format, the request creation job, the merge job, and also its child Exportltem entities. • ExportRequestltem - specifies the publication ID of one entity per ID i n the request. It also references a single Export representing the root of the export of the publication. • Export - this entity represents a single directory. It contains some files i n specified format - pages, or it contains children's Exports - more directories. t ExportRequest 1 ExportRequestltem 1 Export 1 -owner: User -name : String -publicationlds : List -state: Enum -createRequestJobld : String -mergeJobld: String -file: File -bulkExportState : Enum 1 -publicationld : String -publicationTitle : String -exportRequestld : String -order: Long -rootExportld : String -state: Enum 1 -publicationld: String -publicationTitle : String -file : File -parentld: String -state : Enum -format: Enum -model : Enum -order: Long -exportJobld : String 1 -owner: User -name : String -publicationlds : List -state: Enum -createRequestJobld : String -mergeJobld: String -file: File -bulkExportState : Enum -publicationld : String -publicationTitle : String -exportRequestld : String -order: Long -rootExportld : String -state: Enum 1 -publicationld: String -publicationTitle : String -file : File -parentld: String -state : Enum -format: Enum -model : Enum -order: Long -exportJobld : String Figure 4.4: Export Entities class diagram 23 4. KRAMERIUS+ SERVICES Again all entities are automatically created w h e n an export request is submitted. The process works i n post order 8 starting at the bottom of a publication tree, working its way up to the root, wrapping exports in their parents' directories as needed, then zipping the root directory. After each ExportRequestltem is complete, they are merged into a single zip file. The individual files are still available on the file download A P I by design. 4.2 Kramerius+ Application Structure Kramerius+ is split into four modules i n total. This decomposition is done to separate concerns into each module as well as possible. These modules follow the Spring Boot architecture 9 . The first layer (presentation) is handled by two modules: rest and api. The rest module defines all the controllers w i t h their endpoints. The application is secured through K e y c l o a k 1 0 authentication utilizing J W T n . T h e api module contains definitions of D T O s 1 2 that are visible to the public through the controllers. Under the A P I module, there is the service module (representing the service layer). The service module communicates w i t h the data layer inside the core module, described later. The p r i m a r y purposes the service layer takes care of i n Kramerius+ are reading data and, initializing the request, creating jobs responsible for further data creation. The core module is the most extensive module of Kramerius+. It contains data adapters, JPA entity definitions, and the Spring Batch configuration. It connects external tools with WebClients and contains configuration for message listeners. 8. Post order - traverse the left subtree, then traverse the right subtree and visit the root 9. Application is split into a presentation, service and data layer 10. Keycloak is an open source and identity management technology 11. JSON web tokens 12. Digital Transfer Object 24 4- KRAMERIUS+ SERVICES 4.3 Job Operation Spring Batch declares a JobLauncher interface. This interface contains a single method - run. Its input parameters are a Job and its JobParameters these two objects are enough to specify a Joblnstance, that can be run. However, i n Kramerius+, we use Krameriusjoblnstance, an entity that serves as an extension or an abstraction of Spring Batch Joblnstance. Kramerius+ defines its launcher not within the Spring Batchs contract. It takes an i d of an already created Krameriusjoblnstance. The service layer receives enough information to instantiate a single Krameriusjoblnstance - the create request Job. This create request Job is automatically r u n using the custom Job launcher implementation. This custom Job launcher definition is very similar to Spring Batch's default implementation SimplejobLauncher. The m a i n difference is the creation of a Job instance inside the launcher. Since Krameriusjoblnstance is created, the launcher only creates Batch entities using its Job repository. 4.3.1 Request Job control Since a single Job i n Kramerius+ takes a long time to r u n , the user w o u l d be stuck waiting for a response after submitting a request. A message broker can be used to address this issue - instead of running a Job, Kramerius+ sends a message w i t h the corresponding Job i d . It utilizes A c t i v e M Q 1 3 for this purpose. The servicing of a request ends by enqueuing its create request Job. A s mentioned before, this Job initializes all needed KrameriusjobInstances and enqueues them automatically. A part of this process is downloading publication data from the Kramerius A P I , w h i c h creates a need to r u n this process asynchronously. Other than creating and r u n n i n g requests, Kramerius+ allows the cancellation of requests. This operation requires disabling the ability to be run for all enqueued Jobs. Jobs under the requests that are completed are not a concern. However, the running Jobs still need to be stopped. Stopping a Job can be done by using Batchs JobOperator, w h i c h has a method for sending a Stop signal to a Job. The request 13. A specific message broker technology 25 4. KRAMERIUS+ SERVICES fails depending on whether the signal was successfully sent to all the Jobs. 4.3.2 Message Broker Comparison Kramerius+ required a one-to-one message broker. There were two candidates considered: A c t i v e M Q and R a b b i t M Q . In this scenario, Kramerius+ is both the sender and consumer of messages. • R a b b i t M Q is an open-source message broker that implements the A M Q P 1 4 . This is a universal protocol that mandates the behavior of client and server messaging i n such a w a y that implementations from different vendors are interoperable. • A c t i v e M Q is an open-source message broker written i n Java implementing the JMS 1 5 standard. JMS-based applications can only connect one Java-based application to another. Both of the message broker choices fulfill the requirements Kramerius+ has for its message broker, nontransient - persistent messages, scaling, and good performance. The performance comparison is very close, but RabbitMQ wins i n this aspect. The test results indicated that ActiveMQ has faster message reception (receiving messages f r o m the client), but R a b b i t M Q has quicker message production by a larger margin (the client receives the message faster). [16] A l t h o u g h R a b b i t M Q w i n s i n the performance department and satisfies our previously mentioned needs, the configuration for messaging i n the A M Q P protocol is more difficult since Kramerius+ is a Java-based application configuration of a JMS producer and consumer was m u c h more straightforward. 14. A M Q P - Advanced Message Queuing Protocol for message-oriented middle- ware 15. Java Messaging Services - another message-oriented middleware 26 4. KRAMERIUS+ SERVICES OComponent BSlf4j public class JmsProducer implements JobEnqueueService { private JmsTemplate jmsTemplate; OOverride public void enqueue(KrameriusJoblnstance job) { log.info("Attempting Send message : " + j o b . g e t l d O ) ; j msTemplat e .convertAndSend(job.getJobType().getQueueO, j o b . g e t l d ( ) ) ; } OOverride public void enqueue(KrameriusJoblnstanceDto jobDto) { log.info("Attempting Send message : " + j obDto.getld()); j msTemplat e .convertAndSend(jobDto.getJobType().getQueue j obDto.getld()); } @Aut owired public void setJmsTemplate(JmsTemplate jmsTemplate) { this.jmsTemplate = jmsTemplate; } } Figure 4.5: Kramerius+ implementation of enqueuing service - the message producer 27 4. KRAMERIUS+ SERVICES OComponent public class JobListenerService { private JobRunner jobRunner; @JmsListener(destination = ENRICHMENT_QUEUE, concurrency = "3-5") public void listenEnrichment(String krameriusJoblnstanceld) { j obRunner.run(krameriusJoblnstanceld) ; } OJmsListener(destination = EXPORT_QUEUE, concurrency = "1-3") public void l i s t e n E x p o r t ( S t r i n g krameriusJoblnstanceld) { j obRunner.run(krameriusJoblnstanceld) ; } 0JmsListener(destination = DEFAULT_QUEUE, concurrency = "1-2") public void 1istenDefault(String krameriusJoblnstanceld) { j obRunner.run(krameriusJoblnstanceld) ; } OJmsListener(destination = PRIORITY_QUEUE, concurrency = "1") public void l i s t e n P r i o r i t y ( S t r i n g krameriusJoblnstanceld) { j obRunner.run(krameriusJoblnstanceld) ; } @Aut owired public void setJobRunner(JobRunner jobRunner) { this.jobRunner = jobRunner; } Figure 4.6: The Kramerius+ implementation of a message consumer 5 Implementation of Jobs and Other Structures Spring Batch provides conveniences for Step and Job building through its helper classes StepBuilder and JobBuilder, which utilize the builder pattern. The builder is a creational pattern that allows the construction of complex objects step by step instead of creating an object and passing its components into a constructor. The builder pattern lets its user append each component, reducing parameter redundancy. [17] 5.1 Step Building Building a Step requires specifying all its components. The first thing needed to specify is the chunk size for the Step. If the chunk size is not specified, the Step is assumed to be task-oriented. C h u n k size determines h o w many items are read and processed before being written. A l o n g w i t h chunk size, the type of object that an ItemReader w i l l read and the type that the ItemWriter w i l l write need to be specified. Another aspect is listeners. Each Step i n Kramerius+ uses two listeners—the ExecutionContextPromotionListener - a component responsible for promoting keys and values from the StepExecutionContext to the JobExecutionContext. The second one StepFailureListener is a workaround for updating the exit status of a Job - after the Step ends, there is a hook - the after-step method. This mechanism is used to retrieve stored failure exceptions. The exit status is modified according to the error code i n the exception i n case it is one of Kramerius+ custom exceptions, otherwise, it is set to a status representing unexpected failure. 5.1.1 Closer Specification of Status In Kramerius+, the Steps needed to be as verbose as possible about their executions,this required some additional support on top of the fault tolerance and monitoring the Spring Batch framework offers. 29 5- IMPLEMENTATION OF JOBS AND OTHER STRUCTURES @Component public class ExportTextStepDesigner extends AbstractStepDesigner { private KrameriusPageReader reader; private TextPageExportProcessor processor; private DigitalObjectFileltemWriter writer; @Bean(EXPOR.T_TEXT_PAGES_STEP) OOverride public Step build() { return getStepBuilder() • chunk(5) .reader(reader) .processor(processor) .writer(writer) .build(); } OOverride protected String getStepName () { return EXPORT_TEXT_PAGES_STEP; } //...setters for components y Figure 5.1: Example of Step building - the ExportPagesText step from Kramerius+ 30 5- IMPLEMENTATION OF JOBS AND OTHER STRUCTURES The Steps i n Kramerius+ process hundreds of pages, and the user can specify fault tolerance o n these pages i n their request. This k i n d of configuration could be done alone w i t h SkipPolicy 1 . Even though the SkipPolicy configuration could let Kramerius+ ignore these errors and fail if the limit was surpassed, it lacked one aspect, m o d i f y i n g the exit status. If the SkipPolicy does not reach its allowed limit, it w i l l let the Job complete w i t h the status successful. Otherwise, it w i l l throw a SkipLimitExceededException, and Spring Batch w i l l automatically set the status failed. The intention was mainly to modify the completion status to something describing the issue causing the failure. In case of a failed Job, there can be a status describing the error i n the Job. The component utilizes the helper class StepExecutionListenerSupport because the class implements all hook methods, so only the required ones can be overridden and implemented. The scope of the component allows injection of StepExecution - a Step scoped object, and JobParameters a Job scoped object. 5.2 Job Building Job b u i l d i n g is analogic to Step building. The m a i n differences are the lack of specification of chunks or tasks. Steps do all the work. The other difference is the pre-defined sequential configuration. For a Job, a complex flow can be specified. Jobs operate and decide the execution of the next Step by pattern-matching exit statuses. 5.2.1 Fault tolerance in Kramerius+ Jobs This section talks about how Kramerius+ handles errors. Spring Batch only holds exceptions i n a transient container. Kramerius+ needed persistent errors to display to the users. This reason is w h y the entity StepRunReport was created. StepRunReport is an abstraction of failure exceptions from a step. They a d d a reference to the Kramerius Job instance they belong to and the Spring Batch Job instance on top of the failures they hold. 1. A n interface with a single hook method that is called when a faulty record is encountered, implementing classes can be added to a FaultTolerant Step builder 31 5- IMPLEMENTATION OF JOBS AND OTHER STRUCTURES ©StepScope ©Component public class StepFailureListener extends StepExecutionListenerSupport { © V a l u e ( " # { j o b P a r a m e t e r s ['" + JobParameterKey.KRAMERIUS_JOB_INSTANCE_ID + " ' ] } ") private String krameriusJoblnstanceld; private StepRunReportService reportService ; ©Override public ExitStatus afterStep(StepExecution stepExecution) { List f a i l u r e s = stepExecution.getFailureExceptions(); if (!failures.isEmpty()) { StepRunReport report = reportService .saveStepErrors(krameriusJoblnstanceld , stepExecution.getld(), f a i l u r e s ) ; Optional f i r s t E r r o r = report.getErrors () .stream () .min(Comparator.comparing(StepError: :getOrder)); if ( f i r s t E r r o r . i s E m p t y ( ) ) { throw new IllegalStateExcept i o n ( " F i r s t error was not found even though step errors were persisted."); } return new E x i t S t a t u s ( f i r s t E r r o r . g e t ( ) .getExitCodeO) ; ' „ 32return n u l l ; } // ...setters y Figure 5.2: Example implementaion of StepListener from Kramerius+ 5- IMPLEMENTATION OF JOBS AND OTHER STRUCTURES ©Getter ©Setter @Ent i t y STable(name = "kplus_step_run_report") public class StepRunReport extends DomainObject { OManyToOne private KrameriusJoblnstance Job; ONotNull private Long stepExecutionld; SOneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, mappedBy = "StepRunReport") private Set errors = new HashSet <>() ; } Figure 5.3: StepRunReport entity used to persist errors 33 5- IMPLEMENTATION OF JOBS AND OTHER STRUCTURES ©Getter ©Setter @Ent i t y @Table(name = "kplus_step_error") public class StepError extends DomainObject { OManyToOne private StepRunReport stepRunReport; private String exitCode; private String shortMessage; @Lob © C o l u m n ( c o l u m n D e f i n i t i o n = "text") private String stackTrace; @Column(name = "error_order") private Long order; } Figure 5.4: StepError - a persistent representation of a n exception Exceptions are transformed into an entity that can be persisted. They contain most of the information that caused the fault a n d are as verbose as possible. These exceptions are always caught i n Skip Policy w h i c h is configured for a specific type of exception so that some nonskippable exceptions automatically fail the Job. The limit of exceptions is specified w h e n a user sends a request to the A P I . Persistent exceptions are a good w a y to track d o w n invalid input records, external tool failures or internal Kramerius+ faults. 34 Conclusion This thesis showcases the versatility of the Spring Batch framework and h o w Kramerius+ benefited from its usage. Kramerius+ is an application that provides better searching capabilities over the data i n Kramerius. To achieve this, it enriches data i n Kramerius using various tools. The vast size of this data requires the processes of enrichment and export to be reliable and robust. The jobs Kramerius+ runs on the data are long-running and have multiple points of failure. Spring Batch takes care of these concerns by coupling data and provides its jobs w i t h monitoring and fault tolerance. The result of this is that the publications i n Kramerius can now be enriched and exported reliably and fast using Kramerius+. In case of any failure, the system provides both the administrator and the user w i t h verbose feedback. These qualities were reached by getting the most out of the Spring Batch job infrastructure as well as building on top of it. Kramerius + went through multiple prototypes and is now i n production. The current implementation is the second one using the Spring Batch framework. The previous one lacked fault tolerance and needed to be designed to deal w i t h the complex tree structure that periodical publications come in. The previous implementation h a d sound error h a n d l i n g i n some places, especially w h e n dealing w i t h malformed input documents, but lacked i n other areas, w h i c h motivated the redesign and refactoring. The Spring Batch implementation of Kramerius + still has some issues, but its stability and speed were m u c h improved by accommodating it on the Spring Batch framework. In most cases, these are minor flaws that were encountered d u r i n g testing. One significant issue is authentication when fetching private data through Kramerius using tokens that expire after a short period and hence are unsuitable to be used i n long-running automatic jobs. A solution was discussed for a future release using refresh tokens or a custom authentication method for Kramerius+. 35 Bibliography 1. I B M . REST API [online]. [visited on 2023-03-20]. Available from: https://www.ibm.com/topics/rest-apis. 2. C Z E C H A C A D E M Y O F SCIENCES, Library of the. Kramerius [online], [visited on 2023-03-03]. Available from: https ://github. com/ceskaexpedice/kramerius. 3. GROUP, M E T A e project. ALTO XML [online]. [visited on 2023-03- 04]. Available from: https://www.loc.gov/standards/alto/. 4. M A N N I N G . C O M . Spring Batch In Action [online], [visited on 2023-03-06]. Available from: https : //livebook.manning, com/ b o o k / s p r i n g - b a t c h - i n - a c t i o n / . 5. Spring Batch Reference Documentation [online], [visited o n 2023- 03-06]. Available from: https : / /docs . s p r i n g . i o / s p r i n g - batch/docs/current/reference/html/index.html. 6. M U E L L E R , Thomas. H2 database [online]. [visited on 2023-04-10]. Available from: h t t p : //www. h2database. com/html/main. html. 7. S T R A K A , M i l a n . U D P i p e 2.0 Prototype at C o N L L 2018 U D Shared Task. In: Proceedings of the CoNLL 2018 Shared Task: Multilingual Parsing from Raw Text to Universal Dependencies. Brussels, Belgium: Association for Computational Linguistics, 2018, pp. 197-207. Available from DOI: 10.18653/vl/K18-2020. 8. S T R A K O V A , Jana; S T R A K A , M i l a n ; H A J I C , Jan. N e u r a l A r c h i tectures for Nested N E R through Linearization. In: Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics. Stroudsburg, PA, U S A : Association for Computational Linguistics, 2019, pp. 5326-5331. ISBN 978-1-950737-48-2. 9. M I N E L L A , Michael T. The Definitive Guide to Spring Batch: Modern Finite Batch Processing in the Cloud. 2 n d edtions. U S A : Apress, 2019. ISBN 1484237234. 10. Spring Boot reference documentation [online], [visited o n 2023-03- 19]. Available from: https : //docs . s p r i n g , i o / s p r i n g - b o o t / docs/current/reference/htmlsingle/. 36 B I B L I O G R A P H Y 11. S T R M E C K I , Daniel. Singleton Design pattern [online], [visited on 2023-04-10]. Available from: https : //www . baeldung . com/ s p r i n g - b o o t - s i n g l e t o n - v s - b e a n s . 12. Text Encoding Initiative [online]. [visited on 2023-03-20]. Available from: h t t p s : / / t e i - c . org/. 13. C Z E C H A C A D E M Y O F S C I E N C E S , Library of the. TEI Converter [online], [visited o n 2023-03-20]. Available from: https : //github.com/LIBCAS/DL4DH-TEI-Converter. 14. LI, Chengkai. XML Parsing, SAX/DOM. 2009. 15. H A R O L D , Elliotte Rusty. Processing XML with Java: a guide to SAX, DOM, JDOM, JAXP, and TrAX. V o l . 1. Addison-Wesley Professional, 2003. 16. I O N E S C U , Valériu Manuel. The analysis of the performance of R a b b i t M Q a n d A c t i v e M Q . In: 2015 14th RoEduNet International Conference - Networking in Education and Research (RoEduNet NER). 2015, pp. 132-137. Available from DOI: 10.1109/RoEduNet. 2015. 7311982. 17. S H V E T S , Alexander. Refactoring Guru Blog [online], [visited on 2023-04-04]. Available from: https : / / r e f a c t o r i n g . guru/ r e f a c t o r i n g . 37