YouTube Icon

Interview Questions.

Top 43 Spring Batch Interview Questions - Jul 28, 2022

fluid

Top 43 Spring Batch Interview Questions

Q1. Explain Spring Batch Framework.

Spring Batch frame paintings, a collaborative effort from Accenture and SpringSource, is a light-weight, complete framework that enables the improvement of batch applications that helps the each day sports of agency structures. Batch software or processing refers to automated offline structures that performs bulk statistics processing, periodic updates and delegated processing.

Examples consist of loading csv report facts to database, system feed file as soon as received and push day by day transactions to the upstream or downstream systems.

Q2. What Is Commandlinejobrunner In Spring Batch?

CommandLineJobRunner is one of the approaches to bootstrap your Spring batch Job. The xml script launching the job wishes a Java elegance essential method as as entry factor and CommandLineJobRunner lets you start your process immediately using the XML script.

The CommandLineJobRunner plays four tasks:

Load the proper ApplicationContext.

Parse command line arguments into JobParameters.

Locate the proper process based on arguments.

Use the JobLauncher provided in the utility context to release the task..

The CommandLineJobRunner arguments are jobPath, the area of the XML record so one can be used to create an ApplicationContext and the jobName, the name of the job to be run.

Bash$ java CommandLineJobRunner DailyJobConfig.Xml processDailyJob

These arguments have to be exceeded in with the direction first and the name 2d. All arguments after these are considered to be JobParameters and should be inside the layout of 'call=cost'.

Q3. Explain Parallel Processing In Spring Batch Framework?

Parallel processing allows more than one batch runs jobs to run in parallel to reduce the total elapsed batch processing time. Parallel processing is less difficult as long as the equal document or database table is not shared some of the methods in any other case the approaches should method partitioned data.

Another approach could be the usage of a control desk for preserving interdependencies and to track every shared aid in use by any technique or now not.

Other key troubles in parallel processing encompass load balancing and the availability of preferred system assets including files, database buffer pools etc. Also observe that the control desk itself can effortlessly come to be a essential resource.

Q4. Mention The Different Itemreader And Itemwriter Implementations Available In Spring Batch?

There are many implementations along with the ones that permit examine and write operations on,

Flat File.

Xml.

Hibernate Cursor.

JDBC.

JMS.

Hibernate Paging.

Stored Procedure.

Q5. Explain Partitioning In Spring Batch Framework?

Partitioning faciliates a couple of huge batch packages to run simultaneously that reduce the elapsed time required to method lengthy batch jobs. Processes which can be successfully partitioned are the ones where the input document can be break up and/or the principle database tables partitioned to permit the application to run in opposition to special sets of records.

Processes which can be partitioned must be designed to most effective method their assigned statistics set.

Q6. How Do We Track The Number Of Item Processed By The Itemreader In Spring Batch?

The item mapping bean can put in force org.Springframework.Batch.Object. ItemCountAware, a marker interface to have the object role tracked.

Q7. What Is Jobinstance?

A JobInstance represents the concept of a logical activity run.

Q8. How Do I Schedule A Job With Spring Batch?

Use a scheduling device such as Quartz, Control-M or Autosys. Quartz islight weight, would not have all of the functions of Control-M or Autosys. Even the OS primarily based Task scheduler, CRON jobs can be used to agenda Spring batch jobs.

Q9. Name Few Of The Domain Buzzwords In Spring Batch?

Job.

JobLauncher.

JobRepository.

JobInstance.

JobExecution.

JobParameters.

Q10. What Are The Required Dependencies For Configuring A Job?

There are 3 required dependencies:

Job name,

JobRepository,

and one or extra steps.

Q11. What Are Spring Batch Metadata Schema?

The Spring Batch Meta-Data tables are used to persist batch area gadgets along with JobInstance, JobExecution, JobParameters, and StepExecution for internally handling the Batch Jobs.

The JobRepository is chargeable for saving and storing each Java object into its accurate desk

Q12. How Cron Job Works In Linux?

Cron is a daemon that executes scheduled instructions. Cron is commenced automatically from /and many others/init.D on getting into multi-user runlevels. Cron searches its spool vicinity (/var/spool/cron/crontabs) for crontab documents (which can be named after bills in /and so forth/passwd); crontabs observed are loaded into memory.

Cron wakes up every minute, examining all stored crontabs, checking every command to peer if it should be run in the contemporary minute. When executing commands, any output is mailed to the owner of the crontab (or to the user named inside the MAILTO environment variable in the crontab, if such exists).

Q13. What Is Itemreader In Spring Batch Framework?

