<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Raja Anbazhagan</title>
    <description>The latest articles on DEV Community by Raja Anbazhagan (@raja_anbazhagan).</description>
    <link>https://dev.to/raja_anbazhagan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F314733%2F2bee3497-621a-49f6-9b2f-2d2901ac8a38.jpeg</url>
      <title>DEV Community: Raja Anbazhagan</title>
      <link>https://dev.to/raja_anbazhagan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/raja_anbazhagan"/>
    <language>en</language>
    <item>
      <title>Finally, You can Collect Web Vital metrics from AMP pages using Google Analytics</title>
      <dc:creator>Raja Anbazhagan</dc:creator>
      <pubDate>Thu, 08 Apr 2021 17:16:06 +0000</pubDate>
      <link>https://dev.to/raja_anbazhagan/finally-you-can-collect-web-vital-metrics-from-amp-pages-using-google-analytics-7bl</link>
      <guid>https://dev.to/raja_anbazhagan/finally-you-can-collect-web-vital-metrics-from-amp-pages-using-google-analytics-7bl</guid>
      <description>&lt;p&gt;If you don't know already, You can monitor your site's Web Vitals using &lt;a href="https://github.com/GoogleChrome/web-vitals"&gt;Web-vitals&lt;/a&gt; script. Hooking it with the &lt;a href="https://web-vitals-report.web.app/"&gt;Web-Vitals-Report&lt;/a&gt; app, you have easy monitoring for site performance.&lt;/p&gt;

&lt;p&gt;However, You can't run these scripts in AMP pages as 3&lt;sup&gt;rd&lt;/sup&gt;Party Scripts are a no-no. So there was no easier way to properly collect web vital metrics until now.&lt;/p&gt;

&lt;p&gt;Recently AMP project started providing vitals like CLS, LCP and FID as &lt;a href="https://github.com/ampproject/amphtml/blob/main/spec/amp-var-substitutions.md#performance"&gt;performance variables&lt;/a&gt;. When I tried to implement this in my blog I had a couple of problems.&lt;/p&gt;

&lt;p&gt;1) Google analytics Event values should be an integer. CLS, LCP, FID values will most likely have decimal points. This means the entire event will be dropped in google analytics.&lt;br&gt;
2) If I wanted to use fractions, then I should use Google Analytics G4. Which is still in alpha and no official support from AMP.&lt;/p&gt;

&lt;p&gt;So the obvious option I had was to &lt;a href="https://github.com/ampproject/amphtml/pull/33383"&gt;submit a PR&lt;/a&gt; that would translate these values into something Google Analytics can understand. Thankfully the team accepted it. So here is what you have to do.&lt;/p&gt;

&lt;p&gt;If you want to capture CLS metrics, You need to include the google analytics snippet for AMP as shown below.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;amp-analytics&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"googleanalytics"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"application/json"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vars&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;account&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;👉 Provide site tracking ID here (e.g. UA-XXXXX-Y) 👈&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
          &lt;span class="p"&gt;},&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;triggers&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;capture CLS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
              &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;on&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;visible&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;request&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;event&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
              &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vars&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;eventCategory&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Web Vitals&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;eventAction&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;CLS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;eventLabel&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;${clientId}-${pageViewId}-CLS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;eventValue&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;$CALC(${cumulativeLayoutShift},1000,multiply,true)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
              &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/amp-analytics&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Also, don't forget to set the tracking ID.&lt;/p&gt;

&lt;p&gt;You can read the detailed write-up at &lt;a href="https://raja.anbazhagan.dev/amp-pages-and-core-web-vitals-and-google-analytics/"&gt;Collect Core Web Vitals from AMP pages using Google Analytics&lt;/a&gt; @ &lt;a href="https://raja.anbazhagan.dev"&gt;raja.anbazhagan.dev&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Drools integration with Spring Boot</title>
      <dc:creator>Raja Anbazhagan</dc:creator>
      <pubDate>Tue, 16 Feb 2021 04:06:50 +0000</pubDate>
      <link>https://dev.to/raja_anbazhagan/drools-integration-with-spring-boot-31j2</link>
      <guid>https://dev.to/raja_anbazhagan/drools-integration-with-spring-boot-31j2</guid>
      <description>&lt;p&gt;&lt;a href="https://drools.org/"&gt;Drools&lt;/a&gt; is a versatile business rule engine that can elevate your application by externalizing a lot of decision  logic. As the most application servers are now using Spring boot, let's understand how to use Drools with Spring boot.&lt;/p&gt;

