{"id":2516,"date":"2021-09-09T14:56:27","date_gmt":"2021-09-09T05:56:27","guid":{"rendered":"https:\/\/jennifersoft.com\/en\/?p=2516"},"modified":"2021-09-14T13:16:35","modified_gmt":"2021-09-14T04:16:35","slug":"2021-09-09","status":"publish","type":"post","link":"https:\/\/jennifersoft.com\/en\/blog\/tech\/2021-09-09\/","title":{"rendered":"Spring Batch Monitoring with JENNIFER"},"content":{"rendered":"\n<figure class=\"wp-block-image big\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"614\" src=\"https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/blog_albert-1024x614-1024x614.jpg\" alt=\"\" class=\"wp-image-2538\" srcset=\"https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/blog_albert-1024x614.jpg 1024w, https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/blog_albert-1024x614-300x180.jpg 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In this article, we will introduce you to how to trace application transactions that use a spring batch with Jennifer. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>Basic Operation of Spring Batch<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s first take a look at the basic operational structure of spring batch. Basically, a spring batch is run by implementing necessary logic in the unit of step, which is an independent job unit. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Steps can\nbe divided into tasklet based steps and chunk based steps.<br>\nIf you want to use a tasklet based step, then you have to implement a tasklet.\nUntil the step is terminated, the execute method will be repeatedly executed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Tasklet based step is generally used in a lot in jobs such as initialization, execution of saving procedures, alarm transmission and so on.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s\nfirst take a look at the basic operation structure of spring batch. Basically,\na spring batch is run by implementing necessary logics in the unit of step,\nwhich is an independent job unit. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Steps can\nbe divided into tasklet based steps and chunk based steps.<br>\nIf you want to use a tasklet based step, then you have to implement a tasklet.\nUntil the step is terminated, the execute method will be repeatedly executed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Tasklet based step is generally used in a lot in jobs such as initialization, execution of saving procedures, alarm transmission and so on.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"350\" src=\"https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/Springbatch_architecture-1024x350-1024x350.png\" alt=\"\" class=\"wp-image-2517\" srcset=\"https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/Springbatch_architecture-1024x350.png 1024w, https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/Springbatch_architecture-1024x350-300x103.png 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Basic Execution Architecture of Spring Batch<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. Spring Batch Transaction Monitoring with JENNIFER<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Once you\nhave activated the Spring Batch Monitoring option in Jennifer, Jennifer will\nbegin to detect batch execution in step discussed earlier and then monitor\ntransactions in step.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once the\ntransaction starts, it will detect each individual step running in the order of\nexecution as spring batch inside the transaction and then trace entire\ntransactions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The\nfollowing sample code shows how Jennifer detects spring batch steps and\nmonitors them accordingly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A total of 6 steps from the start step to the end step are defined in the sample code. The sample code was prepared in such a way that a different SQL will run in each step.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">@Bean&lt;br>\n     public Job chunkBasedJob() {&lt;br>\n         return jobBuilderFactory.get(JOB_NAME).incrementer(new RunIdIncrementer()). \/\/&lt;br>\n                 start(step(\"Start Step\")). \/\/  &lt;br>\n                 next(step(\"Step One\")). \/\/&lt;br>\n                 next(step(\"Step Two\")). \/\/&lt;br>\n                 next(chunkStep(\"chunk first Step\", 10)). \/\/&lt;br>\n                 next(chunkStep(\"chunk Second Step\", 100)). \/\/&lt;br>\n                 next(step(\"End Step\")). \/\/&lt;br>\n                 build();&lt;br>\n     }<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In order to see how Jennifer monitors the prepared spring batch sample codes, go to the Advanced Agent option and set the enable_spring_batch option to true.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"371\" src=\"https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/spring_default_batch_option-1024x371-1024x371.png\" alt=\"\" class=\"wp-image-2518\" srcset=\"https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/spring_default_batch_option-1024x371.png 1024w, https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/spring_default_batch_option-1024x371-300x109.png 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Agent option setting<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Once the setting is done as above and spring batch job execution transaction is run, then as shown in the following, you can see the name and execution details of job running within the transaction.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"688\" src=\"https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/batch_full_profile-1024x688-1024x688.png\" alt=\"\" class=\"wp-image-2519\" srcset=\"https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/batch_full_profile-1024x688.png 1024w, https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/batch_full_profile-1024x688-120x80.png 120w, https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/batch_full_profile-1024x688-300x202.png 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Example of Spring Job Transaction Trace through X-view<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"169\" src=\"https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/atch_transaction_name01.png-1024x169-1024x169.png\" alt=\"\" class=\"wp-image-2520\" srcset=\"https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/atch_transaction_name01.png-1024x169.png 1024w, https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/atch_transaction_name01.png-1024x169-300x50.png 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Check the name of job executed in the application list table at the top<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"456\" src=\"https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/batch_profile-1024x456-1024x456.png\" alt=\"\" class=\"wp-image-2521\" srcset=\"https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/batch_profile-1024x456.png 1024w, https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/batch_profile-1024x456-300x134.png 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>In the profile list, check the step profile where the job of the sample code is run<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Especially, X-view timeline shows the portion of time occupied by the individual job running individually in the entire transaction, so it can be very helpful in understanding the job performance. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"357\" src=\"https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/batch_timeline-1024x357-1024x357.png\" alt=\"\" class=\"wp-image-2522\" srcset=\"https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/batch_timeline-1024x357.png 1024w, https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/batch_timeline-1024x357-300x105.png 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>Timeline chart in the middle can help you analyze the portion of response time occupied by the batch job compared to other transactions.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And, if you want to use the name of the batch job executing each job as a transaction name, then go to the Advanced Agent option and set JobName in the service_naming_by_job_parameter as follows.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"372\" src=\"https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/jobname_option-1024x372-1024x372.png\" alt=\"\" class=\"wp-image-2523\" srcset=\"https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/jobname_option-1024x372.png 1024w, https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/jobname_option-1024x372-300x109.png 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>service_naming_by_job_parameter setting<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And, if you want to use the name of the batch job executing each job as a transaction name, then go to the Advanced Agent option and set JobName in the service_naming_by_job_parameter as follows.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"220\" src=\"https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/Group-1024x220-1024x220.png\" alt=\"\" class=\"wp-image-2524\" srcset=\"https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/Group-1024x220.png 1024w, https:\/\/jennifersoft.com\/en\/wp-content\/uploads\/sites\/3\/2021\/08\/Group-1024x220-300x64.png 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>You can see that the name set in the batch job application name field of the X-View pop-up windows is displayed<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">With this simple\nJennifer option setting, you will be able to check the bottleneck point of\nperformance while monitoring spring batch transactions. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For more details\nabout spring batch monitoring in terms of technical information or batch job\nprofiling methods, then you are always welcome to contact\ntech@jennfiersoft.com.<\/p>\n","protected":false},"excerpt":{"rendered":"In this article, we will introduce you to how to trace application transactions that use a spring batch with Jennifer&#8230;.","protected":false},"author":19,"featured_media":2538,"comment_status":"closed","ping_status":"closed","sticky":true,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[78],"tags":[],"class_list":["post-2516","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech"],"acf":[],"_links":{"self":[{"href":"https:\/\/jennifersoft.com\/en\/wp-json\/wp\/v2\/posts\/2516","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jennifersoft.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jennifersoft.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jennifersoft.com\/en\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/jennifersoft.com\/en\/wp-json\/wp\/v2\/comments?post=2516"}],"version-history":[{"count":4,"href":"https:\/\/jennifersoft.com\/en\/wp-json\/wp\/v2\/posts\/2516\/revisions"}],"predecessor-version":[{"id":2605,"href":"https:\/\/jennifersoft.com\/en\/wp-json\/wp\/v2\/posts\/2516\/revisions\/2605"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jennifersoft.com\/en\/wp-json\/wp\/v2\/media\/2538"}],"wp:attachment":[{"href":"https:\/\/jennifersoft.com\/en\/wp-json\/wp\/v2\/media?parent=2516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jennifersoft.com\/en\/wp-json\/wp\/v2\/categories?post=2516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jennifersoft.com\/en\/wp-json\/wp\/v2\/tags?post=2516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}