ItemReader is an abstraction that represents the retrieval of input for a Step, one object/row/report at a time. When the ItemReader has exhausted the gadgets it can provide, it's going to suggest this through returning null.

Q14. Explain Concurrent Batch On-line Processing In Spring Batch Framework?

Concurrent/on-line batch processing refers to the batch system that handles facts being concurrently used/updated by online users so the information can not be locked in database or file as the online customers will want it. Also the records updates have to be commited regularly on the give up of few transactions to reduce the part of information that is unavailable to other methods and the elapsed time the records is unavailable.

Q15. What Is The Default Isolation Level Of Spring Batch Transactions?

It is SERIALIZABLE with the aid of default to prevent the identical job example being performed simultaneously.

Q16. List Out Some Of The Practical Usage Scenario Of Spring Batch Framework?

Reading huge variety of information from a database, record, queue or every other medium, system it and save the processed statistics into medium, for example, database.

Concurrent and massively parallel processing.

Staged, corporation message-driven processing.

Sequential processing of based steps.

Whole-batch transaction.

Scheduled and repeated processing.

Q17. How Can I Make An Item Reader Thread Safe In Spring Batch?

You can synchronize the study() approach. Remember that you'll lose restartability, so quality practice is to mark the step as no longer restartable and to be secure (and efficient) you may also set saveState=fake at the reader.

Q18. How Do I Start A Spring Batch Job?

A Job Launcher can be used to execute a Spring Batch Job. Also a batch job can be launched/scheduled the usage of a web field as properly.

Execution of a task is called as Job Instance. Each Job Instance is supplied with an execution identification which can be used to restart the process if required.

Job can be configured with parameters which is exceeded to it from the Job Launcher.

Q19. How Do I Configure A Job In Spring Batch Framework?

A Job in Spring Batch contains a series of 1 or greater Steps. Each Step can be configured with the listing of parameters/characteristic required to execute each step.

Subsequent : next step to execute

tasklet: project or chunk to execute. A bite can be configured with a Item Reader, Item Processor and Item Writer.

Choice : Decide which steps want to finished.

Q20. What Is Itemprocessor?

ItemProcessor is an abstraction that represents the enterprise processing of an object. While the ItemReader reads one item, and the ItemWriter writes them, the ItemProcessor presents access to transform or apply different enterprise processing. If, while processing the object, it is decided that the item isn't always valid, returning null suggests that the item have to no longer be written out.

Q21. Define A Job In Spring Batch?

A Job is an entity that encapsulates a whole batch technique.

Job could be wired collectively using a XML configuration document or Java based configuration. This configuration is also referred as "activity configuration".

A Job is actually a container for Steps and it combines more than one steps that runs logically together in a flow.

Q22. What Are The Important Features Of Spring Batch?

Restorability: Restart a batch software from where it failed.

Different Readers and Writers : Provides brilliant assist to examine from textual content files, csv, JMS, JDBC, Hibernate, iBatis and so forth. It can write to JMS, JDBC, Hibernate, documents and plenty of more.

Chunk Processing : If we've got 1 Million records to technique, those may be processed in configurable chunks (a thousand at a time or ten thousand at a time).

Easy to put in force proper transaction management even when the use of bite processing.

Easy to put in force parallel processing. With simple configuration, exclusive steps may be run in parallel.

Q23. What Is A Cron Job?

A cron job is a Linux command for scheduling script in your server to execute repetitive tasks robotically. Scripts executed as a cron process are generally used to adjust documents, databases and manipulate caching.

Q24. Difference Between Step And Stepexecution?

A Step is a site object that encapsulates an unbiased and sequential phase of a batch process at the same time as a StepExecution represents a single attempt to execute a step.

Q25. What Are The Typical Processing Strategies In Spring Batch?

Normal processing during offline.

Concurrent batch or on-line processing.

Parallel processing of many distinctive batch or jobs at the equal time.

Partitioning (processing of many instances of the same process on the equal time).

Q26. What Is Executioncontext?

An ExecutionContext represents a set of key/fee pairs which can be continued and managed with the aid of the framework if you want to offer the developers a placeholder to shop persistent country that is scoped to a StepExecution or JobExecution.

Q27. How Do You Categorize Batch Applications Based On Input Source In Spring Batch?

Database-driven applications are driven through rows or values obtained from the database.

File-driven packages are pushed through data or values retrieved from a document.

Message-driven programs are driven by way of messages retrieved from a message queue.

Q28. What Is The Latest Version Of Spring Batch?

The available present day version is 3.Zero.7.

Q29. Explain Normal Processing Strategy In Spring Batch Framework?

Normal processing refers to the batch techniques that runs in a separate batch window, the information being updated is not required with the aid of online customers or other batch strategies, in which concurrency would now not be a challenge and a single dedicate may be done on the cease of the batch run.