&lt;p&gt;For a simple example, you can create a &lt;code&gt;KieContainer&lt;/code&gt; as shown below.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Bean&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;KieContainer&lt;/span&gt; &lt;span class="nf"&gt;getKieContainer&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;KieFileSystem&lt;/span&gt; &lt;span class="n"&gt;kieFileSystem&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;kieServices&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;newKieFileSystem&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;kieFileSystem&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;write&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="nc"&gt;ResourceFactory&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;newClassPathResource&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"discount.drl"&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
    &lt;span class="nc"&gt;KieBuilder&lt;/span&gt; &lt;span class="n"&gt;kb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;kieServices&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;newKieBuilder&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;kieFileSystem&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;kb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;buildAll&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="nc"&gt;KieModule&lt;/span&gt; &lt;span class="n"&gt;kieModule&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;kb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getKieModule&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;kieServices&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;newKieContainer&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;kieModule&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getReleaseId&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Once you have a container, You can execute the rules within it by creating a session and firing all rules.&lt;/p&gt;

&lt;p&gt;More on this explained at &lt;a href="https://springhow.com/spring-boot-drools/"&gt;Drools integration with Spring Boot&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>drools</category>
      <category>springboot</category>
    </item>
    <item>
      <title>Thymeleaf form-handling is underrated.</title>
      <dc:creator>Raja Anbazhagan</dc:creator>
      <pubDate>Fri, 15 Jan 2021 13:46:10 +0000</pubDate>
      <link>https://dev.to/raja_anbazhagan/thymeleaf-form-handling-is-underrated-381a</link>
      <guid>https://dev.to/raja_anbazhagan/thymeleaf-form-handling-is-underrated-381a</guid>
      <description>&lt;p&gt;Single-page applications may have sleek forms and, AJAX calls to supply details to the server. But it cannot beat the simplicity of form-submissions. With templating libraries like thymeleaf and its support towards Spring-MVC makes form handling hassle-free.&lt;/p&gt;

&lt;p&gt;A typical way to handle form parameters is through &lt;code&gt;@RequestParam&lt;/code&gt; annotation. For example, the following snippet is to take three form parameters to a POST endpoint.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@RequestMapping&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;method&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;RequestMethod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;POST&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;handleForm&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;@RequestParam&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"firstName"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
    &lt;span class="nd"&gt;@RequestParam&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"lastName"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;lastName&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nd"&gt;@RequestParam&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"role"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="nc"&gt;Role&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;info&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"first Name : {}"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;info&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Last Name : {}"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lastName&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;info&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Role: {}"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;"users"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;But this would be cumbersome when the form has too many parameters. For this reason, Spring MVC lets you wrap the parameters into a Form-Backed bean. &lt;/p&gt;

&lt;p&gt;To do this, you need to define a class that would represent the FORM elements as POJO. Then use this class as a &lt;code&gt;@ModelAttribute&lt;/code&gt;.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@RequestMapping&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"/"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;method&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;RequestMethod&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;POST&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;createUser&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;@ModelAttribute&lt;/span&gt; &lt;span class="nc"&gt;UserInfo&lt;/span&gt; &lt;span class="n"&gt;userInfo&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;info&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"first Name : {}"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;info&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Last Name : {}"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lastName&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;info&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Role: {}"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;"users"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here is a simple tutorial and demo on &lt;a href="https://springhow.com/thymeleaf-form-handling/"&gt;&lt;strong&gt;Thymeleaf Form Handling in Spring Boot&lt;/strong&gt;&lt;/a&gt;. This post explains how to keep model along with forms.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The @Scheduled annotation may be deceiving you..!
</title>
      <dc:creator>Raja Anbazhagan</dc:creator>
      <pubDate>Thu, 07 Jan 2021 12:52:47 +0000</pubDate>
      <link>https://dev.to/raja_anbazhagan/the-scheduled-annotation-may-be-deceiving-you-47ml</link>
      <guid>https://dev.to/raja_anbazhagan/the-scheduled-annotation-may-be-deceiving-you-47ml</guid>
      <description>&lt;p&gt;Is your &lt;code&gt;@Scheduled&lt;/code&gt; method with &lt;code&gt;fixedRate&lt;/code&gt; is not firing exactly at the time interval configured? Here I try to explain this behaviour and how you can fix it.&lt;/p&gt;

