<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by arjun nagathankandy on Medium]]></title>
        <description><![CDATA[Stories by arjun nagathankandy on Medium]]></description>
        <link>https://medium.com/@arjunac009?source=rss-d833b3181cb4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gvPvbK-QBZQqlvnppGHJZw.jpeg</url>
            <title>Stories by arjun nagathankandy on Medium</title>
            <link>https://medium.com/@arjunac009?source=rss-d833b3181cb4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 04:41:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arjunac009/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a Real-Time Fraud Detection Pipeline with Python, FastAPI, and n8n]]></title>
            <link>https://medium.com/@arjunac009/building-a-real-time-fraud-detection-pipeline-with-python-fastapi-and-n8n-f8d43250de51?source=rss-d833b3181cb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8d43250de51</guid>
            <category><![CDATA[fraud-detection]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[fastapi]]></category>
            <category><![CDATA[pyhon]]></category>
            <category><![CDATA[n8n-workflow]]></category>
            <dc:creator><![CDATA[arjun nagathankandy]]></dc:creator>
            <pubDate>Sat, 27 Sep 2025 17:04:54 GMT</pubDate>
            <atom:updated>2025-09-27T19:38:59.290Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Utr5eegzAZofpNeXF2Ms0g.png" /></figure><p>How I used a low-code automation tool to orchestrate a machine learning model and the Gemini API, all for the fun of exploring n8n.</p><p>Fraud detection is a critical, real-time challenge. But what if you could visually build and manage the logic that powers it?•The Goal: Introduce the main purpose of the article. <strong>This isn’t just another machine learning tutorial</strong>. It’s an exploration of workflow automation. State clearly that you chose this project as a fun and practical way to get hands-on with n8n.</p><p><strong>What we built<br></strong>a system where a Python script simulates a transaction, n8n orchestrates the entire process, a FastAPI model makes a prediction, and for fraudulent transactions, the Gemini API adds descriptive insights.</p><p><strong>The Big Picture: Visualizing the Workflow</strong></p><p>.While a single, complex script could have handled parts of this project, my primary goal was to explore the power of modern workflow automation. I wanted to move beyond linear code and find a way to visually orchestrate how different, independent services — like our custom ML model and an external AI — could talk to each other. This is precisely where a tool like<a href="https://n8n.io/"> n8n shines.</a> Think of n8n as the project’s central conductor. It doesn’t perform the fraud analysis itself, but it tells every other component what to do and when. The entire logic is laid out in a clear, visual sequence that anyone can understand at a glance. Here’s the high-level flow of our automated pipeline:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z93GLH989yKmhR9rocx-Ag.png" /></figure><ol><li>Transaction Starts: Our stimulator.py script kicks things off by sending a sample transaction to a webhook.</li><li>2.n8n Catches It: The n8n webhook acts as the front door, receiving the incoming data instantly.</li><li>3.n8n Asks for a Prediction: The workflow immediately makes an HTTP request to our FastAPI /predict endpoint.</li><li>4.The “IF” Moment: An IF node — the core of our logic — checks the model’s response. Is the transaction fraudulent?</li><li>5.Path A (No Fraud): If the transaction is clean, the workflow simply returns the prediction result.</li><li>6.Path B (Fraud!): If fraud is detected, the workflow makes a second call, this time to the Gemini API, to generate descriptive insights about the fraudulent activity before returning the final, enriched data.</li></ol><p><strong>The Brains: A Simple and Powerful FastAPI Model</strong></p><p>A lean and powerful backend service built with Python and FastAPI. I chose FastAPI for this task for several key reasons: its incredible performance, its intuitive structure that makes development a breeze, and its automatic generation of interactive API documentation — a lifesaver for testing endpoints on the fly. This service exposes two critical endpoints:</p><p>First, the<strong> /train </strong>endpoint handles the machine learning aspect. With a single API call, it reads the creditcard.csv dataset and trains a Logistic Regression model. A common challenge in fraud detection is that the data is highly imbalanced — there are far more legitimate transactions than fraudulent ones. To address this, I configured the model with class_weight=’balanced’, a simple yet powerful technique that tells the model to pay closer attention to the fraudulent examples during training, ensuring it doesn’t just dismiss them as rare outliers.</p><p>Second, the<strong> /predict </strong>endpoint serves as the simple, callable brain that our n8n workflow can easily talk to. It accepts a single transaction’s data, runs it through the trained model, and returns a clear, immediate verdict: is it fraud, and with what probability? This clean, predictable interface is the key that allows external tools like n8n to seamlessly integrate machine learning into a broader, more complex workflow. For a detailed guide on setting up the environment, training the model, and running the application, please refer to the <a href="https://github.com/arjunbalussery/fraud_transaction_detector">README.md</a> file in the project’s GitHub repo</p><p>Below is the sample stimulator running and output response from the orchestrater</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MKEbWBbzkqXuAgNi55kSZA.png" /></figure><p><strong>Project Files &amp; References</strong>•</p><p><strong>My Project Repository</strong>: You can find all the code, including the n8n workflow file, on my <br><strong>GitHub</strong> [<a href="https://github.com/arjunbalussery/fraud_transaction_detector">https://github.com/arjunbalussery/fraud_transaction_detector</a>]</p><p><strong>n8n — Workflow Automation</strong>: If you’re new to n8n, I highly recommend checking out their official website and <strong>GitHub</strong>:[<a href="https://n8n.io/">https://n8n.io/</a>]</p><p><strong>Conclusion: More Than Just a Project</strong></p><p>In the end, what we’ve built here is much more than just a simple fraud detector. We’ve created a fully orchestrated, automated pipeline that demonstrates how modern tools can be pieced together to build powerful and intelligent systems. The real star of the show is the workflow automation that holds everything together. This project proves that you don’t need monolithic applications to achieve complex results. My main takeaway from this experiment is how effectively tools like n8n can act as the “glue” between disparate services. By connecting a custom Python model, an external AI, and conditional logic in a visual interface, we were able to build a sophisticated workflow with surprising speed and clarity. This visual approach makes the entire system easier to understand, debug, and, most importantly, extend.</p><p><strong>Questions and Discussion</strong></p><p>If you run into any problems while setting this up, have a question about a specific step, or need any further explanation, please don’t hesitate to share it in the comments below. I will be actively following this article for some time and will do my best to help out.</p><p><strong>Happy Learning!!!!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8d43250de51" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stress Testing Reactive Springboot Application with Kotlin Coroutine + Jooq + PostgreSQL]]></title>
            <link>https://medium.com/@arjunac009/stress-testing-reactive-springboot-application-with-kotlin-coroutine-jooq-postgresql-61aabe970b29?source=rss-d833b3181cb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/61aabe970b29</guid>
            <dc:creator><![CDATA[arjun nagathankandy]]></dc:creator>
            <pubDate>Thu, 21 Dec 2023 08:17:21 GMT</pubDate>
            <atom:updated>2023-12-21T08:17:21.456Z</atom:updated>
            <content:encoded><![CDATA[<p>Stress testing a write-heavy reactive spring-boot application developed using Kotlin coroutine connected to PostgreSQL using R2dbc and Jooq.</p><p>In the previous <a href="https://medium.com/@arjunac009/aab727b64c2f">article</a>, we discussed how to develop a Springboot non-blocking application with Kotlin coroutines, Jooq, and PostgreSQL.</p><p><strong>Let us Stress Test it using K6</strong></p><p><strong>System Profile</strong></p><ul><li>SB3.2</li><li>Jooq 3.18</li><li>PostgreSQL:alpine-3.16 (docker image with default settings)</li><li>flyway</li><li>r2dbc</li><li>Connection pool using r2dbc connection pool</li><li>A single instance of an application running in one container and connecting to Postgres to a Postgres DB running in another container</li></ul><h4><strong>Scenario 1 :</strong></h4><ul><li>Connection pool config — initial-size: <strong>10</strong>, max-size: <strong>20 (default Hikari CP config given to r2dbc)</strong></li><li>Stress testing using K6 with 10 write req/s</li></ul><p><strong>Analysis</strong></p><ul><li>All requests were executed successfully. The result persisted in the database</li><li>0.9 % utilization of Postgres DB</li><li>in 10 seconds 100 records got successfully persisted in the system</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*KB677ZzmHD34RFDr8suHiQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JKXEmi7ebJq9OzaqLncRCQ.png" /></figure><p><strong>Scenario 2:</strong></p><ul><li>Connection pool config — initial-size: <strong>10</strong>, max-size: <strong>20 (default Hikari CP config given to r2dbc)</strong></li><li>I started gradually increasing the number of parallel requests and reached 120 req/seconds</li></ul><p><strong>Analysis</strong></p><ul><li>%0.7 % Utilisation of database cpu</li><li>in 10.5 seconds 1200 records got successfully persisted in the system</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JKyxlx7CobLuDg89fvso7w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*faPZv5RAiIEtWR6-rTTPJA.png" /></figure><p><strong>Scenario 3:<br></strong>Connection pool config — initial-size: <strong>10</strong>, max-size: <strong>20 (default Hikari CP config given to r2dbc)</strong></p><ul><li>Tested with 130 req/seconds, 135 req/second, 150 req/Seconds</li><li>135reg/seconds executed 4 times. 3 times we got 100 % success — 1300 records were inserted</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G-DXOZiSZlIc9oiAihe5aQ.png" /></figure><ul><li>1one time I got 98% success— 1283 records were successfully inserted</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fGvcgc5vPQGBa7ej2QcDxA.png" /></figure><ul><li>The same scenario happened when tried with 145 and 150 req/seconds</li><li>with 150 req/second one time, we started getting <strong>connection reset by peer error</strong></li><li>One request got errored out. able to insert 1499 records in 10.4 seconds.</li><li>Out of 4 tests with 150req/second. we had success 3 times and one time request got errored out</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q8Q0OE3u6vMb2UoFNuagig.png" /></figure><ul><li>Started seeing a high spike in database CPU. Around 57.7 % utilisation</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GoIxMt9radQlYnRjDZzjMw.png" /></figure><p>Summary:</p><ul><li>Performance looks good with the default connection pool.</li><li>The Major concern I see here is the CPU spike. Let&#39;s compare it with a blocking Springboot application</li></ul><h3>Testing using a blocking Application with HikariCP Connection Pool</h3><p>Github repo: <a href="https://github.com/arjunbalussery/kotllin-sync">https://github.com/arjunbalussery/kotllin-sync</a></p><h4>Scenario 1 :</h4><ul><li>Connection pool config — initial-size: <strong>10</strong>, max-size: <strong>20 (default Hikari CP config given to r2dbc)</strong></li><li>Stress testing using K6 started with 10 req/seconds to 150 req/seconds</li></ul><p>Analysis</p><ul><li>Started getting some errors when we reached 150 requests/seconds</li><li>Till reaching 150 req/seconds. Performance was pretty similar to r2dbc and no errors.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nm0bmeNUgKzKzsXPL7jEzQ.png" /></figure><blockquote>When comparing CPU. It looks like Hikari Pool and JDBC connections are more optimized. <strong>The CPU spike went up to only 5 %</strong>. Whereas r2dbc with r2dbc pool it reached 57 %</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2FcbPA_k-Qg_X499TYZakg.png" /></figure><h3>Conclusion</h3><ul><li>For a simple write scenario, JDBC with HikariCP pool gives better PostgreSQL database CPU optimization comparing non-blocking r2dbc with r2dbc connection pool</li><li>The number of parallel requests that can be handled by both blocking and non-blocking applications for the scenario specified here is pretty much the same.</li><li>It seems r2dbc with jooq , springboot, postgres need more optimizations. Need to dig deeper into what all are the parameters we can configure to create a better performance</li><li>Some of you may already have some experience with some issues and might have overcome them. Appreciate it If you could share your thought process or opinions that help r2dbc connections will give better performance</li><li>Even though I strongly believe in a non-blocking system. it is really important to understand the system-specific scenarios and come up with solutions for them.</li><li>We have seen some performance issues with database IO operations. However, I strongly believe that systems that are connected to multiple systems for consuming data would be a good candidate to make it completely non-blocking. Which will give higher performance.</li></ul><p>Would be great if you could share any thought processes or scenarios we can test and optimize the system further<br>Stay Hungry …</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61aabe970b29" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Springboot Reactive Programming with Kotlin Coroutine + Jooq + PostgreSQL]]></title>
            <link>https://medium.com/@arjunac009/springboot-reactive-programming-with-kotlin-coroutine-jooq-postgresql-aab727b64c2f?source=rss-d833b3181cb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/aab727b64c2f</guid>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[reactive-programming]]></category>
            <category><![CDATA[r2dbc]]></category>
            <category><![CDATA[springboot-3]]></category>
            <category><![CDATA[jooq]]></category>
            <dc:creator><![CDATA[arjun nagathankandy]]></dc:creator>
            <pubDate>Wed, 20 Dec 2023 18:03:27 GMT</pubDate>
            <atom:updated>2023-12-21T08:19:18.978Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Dependency</strong></p><ul><li>SB3.2</li><li>Jooq 3.18</li><li>Postgres16:alpine</li></ul><p><strong>Mainly focusing on the below topics</strong></p><ul><li>Non-blocking Springboot Microservice connecting to a PostgreSQL(Docker)</li><li>Stress testing Database Write functionality with K6</li><li>Blocking Springboot Microservice connecting to a PostgreSQL(Docker)</li><li>Stress testing Database Write functionality with K6</li><li>Comparing the result concerning the performance of R2DBC and JDBC with respective connection-pool</li></ul><p><strong>STEP 1: Create a non-blocking microservice using spring-boot and Kotlin<br>- Below we created a simple system that has an endpoint to add products to a database</strong></p><p>Github Repo: <a href="https://github.com/arjunbalussery/kotlin-async">https://github.com/arjunbalussery/kotlin-async</a></p><p><strong>Let&#39;s dig deep into the project</strong></p><ul><li><strong>What is meant by non-blocking?</strong><br>There are lots of good articles to read about it. Here I am just briefly explaining the concept. Let&#39;s think about a scenario of receiving a request.<br>- Every request to a spring-boot microservice will get allocated to a thread <br>- This thread will be responsible for executing the request and giving back the result.<br>- So basically this particular thread is dedicated to an incoming request and until the request is processed/ errored out, no other request will be able to access this thread.<br>- So this thread is basically in a blocked state concerning another request.<br>- If the processing of a request requires heavy I/O operation, This thread will be blocked for a long time which will affect the performance of the entire application</li><li><strong>How to overcome this</strong>?<br>- We need a mechanism that can pause execution and allocate the thread to another request during heavy operations. Once we get the result back from the operation. the mechanism should be able to resume and start executing the remaining process by allocating to a thread.<br>- So basically a function <strong>should be able to suspend</strong> and then resume without blocking any particular thread</li><li><strong>How to achieve it?<br></strong>Kotlin by default gives a modifier called <strong>suspend</strong> to achieve this functionality</li></ul><pre>    suspend fun save(product: Product): UUID = repository<br>            .save(product)</pre><ul><li>Now in Springboot3(SB3), spring is allowing controllers with suspend functionality so that it does not create a new thread. Instead, it schedules the suspend function to be executed on an existing thread from the application’s thread pool. This is because suspend functions are designed to be asynchronous and non-blocking, which means they do not hold onto the current thread while they are executing. Instead, they can suspend themselves and resume at a later time when they are ready to continue.</li><li>So great which solves the first problem and we can call a service component that is also a suspended function</li></ul><pre>@RestController<br>class SaveProductController(<br>    private val service: ProductService<br>) {<br>    @PostMapping(&quot;/api/v1&quot;)<br>    suspend fun save(@RequestBody saveProduct: SaveProduct): ResponseEntity&lt;UUID&gt; = service<br>        .save(Product(UUID.randomUUID(), saveProduct.name))<br>        .let { ResponseEntity(it, HttpStatus.CREATED) }<br>}</pre><ul><li><strong>What about the database (IO operation)? can we make it non-blocking?</strong><br>- JDBC is still working in a blocked manner<br>- Luckily we have R2DBC (Reactive Relational Database Connectivity) which allows us to connect the database in a nonblocking way.<br>- Springboot now auto-configures R2DBC and Postgres16 also giving R2DBC support.<br>-So all good. What about our connection-pool? We have been using Hikari for a long time and it is optimized. <br>- The bad news is Hikari does not support reactive relational database connections<br>-There is a r2dbc connection pool. So we have to replace Hikari with <a href="https://github.com/r2dbc/r2dbc-pool">r2dbc connection pool</a>. So here is the big question how efficient it is?</li></ul><p><strong>STEP 2: Create a Gradle build script with all configurations</strong><br>- <a href="https://github.com/arjunbalussery/kotlin-async/blob/main/kotlin/build.gradle.kts">build.gradle.kts</a><br>- I have added inline comments in the Gradle build file. Hope it is self-explanatory. If any doubt feel free to ask in the comment section.</p><p><strong>STEP 3: add controller, service, and repository<br></strong>- As we already added code snippets for controller and service. let&#39;s look into the repository code snippet</p><pre>@Repository<br>class ProductRepository(<br>    private val jooq: DSLContext<br>) {<br>    suspend fun save(product: Product): UUID = withContext(Dispatchers.IO) {<br>         jooq<br>            .insertInto(PRODUCT)<br>            .columns(PRODUCT.ID, PRODUCT.NAME)<br>            .values(product.id, product.name)<br>            .returning(PRODUCT.ID)<br>            .awaitFirst()<br>            .id<br>    }<br>}</pre><ul><li>As you can see we are using the `<strong>suspend</strong>` keyword in the function</li><li>we are injecting Jooq DSL context</li><li>In the gradle file, we already added dependencies which required for coroutines</li></ul><pre> //coroutine<br> implementation(&quot;org.jetbrains.kotlinx:kotlinx-coroutines-reactive:1.8.0-RC&quot;)<br> implementation(&quot;org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0-RC&quot;)<br> implementation(&quot;org.jetbrains.kotlinx:kotlinx-coroutines-reactor:1.8.0-RC&quot;)<br> implementation(&quot;org.jetbrains.kotlin:kotlin-reflect&quot;)<br> implementation(&quot;io.projectreactor.kotlin:reactor-kotlin-extensions&quot;)</pre><ul><li>So we were able to use the extension function `<strong>awaitFirst()</strong>` to make the code execute in a non-blocking manner. it comes from `<strong>kotlinx.coroutines.reactive</strong>` library</li></ul><p><strong>STEP 4: Add application.yml and database migration script<br></strong>- r2dbc properties</p><pre>spring:<br>  jooq:<br>    sql-dialect: postgres<br>  r2dbc:<br>    url: r2dbc:postgresql://postgres:5432/postgres<br>    username: postgres<br>    password: pass123<br>    pool:<br>      enabled: true<br>      initial-size: 10<br>      max-size: 20<br>      maxAcquireTime: 30s<br>      idle-timeout: 10m<br>      max-life-time: 30m</pre><pre>url: r2dbc:postgresql://postgres:5432/postgres</pre><ul><li>Replace it with the URL below if you want to connect to a Postgres running on your local machine. This system is running as a multi-container and this URL is intended to connect from one container to another Postgres container. will explain in a later section how to run it.</li></ul><pre>url: r2dbc:postgresql://localhost:5432/postgres</pre><p><strong>STEP 5: Explicit Configuration of Connection Pool</strong></p><ul><li>even though — “<strong>org.springframework.boot:spring-boot-starter-data-r2dbc:3.2.0</strong>” is capable of auto-configuring r2dbc properties with connection factory. While doing stress testing I was faced with some issues related to connection release.</li><li>Also, I started getting an Async timeout exception when the number of parallel requests increased.<br>will discuss it in the stress testing section</li><li>It can be related to the Jooq configuration.</li><li>So I decided to explicitly configure connection pool and connection factory</li></ul><pre>@Configuration<br>class R2DBCConfiguration(<br>    private val properties: R2dbcProperties<br>) {<br><br>    @Bean<br>    fun connectionPool(<br>        connectionFactory: ConnectionFactory,<br>    ): ConnectionPool {<br>        val poolConfig = ConnectionPoolConfiguration.builder(connectionFactory)<br>            .maxIdleTime(properties.pool.maxIdleTime )<br>            .maxSize(properties.pool.maxSize)<br>            .initialSize(properties.pool.initialSize)<br>            .build()<br><br>        return ConnectionPool(poolConfig)<br>    }<br><br>    @Bean<br>    fun databaseClient(<br>        connectionFactory: ConnectionFactory<br>    ): DatabaseClient {<br>        return DatabaseClient.create(connectionFactory)<br>    }<br><br>    @Bean<br>    fun connectionFactory(properties: R2dbcProperties): ConnectionFactory {<br>        val connectionConfiguration = PostgresqlConnectionConfiguration<br>            .builder()<br>            .host(&quot;postgres&quot;) // for connecting from one container to another postgres container<br>            .port(5432) // Your database port<br>            .database(properties.name)<br>            .username(properties.username)<br>            .password(properties.password)<br>            .build()<br><br>        return PostgresqlConnectionFactory(connectionConfiguration)<br>    }<br>}</pre><p><strong>STEP 5: How to run the system?</strong></p><ul><li>Open terminal</li><li>clone the repo- <a href="https://github.com/arjunbalussery/kotlin-async">https://github.com/arjunbalussery/kotlin-async</a></li><li>Make sure you have a docker desktop running on your machine</li><li>I have already added a bash script called <strong>setup.sh </strong>which will able to do the initial setup and start the application</li><li>go to the parent folder (<strong>cd kotlin-async/kotlin)</strong></li><li>give execution permission to <strong>setup.sh</strong> and run the script in the terminal</li></ul><pre>chmod 755 setup.sh<br>./setup.sh</pre><ul><li>which will generate jooq stubs, create a gradle build then make the Postgres container running</li><li>Which internally uses docker-compose to build the application</li><li>You will be able to hit the application using below curl command</li></ul><pre>curl --location &#39;localhost:8080/api/v1&#39; \<br>--header &#39;Content-Type: application/json&#39; \<br>--data &#39;{<br>    &quot;name&quot;: &quot;bus123&quot;<br>}&#39;</pre><ul><li>Or There is a K6 folder. you can open another terminal and execute the k6 script using the below command. which will trigger 10 parallel requests to the application</li><li>you may need to install k6 in your system. For Mac, you can use brew to install it.</li></ul><pre> k6 run k6/loadtest.js</pre><ul><li>have fun</li><li>Please let me know if any additional needed in the comment section. Happy to help</li></ul><p><strong>STEP 6: How to stop the system</strong></p><ul><li>Open another terminal</li><li>Go to the cloned repo folder (<strong>cd kotlin-async/kotlin)</strong></li><li>give execution permission to <strong>stop.sh</strong> and run the script in the terminal</li></ul><pre>chmod 755 stop.sh<br>./setup.sh</pre><p><strong>Enjoy<br></strong>In the article below, we will be discussing the write-heavy experiment we have done with the system.<br><a href="https://medium.com/@arjunac009/stress-testing-reactive-springboot-application-with-kotlin-coroutine-jooq-postgresql-61aabe970b29">Stress Testing Reactive Springboot Application with Kotlin Coroutine + Jooq + PostgreSQ</a>L</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aab727b64c2f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sprinklr Kerala High Court Interim Order favours Right wing]]></title>
            <link>https://medium.com/@arjunac009/sprinklr-kerala-high-court-interim-order-favours-right-wing-5eee793390cf?source=rss-d833b3181cb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/5eee793390cf</guid>
            <category><![CDATA[high-court]]></category>
            <category><![CDATA[political]]></category>
            <category><![CDATA[india]]></category>
            <category><![CDATA[kerala]]></category>
            <category><![CDATA[sprinklr]]></category>
            <dc:creator><![CDATA[arjun nagathankandy]]></dc:creator>
            <pubDate>Sat, 25 Apr 2020 16:59:54 GMT</pubDate>
            <atom:updated>2020-04-25T16:59:54.796Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*lCnSXqsyQ-JlJ2tOm1rZfA.png" /></figure><p>Sprinkler — HC directions in the interim order<br>There were lot of discussion happening on the interim order.<br>It is interesting that both the left wing and right wing supporters are saying the order favours them.<br>which made me to dig deeper and understand about main points on the same.<br>The order issued by Division Bench comprising Justice Devan Ramachandran and Justice TR is really in favour of kerala people and definitely give upper hand for the right wing.<br><strong>The main point put forward by left supports is below.</strong><br>1. T<em>he honourable HC didn’t ask government to stop using sprinklr. So the interim order favours the government.<br>I think people or supporters who projecting this either didn’t go through the order or just got partial information.</em></p><p><strong>The bench has a clear comment on it. adding it below.</strong></p><blockquote>“We have many serious reservations about statement filed by the State. We do not know how the company was selected and what are their credentials. Normally, we would have interfered. But we do not want to interfere with COVID-19 battle. So, a balance has to be drawn”</blockquote><p>It clearly state that court is has real concern about it but due to the current situation and government already has chosen an organisation . So interference at this stage may make things worst. Court giving highest consideration to people’s health and life here. Really remarkable.<br><strong>The bench added below observations which call the government activities into question.</strong><br>1.<em> The Court also observed that it was amazed that the law department was not consulted before finalizing the Sprinklr deal despite several legal issues in it</em><br>2.<em>What is worrying is that the IT Secretary took a decision without consulting the law department even though many legal issues were involved. Merely because there is an emergency, you cannot create more problems. The cure cannot be worse than the problem</em><br>3.<em>If there is a breach, costs will be unimaginable. Can a head of department enter into a contract on his own under Article 299? This is throwing up a lot of legal issues, and no law dept sanction was taken!</em></p><p><strong>The other main points in the interim order are</strong><br>1. <em>banned all promotions of sprinklr which having appearance of our honarble IT secretary with Kerala government Logo</em><br>2. <em>HC asked to anonymize all data collected from citizens before allowing access to US company Sprinklr.</em><br>3. <em>Directed the state government to take informed consent from individuals before allowing a third party foreign company to process their data.</em><br>4.<em>The case will be heard again after three weeks.<br>Court praised the effort taken by government to prevent COVID-19 spread but also warns the government don’t create another pandemic because of data breach.</em><br><em>For me it is a judgment with pure consideration of law and fact rather than political drama. A Interim order really favours the people of Kerala, India.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5eee793390cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java Generics Simplified- Array vs Generics]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@arjunac009/java-generics-simplified-array-vs-generics-e3d9d9b3c6f8?source=rss-d833b3181cb4------2"><img src="https://cdn-images-1.medium.com/max/2600/1*1Zh5x7OUG7BoW7_KDrN1pg.jpeg" width="3500"></a></p><p class="medium-feed-snippet">This article basically dealing with some concept regarding arrays and generics.</p><p class="medium-feed-link"><a href="https://medium.com/@arjunac009/java-generics-simplified-array-vs-generics-e3d9d9b3c6f8?source=rss-d833b3181cb4------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@arjunac009/java-generics-simplified-array-vs-generics-e3d9d9b3c6f8?source=rss-d833b3181cb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3d9d9b3c6f8</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[arraylist]]></category>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[compile-times]]></category>
            <category><![CDATA[generics]]></category>
            <dc:creator><![CDATA[arjun nagathankandy]]></dc:creator>
            <pubDate>Sat, 25 May 2019 12:15:21 GMT</pubDate>
            <atom:updated>2019-05-25T16:41:03.737Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Spring-boot microservice with centralized authentication (ZUUL+Eureka+JWT)]]></title>
            <link>https://medium.com/@arjunac009/spring-boot-microservice-with-centralized-authentication-zuul-eureka-jwt-5719e05fde29?source=rss-d833b3181cb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/5719e05fde29</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[zuul]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[jwt]]></category>
            <dc:creator><![CDATA[arjun nagathankandy]]></dc:creator>
            <pubDate>Mon, 22 Oct 2018 18:51:21 GMT</pubDate>
            <atom:updated>2018-10-27T13:37:22.667Z</atom:updated>
            <content:encoded><![CDATA[<p>We are going to discuss an architecture in which one microservice will act as a gateway service. Which does central authentication, redirect an incoming request to other microservices. The main advantage of this architecture you can easily add multiple microservices to the system and all authentication, authorization will be taken care from a central unit.</p><ol><li>gateway service: Which will act as a central authentication unit, ZUUL proxy server for redirection.</li><li>cart service: This will act as a eureka client, which receive a request from gateway service.</li></ol><p>Let&#39;s design the architecture like below. Don’t think too much we can split it and work nicely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*jw1fR1zfjnn3jjQrtZwIqw.png" /><figcaption>Architecture</figcaption></figure><p><strong>First Step</strong>: Create a gateway using spring-boot microservice. Add ZUUL, Eureka server dependency to it. So gateway will act as ZUUL proxy server as well as service registry for Eureka client. Don’t worry we can dig deeper into it.</p><p><strong>Second Step:</strong> Create one microservice with Eureka client dependency and register them in Eureka server.</p><p><strong>Third Step: </strong>Test the application.</p><p><strong>Fourth Step</strong>: Now add Spring security dependency in the gateway and check how it is affecting our application.</p><p><strong>Fifth Step:</strong> Make the changes test the application. Yes, we are done !!!!</p><p>Let ‘s start coding.</p><h3><strong>First Step</strong></h3><p>Go to <a href="https://start.spring.io/">https://start.spring.io</a> to create spring initializer. Add ZUUL, Eureka server, web dependency to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zq9OSKrOzkg1WqdV8qv7Tg.png" /><figcaption>gateway with ZUUL, Eureka server, web-dependency</figcaption></figure><p>Download and unzip the file. open it in the editor. check your pom.xml to check the dependencies.</p><p>Now we need to make this gateway microservice as a ZUUL proxy server as well as Eureka server registry. Okay, let&#39;s do it.</p><p>Go to the main application file and add below annotations</p><pre><strong>@EnableZuulProxy  </strong>// act as zuul proxy.<br><strong>@EnableEurekaServer</strong> //for making this application as eureka server.</pre><pre>package com.arjun.gateway;<br><br>import org.springframework.boot.SpringApplication;<br>import org.springframework.boot.autoconfigure.SpringBootApplication;<br>import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;<br>import org.springframework.cloud.netflix.zuul.EnableZuulProxy;<br><br>@EnableZuulProxy  // act as zuul proxy.<br>@EnableEurekaServer //for making this application as eureka server.<br>@SpringBootApplication<br>public class GatewayApplication {<br><br>   public static void main(String[] args) {<br>      SpringApplication.<em>run</em>(GatewayApplication.class, args);<br>   }<br>}</pre><p>Fine now we need to add some properties to our application.properties file.</p><pre>#Name of the application<br>spring.application.name=gateway<br>#This is a eureka server so no need to register<br>eureka.client.register-with-eureka=false<br>#This is a eureka server no need to fetch registry<br>eureka.client.fetch-registry=false<br>#Register url for client<br>eureka.client.service-url.defaultZone=http://localhost:8080/eureka<br>#timeout<br>eureka.server.wait-time-in-ms-when-sync-empty=0<br>#All url come with prefix/api will interpret<br>zuul.prefix=/api</pre><p>We are done. Just start the application and go to the URL <a href="http://localhost:8080/">http://localhost:8080</a> .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L-KUcjJkJB49AZwNX8Hh8Q.png" /></figure><p>As you can see in the picture. No instances are available. Which means service registry is fine and it is looking for the Eureka client to register. But currently, we don’t have any Eureka clients. So far so good let&#39;s go and create a client</p><p>When I am saying Eureka client don’t confuse it with front-end client. Eureka clients are microservices. It is a server side thing. But with respect to the gateway (Eureka server), these microservice will act as the client.</p><p>We have completed the first step. My commit till this point is below.</p><blockquote><a href="https://github.com/arjunbalussery/gateway/commit/a17f1f0d6567313dbb61769a76ef4ae2898b6c68"><strong>https://github.com/arjunbalussery/gateway/commit/a17f1f0d6567313dbb61769a76ef4ae2898b6c68</strong></a></blockquote><h3><strong>Second Step</strong></h3><p><strong>Create a microservice with Eureka client dependency and register it to the Eureka server. Make use of ZUUL proxy to redirect the request from the gateway to the client microservice. Excited?!!. Let’s make our hand a little dirty.</strong></p><p>First create a microservice with Eureka client dependency (Eureka Discovery) as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*08B7PkEMOJWd_FiEUQ9k9A.png" /></figure><p>We are going to create a cart microservice which perform all operation related with cart.</p><p>For simplicity, I am adding only one operation which retrieves cart details for a particular user. for that</p><p>1 Added 2 bean classes product, Cart</p><p>2 Added a cartController class</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vYobxGsvRNVpft71VCsOUA.png" /></figure><p>CartController will look like below.</p><pre>@RestController<br>@RequestMapping(&quot;v1/cart&quot;)<br>public class CartController<br>{<br><br>    @GetMapping(&quot;/{userId}&quot;)<br>    public Cart getCart(@Valid @PathVariable long userId)<br>    {<br>        // For simplicity we are returning a hard coded value<br>        List&lt;Product&gt; products = new ArrayList&lt;&gt;();<br>        //p1<br>        Product p1 = new Product(1,&quot;keyboard&quot;,250,2);<br>        p1.setTotlalPrice(p1.getBasePrice()*p1.getQuantity());<br>        products.add(p1);<br><br>        //p2<br>        Product p2 = new Product(2,&quot;mouse&quot;,150,2);<br>        p2.setTotlalPrice(p2.getBasePrice()*p2.getQuantity());<br>        products.add(p2);<br><br>        //calculating total price<br>        double totalPrice=products.stream().mapToDouble(p-&gt;p.getTotlalPrice()).sum();<br><br>        Cart cart = new Cart(products.size(),totalPrice, products);<br>        return cart;<br><br>    }<br><br>}</pre><p>At this point, you can test this application separately. For that, you need to comment below dependency (Eureka Client) and import the changes. Because we still not added this microservice as a eureka Client.</p><pre>&lt;!--&lt;dependency&gt;<br>   &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;<br>   &lt;artifactId&gt;spring-cloud-starter-netflix-eureka-client&lt;/artifactId&gt;<br>&lt;/dependency&gt;!--&gt;</pre><p>let&#39;s test using below url.</p><blockquote><strong>Request</strong> : GET, url : <a href="http://localhost:8080/v1/cart/123">http://localhost:8080/v1/cart/123</a></blockquote><blockquote><strong>Response</strong> : {“totaltems”:2,”totalPrice”:800.0,”products”:[{“id”:1,”name”:”keyboard”,”basePrice”:250.0,”quantity”:2,”totlalPrice”:500.0},{“id”:2,”name”:”mouse”,”basePrice”:150.0,”quantity”:2,”totlalPrice”:300.0}]}</blockquote><p>Fine great. Next register this microservice as a eureka client. How do we do that? It is really simple.</p><p>1 ) Uncomment the above dependency and import the changes.</p><p>2) Go to the main application file and add @EnableEurekaClient Annotation. Like below.</p><pre>package com.arjun.cart;<br><br>import org.springframework.boot.SpringApplication;<br>import org.springframework.boot.autoconfigure.SpringBootApplication;<br>import org.springframework.cloud.netflix.eureka.EnableEurekaClient;<br><br>@EnableEurekaClient<br>@SpringBootApplication<br>public class CartApplication {<br><br>   public static void main(String[] args) {<br>      SpringApplication.<em>run</em>(CartApplication.class, args);<br>   }<br>}</pre><p>3) Now we need to consider a couple of things. Eureka server is running on 8080 port. So we need another port for our client application. let&#39;s give this 8081 port.</p><p>4) Ask cart service (Eureka client)to register to gateway (Eureka server)service</p><p>How do we do that? Let&#39;s use our application.properties for the above configurations.</p><pre>#Name of the application<br>spring.application.name=cart<br>server.port=8081<br>#Eureka server url for registering<br>#This is eureka client<br>eureka.client.register-with-eureka=true<br>eureka.client.fetch-registry=true<br>#register url to server<br>eureka.client.serviceUrl.defaultZone=http://localhost:8080/eureka/<br>instance.hostname=localhost</pre><p>Fine. Looks great. let&#39;s start testing whether everything works till now.</p><p>First start gateway service, then start our cart application. To check whether out client service register to the server goes to the below URL.</p><p><a href="http://localhost:8080/">http://localhost:8080/</a> you can see the cart application is registered on gateway service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AGMoGUdagZVEU-uoKJrPqg.png" /></figure><p>All looks fine. My commit for cart service is below.</p><blockquote><a href="https://github.com/arjunbalussery/cart/commit/8f7fea38fcfc6c9cd84a4bbcd8933b935aafbe64"><strong>https://github.com/arjunbalussery/cart/commit/8f7fea38fcfc6c9cd84a4bbcd8933b935aafbe64</strong></a></blockquote><p>Now we have registered cart service to the gateway. The next problem is how to access cart through gateway service ?. Here ZUUL proxy will help us. So <strong>let’s do the changes in the gateway service to accommodate this.</strong> Alter the application.properties file and add below properties.</p><pre>zuul.routes.middleware.path=/cart/**<br>zuul.routes.middleware.url=http://localhost:8081/</pre><p>It means whichever URL coming with<strong> /cart/**</strong> redirect it to <a href="http://localhost:8081/"><strong>http://localhost:8081/</strong></a></p><p>is that enough? yes, we implemented it.</p><h3><strong>Third Step: </strong>Test the application<strong>.</strong></h3><p>Let&#39;s test it. Start gateway, cart services and hit gateway with below URL</p><p><a href="http://localhost:8080/api/cart/v1/cart/123"><strong>http://localhost:8080/api/cart/v1/cart/123</strong></a></p><p>Check you are getting the response which you got earlier.</p><blockquote><strong>Request</strong> : GET, url : <a href="http://localhost:8080/api/cart/v1/cart/123">http://localhost:8080/api/cart/v1/cart/123</a></blockquote><blockquote><strong>Response</strong> : {“totaltems”:2,”totalPrice”:800.0,”products”:[{“id”:1,”name”:”keyboard”,”basePrice”:250.0,”quantity”:2,”totlalPrice”:500.0},{“id”:2,”name”:”mouse”,”basePrice”:150.0,”quantity”:2,”totlalPrice”:300.0}]}</blockquote><p>Let’s split the URL to understand much better.</p><p><a href="http://localhost:8080/api/cart/v1/cart/123"><strong>http://localhost:8080/api/</strong></a><strong> -&gt;</strong> <em>help to reach the gateway.</em></p><p><a href="http://localhost:8080/api/cart/v1/cart/123">http://localhost:8080/api<strong>/cart/</strong></a><strong> -&gt; </strong><em>This helps ZUUL proxy to redirect the request to cart service by appending the remaining part. ie finally it will be converted to</em> <a href="http://localhost:8080/api/cart/v1/cart/123"><strong>http://localhost:8081/v1/cart/123</strong></a></p><p>All looks fine. My commit for gateway service changes is below.</p><blockquote><a href="https://github.com/arjunbalussery/gateway/commit/f0043ffce9148cea12e7945bc78ac571a7e5a39b"><strong>https://github.com/arjunbalussery/gateway/commit/f0043ffce9148cea12e7945bc78ac571a7e5a39b</strong></a></blockquote><h3>Fourth Step<strong>: A</strong>dd Spring security dependency in the gateway and check how it is affecting our application.</h3><p>Great. We are going to extend the spring security filter and implements JWT token-based authentication(JSON Web tokens). We will be using MongoDB to store user information, generated JWT tokens. So we need to add a couple of dependencies and import those changes to our application. Let&#39;s do it step by step.</p><p><strong>Step 1: Add below dependency in pom.xml</strong></p><p>1 ) spring-security</p><pre>&lt;dependency&gt;<br>   &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;<br>   &lt;artifactId&gt;spring-security-test&lt;/artifactId&gt;<br>   &lt;scope&gt;test&lt;/scope&gt;<br>&lt;/dependency&gt;</pre><pre>&lt;dependency&gt;<br>   &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>   &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;<br> &lt;/dependency&gt;</pre><p>2) spring-data-mongo</p><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>    &lt;artifactId&gt;spring-boot-starter-data-mongodb&lt;/artifactId&gt;<br>&lt;/dependency&gt;</pre><p>3) JWT</p><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;io.jsonwebtoken&lt;/groupId&gt;<br>    &lt;artifactId&gt;jjwt&lt;/artifactId&gt;<br>    &lt;version&gt;0.9.1&lt;/version&gt;<br>&lt;/dependency&gt;</pre><p>What we are going to implement.</p><ol><li>Signin request accepts username and password. If username and password are valid it will generate a jwt token and sent back the token in the response header.</li><li>All other request headers should contain the JWT token which we have generated from signin service, it will be validated. If validation fails an exception will be thrown from filter service.</li><li>Request with valid JWT token will be processed.</li><li>Request header should contain →<strong> Authorization : valid-jwt-token </strong>key value pairs</li></ol><p><strong>Step 2: Create User bean, Role bean, User service, User repository to store and retrieve user information.</strong></p><blockquote><a href="https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/bean/auth/User.java">https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/bean/auth/User.java</a></blockquote><blockquote><a href="https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/bean/auth/Role.java">https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/bean/auth/Role.java</a></blockquote><blockquote><a href="https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/security/UserService.java">https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/security/UserService.java</a></blockquote><blockquote><a href="https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/repository/UserRepository.java">https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/repository/UserRepository.java</a></blockquote><p><strong>Step 3: Implements Spring UserDetails interface to implement spring security.</strong></p><blockquote><a href="https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/bean/auth/MongoUserDetails.java">https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/bean/auth/MongoUserDetails.java</a></blockquote><p><strong>Step 4: Create a security package and add Jwt token filter, jwt token configuration, jwt token provider and a websecurityConfig</strong></p><blockquote><a href="https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/security/JwtTokenFilter.java">https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/security/JwtTokenFilter.java</a></blockquote><blockquote><a href="https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/security/JwtTokenFilterConfigurer.java">https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/security/JwtTokenFilterConfigurer.java</a></blockquote><blockquote><a href="https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/security/JwtTokenProvider.java">https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/security/JwtTokenProvider.java</a></blockquote><blockquote><a href="https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/security/WebSecurityConfig.java">https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/security/WebSecurityConfig.java</a></blockquote><p><strong>Step 5: Create a signin, signout mechanism</strong></p><blockquote><a href="https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/controller/LoginController.java">https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/controller/LoginController.java</a></blockquote><blockquote><a href="https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/service/serviceimpl/LoginService.java">https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/service/serviceimpl/LoginService.java</a></blockquote><blockquote><a href="https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/repository/JwtTokenRepository.java">https://github.com/arjunbalussery/gateway/blob/master/src/main/java/com/arjun/gateway/repository/JwtTokenRepository.java</a></blockquote><p><strong>Step 6: Add MongoDB Configurations in the application.properties</strong></p><pre>#spring data mongo<br>spring.data.mongodb.authentication-database=admin<br>spring.data.mongodb.username=root<br>spring.data.mongodb.password=root<br>spring.data.mongodb.database=test<br>spring.data.mongodb.port=27017<br>spring.data.mongodb.host=localhost</pre><p>I am not going too much deeper. You can search in the medium for JWT token implementation. If You really want me to explain deeper, please put in the comment section will write an article on the same.</p><p>Super we have added spring security using JWT token. Everything nice and well. let&#39;s go for testing.</p><h3><strong>Fifth Step: Test our application.</strong></h3><p>Let’s test it. Start gateway, cart services and hit gateway with below URL</p><p><a href="http://localhost:8080/">http://localhost:8080</a> .</p><p>Do you able to see our cart service registered on the gateway service?. Yes it is registered.</p><p>That&#39;s fine. But let me ask you one thing. We have mentioned earlier all request except signin request should contain JWT token in their request header. But here we haven’t sent any headers in the<strong> </strong><a href="http://localhost:8080/"><strong>http://localhost:8080</strong></a> request. Then how it worked?</p><p>For registering to gateway our cart service should request with below URL <a href="http://localhost:8080/eureka/"><strong>http://localhost:8080/eureka/</strong></a><strong> </strong>here also we are not sending any headers. Still, it worked. Does our security has any problem? What do you think?</p><p>No, our security don&#39;t have any problem. Go and check in the WebSecurityConfig.java. There you can see below code. This help us to achieve this.</p><pre>@Override<br>public void configure(WebSecurity web) throws Exception {<br>    // Allow eureka client to be accessed without authentication<br>    web.ignoring().antMatchers(&quot;/*/&quot;)//<br>            .antMatchers(&quot;/eureka/**&quot;)//<br>            .antMatchers(HttpMethod.<em>OPTIONS</em>, &quot;/**&quot;); // Request type options should be allowed.<br>}</pre><ol><li>Call signin service (POST) with below body<br>username:username<br>password:password</li><li>copy the jwt token from the response header.</li><li>Call cart service with the request header <strong>Authorization: jwtTokenrecieved</strong></li><li>Check we are getting the proper response from cart service.</li></ol><p>Congratulations you have done it !!!</p><p>Ask all your suggestions, doubts in the comment section. HAPPY CODING !!!</p><h3><strong>Github</strong></h3><ol><li>gateway<br><a href="https://github.com/arjunbalussery/gateway">https://github.com/arjunbalussery/gateway</a></li><li>cart<br><a href="https://github.com/arjunbalussery/cart">https://github.com/arjunbalussery/cart</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5719e05fde29" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>