Single commit factor may be a difficulty in phrases of scaiability and quantity of data it may handle, it's miles always an awesome practice to have restart recuperation alternatives .

Q30. Explain The Spring Batch Framework Architecture?

Spring Batch show off a layered architecture and it incorporates of three most important excessive level additives:

Application, Core and Infrastructure.

The application layer includes all of the batch job configurations, custom codes for enterprise good judgment and activity meta data developed with the aid of Application builders.

The Batch Core has the middle runtime classes essential to launch and manage any batch job. Some of the middle runtime classes consist of JobLauncher, Job, and Step implementations.

The infrastructure incorporates API for common readers and writers, and services for retrying on failure, repeat jobs etc. The infrastructure layer are used each through utility builders(ItemReader and ItemWriter) and the middle framework itself for controlling the batch task along with Retry, repeat. Thus Batch Core and Application layers are constructed on top of Infrastructure layer.

Q31. Explain The Role Of Jobrepository In Spring Batch?

The JobRepository is used for basic CRUD operations of the various persisted area objects within Spring Batch, which includes JobExecution and StepExecution. It is required by way of some of the main framework features, together with the JobLauncher, Job, and Step.

Q32. What Are The Different Bean Scope In Spring Batch 3.Zero?

Step scope- there may be simplest one instance of this type of bean consistent with executing step.

<bean id="..." class="..." scope="step">

Job scope- there may be only one instance of the sort of bean in step with executing Job.

<bean id="..." class="..." scope="job">

Q33. Can We Create A Spring Batch With No Step?

No. There need to exists as a minimum one step or flow or split configuration within a Spring Batch task.

Q34. How Do You Run Spring Batch Jobs In Production Environment?

Usually The Java batch Job most important elegance and its dependencies are handed to the java command and it's far saved in a command line Batch document or shell script in terms of linux/unix.

These script document may be run using scheduler like Autosys at the Production environment.

Q35. Technical Advantages Of Using Spring Batch Framework From A Developer Perspective?

Batch framework leverages Spring programming model accordingly allows builders to concentrate at the business common sense or the commercial enterprise technique and framework facilitates the infrastructure.

Clear separation of worries between the infrastructure, the batch execution surroundings, the batch software and the one-of-a-kind steps/proceses inside a batch application.

Provides commonplace situation based totally, middle execution offerings as interfaces that the applications can enforce and in addition to that framework offers its default implementation that the builders could use or partially override based on their commercial enterprise logic.

Easily configurable and extendable services across unique layers.

Provides a simple deployment model constructed the usage of Maven.

Q36. What Job Configuration Consists Of?

The job configuration consists of,

The easy name of the task.

Definition and order of the Steps.

Configurable worldwide(to all steps) houses inclusive of restartablity.

Q37. How Do I Setup Spring Batch Job Without Using Xml?

Spring 3 allows the potential to configure applications the use of java as opposed to XML and from Spring Batch 2.2.Zero, batch jobs can be configured the use of the same java config.

There are 2 components for the java based totally configuration:

the @EnableBatchConfiguration annotation and  developers.

@EnableBatchProcessing offers a base configuration for constructing batch jobs.

The center interface for this configuration is the BatchConfigurer. The default implementation provides the beans to be autowired which include JobRepository, JobLauncher.

Q38. What Is Resourceaware Is Spring Batch?

ResourceAware is a marker interface so as to set the present day useful resource on any item that enforce this interface.

Q39. What Is Tasklet In Spring Batch Framework?

The Tasklet is an interface which plays any single challenge together with setup aid, strolling a square replace, cleaning up sources and so on.

Q40. What Is Itemwriter In Spring Batch Framework?

ItemWriter is an abstraction that represents the output of a Step, one batch or bite of objects at a time. Generally, an item writer has no know-how of the input it'll receive subsequent, best the object that became handed in its modern invocation.

Q41. What Is Job Launcher In Spring Batch Framework?

JobLauncher represents a easy interface for launching a Job with a given set of JobParameters.

Q42. Difference Between Spring Batch And Quartz Scheduler?

Spring Batch and Quartz have distinctive capabilities and responsibility. Spring Batch affords functionality for processing big volumes of statistics at the same time as Quartz affords capability for scheduling tasks. Thus Quartz could complement Spring Batch and a commonplace mixture would be to use Quartz as a cause for a Spring Batch task using a Cron expression.

Q43. Define Executioncontext?

An ExecutionContext represents a collection of key-fee pairs which are continued and managed through the framework to be able to allow builders a place to shop chronic state this is scoped to a StepExecution or JobExecution.




CFG