&lt;p&gt;It all has to do with the default &lt;code&gt;ThreadPoolTaskScheduler&lt;/code&gt; that is provided by Spring Boot’s auto-configuration. This Executor’s thread pool size is 1 by default. Every method that uses &lt;code&gt;@Scheduled&lt;/code&gt; annotation will have to use this single thread.&lt;/p&gt;

&lt;p&gt;Spring has deliberately done this so that there won’t be two runs of the same method happening in parallel. To achieve parallelism, we need to do three things.&lt;/p&gt;

&lt;p&gt;1) Enable Async Support by annotating the Spring Boot main class with &lt;code&gt;@EnableAsync&lt;/code&gt;.&lt;br&gt;
2) Mark The &lt;code&gt;@Scheduled&lt;/code&gt; method with &lt;code&gt;@Async&lt;/code&gt;.&lt;br&gt;
3) Increase the default number of threads available using &lt;code&gt;spring.task.scheduling.pool.size&lt;/code&gt; property.&lt;/p&gt;

&lt;p&gt;You can find detailed explanation about this behaviour at the post about how &lt;strong&gt;&lt;a href="https://springhow.com/things-you-dont-know-about-scheduling-in-spring-boot/"&gt;The @Scheduled annotation may be deceiving you..!&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>springboot</category>
    </item>
    <item>
      <title>Distributed Caching with Hazelcast</title>
      <dc:creator>Raja Anbazhagan</dc:creator>
      <pubDate>Thu, 07 Jan 2021 12:46:50 +0000</pubDate>
      <link>https://dev.to/raja_anbazhagan/distributed-caching-with-hazelcast-36n5</link>
      <guid>https://dev.to/raja_anbazhagan/distributed-caching-with-hazelcast-36n5</guid>
      <description>&lt;p&gt;Hazelcast is an in-memory data grid that helps share highly volatile data between multiple application instances. This approach gives the advantages of avoiding network round trips.&lt;/p&gt;

&lt;p&gt;Here is a post about hazelcast with spring boot and how to monitor them with Hazelcast Management centre.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://springhow.com/spring-boot-hazelcast-cache/"&gt;Spring Boot Hazelcast Cache&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Store spring sessions in Separate Database</title>
      <dc:creator>Raja Anbazhagan</dc:creator>
      <pubDate>Wed, 06 Jan 2021 12:28:25 +0000</pubDate>
      <link>https://dev.to/raja_anbazhagan/store-spring-sessions-in-separate-database-1056</link>
      <guid>https://dev.to/raja_anbazhagan/store-spring-sessions-in-separate-database-1056</guid>
      <description>&lt;p&gt;Storing session details in Redis or database is usually a good idea. However,&lt;br&gt;
the &lt;a href="https://springhow.com/spring-boot-security/session-jdbc/"&gt;default implementation&lt;/a&gt; of &lt;code&gt;spring-session-jdbc&lt;/code&gt; uses the primary data source to store and&lt;br&gt;
retrieve data from the session related tables. This can be a problem when there is a large amount of session related&lt;br&gt;
operations to the database.&lt;/p&gt;

&lt;p&gt;The solution here is to define a custom datasource bean and mark it with &lt;code&gt;@SpringSessionDataSource&lt;/code&gt; as shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Bean&lt;/span&gt;
&lt;span class="nd"&gt;@SpringSessionDataSource&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;DataSource&lt;/span&gt; &lt;span class="nf"&gt;sessionDataSource&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;sessionDataSource&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, when you define multiple data sources, you end up breaking the default auto-configurations involving the primary data source. &lt;/p&gt;

&lt;p&gt;To avoid all that, you need to mark one datasource as primary and somehow create and feed the second datasource to the session auto-configuration.&lt;/p&gt;

&lt;p&gt;Follow this post about &lt;a href="https://springhow.com/session-jdbc-different-database/"&gt;Store spring sessions in Separate Database&lt;/a&gt; to learn how and why you should do it this way. &lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
