tag:blogger.com,1999:blog-88823770314565879002024-03-19T02:57:32.433+05:30JavaXp.com | Java Experts Blog | Java Examples | API | Errors | Exceptions<b>Java, J2EE, SQL, Frameworks, APIs, Exceptions and more..</b>Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.comBlogger385125tag:blogger.com,1999:blog-8882377031456587900.post-66712203746674455452024-03-19T02:55:00.004+05:302024-03-19T02:57:00.019+05:30Simplifying Docker Deployment with PM2<p>As you know, <a href="https://pm2.keymetrics.io/" target="_blank">PM2</a> is a daemon process manager that allows you to keep applications online. Many times, you may be running your service inside a Docker image. The service can be written in any language, such as Node.js, Java, etc. Below is the shell script that can be used to deploy your service. It can be added and used in your CI/CD pipeline.</p><br />
<script src="https://gist.github.com/madan712/76829bd78ccd04651fc912ac84a1ac34.js"></script>Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.com0tag:blogger.com,1999:blog-8882377031456587900.post-65669649625757720922023-12-31T21:00:00.007+05:302024-03-16T05:17:56.729+05:30AWS - Get quicksight embed url using JavaScript SDK V3<p>In the realm of data-driven solutions, AWS QuickSight offers a robust platform for crafting dynamic and insightful dashboards. Embedding these dashboards directly into your applications adds a layer of accessibility and convenience. This guide walks you through the process of obtaining a secure QuickSight embed URL using JavaScript SDK V3, suitable for both Node.js backend and Lambda functions. Before proceeding, ensure your QuickSight dashboard is created and shared with the intended audience.</p><p><b>Prerequisites:</b></p><p>Make sure you've completed the following preliminary steps:</p><p></p><b>Dashboard Setup:</b><div><b><span> </span><br /></b></div>Create your QuickSight dashboard and Share the dashboard with all users in your AWS account.<div>Open the published dashboard and choose Share at upper right. Then choose Share dashboard.<br /><div><br /><div><div class="separator" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEg88GgCVPqVKxi5X1KW2zgUrEVItG1Oa1n7lWTacw3eKAXMLaVD10HXX6RtlN_ncMyRJRKTpalKflfjluEMYs0Jt9dSyWUcYMYxWzN5DYv-tqkLpdrz8iIk4zkrMZqqQTfzHOqU5AH3hZqYfssrMGsHypeBC9pz-kNfPqN5fZHwyWZQXCDa6_NvXVEQWGUt" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img alt="" data-original-height="608" data-original-width="855" height="285" src="https://blogger.googleusercontent.com/img/a/AVvXsEg88GgCVPqVKxi5X1KW2zgUrEVItG1Oa1n7lWTacw3eKAXMLaVD10HXX6RtlN_ncMyRJRKTpalKflfjluEMYs0Jt9dSyWUcYMYxWzN5DYv-tqkLpdrz8iIk4zkrMZqqQTfzHOqU5AH3hZqYfssrMGsHypeBC9pz-kNfPqN5fZHwyWZQXCDa6_NvXVEQWGUt=w400-h285" width="400" /></a></div><br /><br /></div><div><b><br /></b></div><div><b><br /></b></div><div><b><br /></b></div><div><b><br /></b></div><div><b><br /></b></div><div><b><br /></b></div><div><b><br /></b></div><div><b><br /></b></div><div><b><br /></b></div><div><b><br /></b></div><div><b><br /></b></div><div><b><br /></b></div><div><b><br /></b></div><div><b><br /></b></div><div><b><br /></b></div><div><b><br /></b></div><div><b>Domain Whitelisting:</b><br /><div><div><br /></div><div>Whitelist the domain where you plan to embed the QuickSight dashboard</div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em; text-align: center;"><span> <div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhN26GdCjJiIzZcVbVdPXWDRlCrBL_7Ve_YcLEfntI0Se6P_80cJ4BOU2ovVi5vkwMkpVC0R_rTYP99-zs9On2gEuIzCzocQZL3A_oL81CvmYb1xQ2axyUkg1gx8v0MDocjFJDKiAg_JLjjqwZy8ibJRCIfn7koPzY4QqQEWtztyCh1K_60tTvkThvNmZIX" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img alt="" data-original-height="622" data-original-width="1265" height="196" src="https://blogger.googleusercontent.com/img/a/AVvXsEhN26GdCjJiIzZcVbVdPXWDRlCrBL_7Ve_YcLEfntI0Se6P_80cJ4BOU2ovVi5vkwMkpVC0R_rTYP99-zs9On2gEuIzCzocQZL3A_oL81CvmYb1xQ2axyUkg1gx8v0MDocjFJDKiAg_JLjjqwZy8ibJRCIfn7koPzY4QqQEWtztyCh1K_60tTvkThvNmZIX=w400-h196" width="400" /></a></div><br /></span></div></div><div><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><span><a name='more'></a></span><p><b>Step 1: </b>IAM Role Creation with Required Policies</p><p>To interact with QuickSight, set up an IAM role with specific permissions. Include the following policies in your IAM role: <span style="color: #2b00fe; font-family: courier;">quicksight:RegisterUser</span> and <span style="color: #2b00fe; font-family: courier;">quicksight:GetDashboardEmbedUrl</span>.</p><p>
<script src="https://gist.github.com/madan712/8d4ad0ec66587e392457cf7a6bfa5ecc.js"></script>
</p><p><b>Step 2: </b>Assuming IAM Role Using AWS SDK</p><p>Assume the IAM role you created using the AWS SDK.</p><p>
<script src="https://gist.github.com/madan712/2172bbb03865ffe57b7a90eba3d97e00.js"></script>
</p><p><b>Step 3: </b>Register a User in QuickSight</p><p>Before obtaining the embed URL, register a user in QuickSight. Note that this is a one-time process; subsequent calls will result in an error.</p><p><script src="https://gist.github.com/madan712/2c195dfe36726221472a0d9692b79f1d.js"></script></p><p>This will create a QuickSight user, as shown below:</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjAUz3EhZSzB8Ckqy8MuL8GhwwzRtDjLGWZsS6dhModXFRUUStyF2luyU--WRizfHUh8aJmmcOjUQl48q52B6PhsigpolkLnvPUGGHzh0c9fVCrmmUTTxZVBwhjCs1daRFu2D7mgvz0mLuwXFT_QhxV4dEHz6ArT_5L9WnCeIYWBOVUhdMVMsRYXAi22RrJ" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img alt="" data-original-height="625" data-original-width="1285" height="195" src="https://blogger.googleusercontent.com/img/a/AVvXsEjAUz3EhZSzB8Ckqy8MuL8GhwwzRtDjLGWZsS6dhModXFRUUStyF2luyU--WRizfHUh8aJmmcOjUQl48q52B6PhsigpolkLnvPUGGHzh0c9fVCrmmUTTxZVBwhjCs1daRFu2D7mgvz0mLuwXFT_QhxV4dEHz6ArT_5L9WnCeIYWBOVUhdMVMsRYXAi22RrJ=w400-h195" width="400" /></a></div><br /><br /><p></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><br /></p><p><b><br /></b></p><p><b>Step 4: </b>Retrieve Secure QuickSight Dashboard Embed URL</p><p>Fetch the secure QuickSight dashboard embed URL using the following code snippet:</p><p><script src="https://gist.github.com/madan712/f8bb91ac04577ebef5815c522ffe1be0.js"></script></p><p><b>Complete Lambda Function Code</b>:</p><p>Here is the complete Node Lambda function code, seamlessly integrating all the steps discussed above:</p><p>Make sure to add following npm package <span style="color: #2b00fe; font-family: courier;">@aws-sdk/client-sts</span> and <span style="color: #2b00fe; font-family: courier;">@aws-sdk/client-quicksight</span></p><div><script src="https://gist.github.com/madan712/9af75f2646a79266cc809fafff174a29.js"></script></div><p><br /></p><p><br /></p></div></div></div></div></div>Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.com0tag:blogger.com,1999:blog-8882377031456587900.post-86460834840381061152023-06-02T20:39:00.001+05:302023-06-02T21:03:12.837+05:30Docker - err: exec: "docker-credential-desktop": executable file not found in $PATH, out: ``<p><b>Introduction:</b></p><p>Docker has revolutionized the way we package, distribute, and deploy applications. However, like any other technology, it is not immune to errors and issues. One such error that I encountered recently while working with Docker on my Mac was the "error getting credentials - executable file not found" error. In this blog post, I will share my experience with this error and provide a solution that worked for me.</p><p><b>The Error:</b></p><p>When attempting to build a Docker image or perform a Docker login, I encountered the following error message:</p><p><span style="color: #2b00fe; font-family: courier;"><br /></span></p><p><span style="color: #2b00fe; font-family: courier;">openjdk:17: error getting credentials - err: exec: "docker-credential-desktop": executable file not found in $PATH, out: ``</span></p><p><span style="color: #2b00fe; font-family: courier;"><br /></span></p><p><span style="color: #2b00fe; font-family: courier;">Error saving credentials: error storing credentials - err: exec: "docker-credential-desktop": executable file not found in $PATH, out: ``</span><span style="color: #2b00fe; font-family: courier;"> </span></p><p><span style="color: #2b00fe; font-family: courier;"><br /></span></p><p><b>Diagnosis:</b></p><p>The error message suggests that the Docker daemon was unable to locate the "docker-credential-desktop" executable file in the $PATH environment variable. This executable is responsible for retrieving Docker credentials and authentication.</p><p><b><span></span></b></p><a name='more'></a><b>Solution:</b><p></p><p>After researching the issue, I discovered that the problem was specific to Docker on macOS. The Docker Desktop application on macOS uses a credential helper called "docker-credential-desktop" to handle authentication with Docker registries. To resolve the error, I followed these steps:</p><p>1. Open Finder and navigate to the following path: `/Users/[USERNAME]/.docker/`.</p><p>2. Look for the file named `config.json` in the `.docker` directory.</p><p>3. Delete the `config.json` file.</p><p>4. Retry the Docker command that was previously failing (e.g., `docker build`, `docker login`, etc.).</p><p><b>Explanation:</b></p><p>By deleting the `config.json` file, we essentially reset the Docker configuration and remove any potential misconfigurations or conflicts. Docker Desktop will recreate the necessary files and configurations automatically when you run Docker commands again.</p><p><b>Conclusion:</b></p><p>If you encounter the "error getting credentials - executable file not found" error while working with Docker on your macOS machine, deleting the `config.json` file located at `/Users/[USERNAME]/.docker/` can help resolve the issue. Remember to retry the Docker command after deleting the file to confirm that the error is resolved.</p><p>Docker is a powerful tool, but occasional errors and challenges are inevitable. Hopefully, this blog post has provided you with a solution to the specific error discussed here, allowing you to continue working with Docker seamlessly. Happy Dockerizing!</p>Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.com0tag:blogger.com,1999:blog-8882377031456587900.post-25753335366983576132023-04-19T20:01:00.004+05:302023-04-19T20:01:26.449+05:30React simple rich text editor using draft-js<p>This React Simple Rich Text Editor is created using the Draft.js library and includes button controls made with react-icons. It allows users to toggle between different inline styles like block, italic, and underline, as well as block types such as header-one, unordered-list-item, and ordered-list-item. The controls buttons are selected on text click, making it easy for users to format their text. </p><p>The component requires two packages to be installed</p><p><span style="font-family: courier;">yarn add draft-js react-icons</span></p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjYPT98udaYddrUHtO2DCwVxJ2eQOIZD-YWh2dQAURslgpcJaZa-wj81jnJFxXviXuBQXS0z7StdSAk9C2VYcHlAYdHKweRWvyydzx4AFo5flqpMCUodC-MBb0pvktoNCKdLh5CAPzJ-j5l9bE0bQpqiMVZu9lBupoe1qpjrLzkM0wPiXrVC_grmeMKLA" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="380" data-original-width="1164" height="209" src="https://blogger.googleusercontent.com/img/a/AVvXsEjYPT98udaYddrUHtO2DCwVxJ2eQOIZD-YWh2dQAURslgpcJaZa-wj81jnJFxXviXuBQXS0z7StdSAk9C2VYcHlAYdHKweRWvyydzx4AFo5flqpMCUodC-MBb0pvktoNCKdLh5CAPzJ-j5l9bE0bQpqiMVZu9lBupoe1qpjrLzkM0wPiXrVC_grmeMKLA=w640-h209" width="640" /></a></div><span><a name='more'></a></span><div class="separator" style="clear: both; text-align: left;"><script src="https://gist.github.com/madan712/75739927dfd5a7c3586757f692a41f1d.js"></script></div>Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.com0tag:blogger.com,1999:blog-8882377031456587900.post-75662749792266778142023-02-23T19:09:00.004+05:302023-02-23T19:16:10.160+05:30Caused by: java.lang.UnsupportedOperationException: PermittedSubclasses requires ASM9<div style="text-align: left;"><span style="background-color: white; color: #374151; white-space: pre-wrap;"><span style="font-family: inherit;">After attempting to upgrade Spring Boot from version 2.7.3 to version 3.0.2, I encountered this error. I spent a few hours searching on Google to try to figure out the cause of the error. Eventually, I realized that the error was related to the version of Gradle that I was using. At the time, I had been using Gradle version 7.3.3. However, once I updated to Gradle version 8.0.1, the error was successfully resolved.</span></span></div><p></p><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjNzIDB8sNVCaErrtDs11O7BUKHmoT-eNG-6Q5pj3W0jlpyzTySqP_Fkm5_R_svAqgVGT0X5Gmip6QRzxdCsxjbWXHbFuuK_0wtla6XWUGpnyaOZO1gaAeWsopHQA-tfCHivYO4MAOZsbfePVGfsgBssyOXInwIj-izZIbB8xJhxmXOkmPCXDLRNH9byA" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="709" data-original-width="977" height="290" src="https://blogger.googleusercontent.com/img/a/AVvXsEjNzIDB8sNVCaErrtDs11O7BUKHmoT-eNG-6Q5pj3W0jlpyzTySqP_Fkm5_R_svAqgVGT0X5Gmip6QRzxdCsxjbWXHbFuuK_0wtla6XWUGpnyaOZO1gaAeWsopHQA-tfCHivYO4MAOZsbfePVGfsgBssyOXInwIj-izZIbB8xJhxmXOkmPCXDLRNH9byA=w400-h290" width="400" /></a></div><br /><div style="text-align: left;">I also updated distributionUrl in gradle-wrapper.properties as shown below</div><div style="text-align: left;"><pre style="background-color: #2b2b2b; color: #a9b7c6; font-family: "JetBrains Mono", monospace; font-size: 9.8pt;"><span style="color: #cc7832;">distributionUrl</span><span style="color: grey;">=</span><span style="color: #6a8759;">https</span>\:<span style="color: #6a8759;">//services.gradle.org/distributions/gradle-8.0.1-bin.zip</span></pre></div></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: left;">Note - After above changes i removed .idea folder and restarted my intellij</div><p></p>Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.com0tag:blogger.com,1999:blog-8882377031456587900.post-38938427257431371322023-02-03T06:19:00.006+05:302023-02-03T06:21:28.442+05:30Java thread synchronization<p>Do you know what is thread synchronization Java? Have you ever thought about how to use synchronized in Java? let us gain some knowledge about thread synchronization Java & try to find out the answer to what is thread synchronization in Java.</p><p>But before we start writing about thread synchronization Java & try to find out how to use synchronized in Java. Let us first try to understand the policy of synchronization from one daily life example.</p><p>Assume one daily life scenario.</p><p>Suppose in your school, there is one toilet for the gents. Now, at the same time, you & your friend need to access the toilet. In both cases, the matter is an urgent one. So, you are not ready to let him go. Neither of your friends is ready to let you go. As a result, there is a mess in front of the toilet.</p><p>So, what you will do in such a case? Or what your friend will do at that time?</p><p>So, you called the teacher to solve the situation that arise there. Your teacher will draw a solution & allow anyone to go to the toilet first. And as a teacher is a respected person both of you are ready with the solution. In this case, the teacher helps to solve the conflict.</p><p>The same thing happens in thread synchronization Java. When two different parts of the program try to access the same resources then this trouble arises. We will try to know more about it when we discuss what is thread synchronization in Java.</p><p><b>What Is Thread Synchronization in Java:</b></p><p>Java is an important programming language. Java is used in the corporate world as it helps to solve real-life problems very easily. Java is used for game development purposes. These along with an operation some more processes are going on. For implementing that situation, Java programming language used the thread concept. Thread is a special concept of the Java programming language. It helps to execute more operations a t same time.</p><p>Synchronization means collaborating two or more processes at the same time. The thread synchronization Java is quite like this. Now, sometimes when two or more processes are using the same resource then there will be a problem. This problem arises when we use thread in Java. Two or more parts of the code want to use the same resources. Then there is a mess at that point.</p><p>The main goal of thread synchronization in Java is to remove the problems related to resources. If two or more parts want to use the same resource, then one by one they will execute that. This means one part will use that resource, then it will be removed. After that, another part is going to use the resource & will be removed. This is a very problematic situation. To come out of this situation, we used the 'synchronized' keyword.</p><p>Synchronize is like the teacher at your school. It helps to remove the conflicts between two or more parts for using the same recourses. We will find out more about this when we implement the thread synchronized Java. Similarly, when you are stuck at Java coding you can use <a href="https://codingzap.com/do-my-java-homework/" target="_blank">Java Assignment Help</a> Services from codingzap.</p><p><b>Why Should We Use Thread Synchronization Java:</b></p><p>Now, after knowing about thread synchronization Java, we need to know why we should use it. This is a very important topic. Often, we find out that, the threads that are implemented in the program are not executing the same we want. In those cases, we need to use this method. As there is a problem related to the synchronization.</p><p>If we don't use synchronization, then there will be an issue related to the memory space. Also, the flow of the output of the program will not be similar as desired. There will be a thread interface problem if we don't use synchronization at the correct time. When we implement thread synchronization Java, it will be easy to understand.</p><p><b><span></span></b></p><a name='more'></a><b>How To Use Synchronized in Java:</b><p></p><p>Now, it is time to implement Thread Synchronization Java. Here, first, we need to declare one function that is synchronized. This means, there will be no issue with the synchronization. We have written a for loop there. This will be executed by the threads. Now, we have declared two threads. Using the concept of the thread, we are accessing the synchronized function. In one thread, we are trying to provide the value of 2. And in another thread, we are trying to provide the value of 10.</p><p>Now, in the main driver function, we will create an object of the synchronized class. Now using that object, we are trying to make a new object of the thread class. Hence, we have implemented two objects for the threads. Now using the start() function of the thread, we will execute that.</p><p><b>Example:</b></p><p><script src="https://gist.github.com/madan712/9f0b4b5d66eb2cddfd3141b6b478e7a9.js"></script></p><p>Let us try to find out the output of the above code. This will help to understand thread synchronization Java.</p><p><b>Output:</b></p><p><b></b></p><div class="separator" style="clear: both; text-align: center;"><b><a href="https://blogger.googleusercontent.com/img/a/AVvXsEiZyfXRk3_JsOrd93Einy-LmuGHbICrIaXIY2K3gD29O-7NvsXeF7fWCpTwaBqwCE7RqHZAc0csDtxBezbHvD56-MvVF3tyyST99EWQj3IFYIDO3JkPXxus4OYSRMhWiQwt2i3kdTXmAMEpTOdCdW7xoHAs6qxnqkdfLH0nI-9W7OTvyZy2R9gWuuNIIw" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="410" data-original-width="890" height="294" src="https://blogger.googleusercontent.com/img/a/AVvXsEiZyfXRk3_JsOrd93Einy-LmuGHbICrIaXIY2K3gD29O-7NvsXeF7fWCpTwaBqwCE7RqHZAc0csDtxBezbHvD56-MvVF3tyyST99EWQj3IFYIDO3JkPXxus4OYSRMhWiQwt2i3kdTXmAMEpTOdCdW7xoHAs6qxnqkdfLH0nI-9W7OTvyZy2R9gWuuNIIw=w640-h294" width="640" /></a></b></div><b><br /></b><b>Conclusion:</b><p></p><p>As we saw, thread synchronization Java is a very important topic.</p><p>We need to remember what thread synchronization in Java is. Also, we need to understand how to use synchronized in Java.</p><p></p><p>It is advisable to clear the basis of the Java Programming Language. Also, we need to clear the multithreading in Java programming language. Then the topic is understandable.</p><div><b>Sponsor by:</b> <a href="https://codingzap.com/" target="_blank">https://codingzap.com/</a></div>Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.com0tag:blogger.com,1999:blog-8882377031456587900.post-78928489204050985312022-07-09T18:51:00.002+05:302022-07-09T18:51:15.417+05:30Java - Progress bar in console<p> </p><p>
<script src="https://gist.github.com/madan712/dc1c432362dc466cd80bf02c76a40c88.js"></script>
<br /></p><p>Output -</p><p><br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPMaEy09CiYvQBsY7HlQS_oxG9ijqFjKNQADFLdBsMKrTitAp0V6FtiNMH2Bnqpo5eWp8oWyMS7aSdda--FMJsR5SqSIsiO9fXwbe-WZDud-GogrieiBk0aX4A_zPth4PhQxOPEOZQg4W16Pf2pxUXW78SZBCbKK1zQS7u6GdkEXS_kUFQ8Ssk8SUNDw/s600/java%20console%20progress%20bar.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="109" data-original-width="600" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPMaEy09CiYvQBsY7HlQS_oxG9ijqFjKNQADFLdBsMKrTitAp0V6FtiNMH2Bnqpo5eWp8oWyMS7aSdda--FMJsR5SqSIsiO9fXwbe-WZDud-GogrieiBk0aX4A_zPth4PhQxOPEOZQg4W16Pf2pxUXW78SZBCbKK1zQS7u6GdkEXS_kUFQ8Ssk8SUNDw/s16000/java%20console%20progress%20bar.gif" /></a></div><br /><p></p>Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.com0tag:blogger.com,1999:blog-8882377031456587900.post-58267264492070558402022-04-05T22:06:00.006+05:302022-04-06T00:05:44.060+05:30Docker - Springboot and mysql image example<p>A simple docker example using springboot and database as mysql/mariadb</p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh17ws6bmI1xbY0Qu4IAJgVTpQDxLLs2kaTC4JGxhpsk8Y3JbNYbFoq6egyCKpg_8claNnhtkfqAVCLMTNUYZ9Szo6u28JTkGhG1up9D4qSDqw7ChwEqE4tT6yQc9bbOi63MsdXn0JHYdR0mYg-AnmEraVf0868d-e1HKHr3CSV1CmBn3e1BYyhHNIO2A/s1500/docker%20image.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1278" data-original-width="1500" height="341" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh17ws6bmI1xbY0Qu4IAJgVTpQDxLLs2kaTC4JGxhpsk8Y3JbNYbFoq6egyCKpg_8claNnhtkfqAVCLMTNUYZ9Szo6u28JTkGhG1up9D4qSDqw7ChwEqE4tT6yQc9bbOi63MsdXn0JHYdR0mYg-AnmEraVf0868d-e1HKHr3CSV1CmBn3e1BYyhHNIO2A/w400-h341/docker%20image.png" width="400" /></a></div><p><b>Create springboot image</b></p>Get the completed springboot source code on github for <a href="https://github.com/madan712/hello-docker" target="_blank">hello-docker</a> image<div><br /></div><div>1. Create docker image</div><div><br /></div><div><span> </span><span style="font-size: 13.6px;"><span style="color: #2b00fe; font-family: courier;">cd hello-docker</span></span></div><div><span style="font-size: 13.6px;"><span style="color: #2b00fe; font-family: courier;"> docker build --tag hello-docker .</span></span></div><div><br /></div><div>2. Tag the image</div><div><span> </span><br /></div><div><span><span> </span></span><span style="font-size: 13.6px;"><span style="color: #2b00fe; font-family: courier;">docker tag hello-docker madan712/hello-docker:v1.0 </span></span></div><div><br /></div><div><p></p><p><b>Run individual container(s) in a docker network</b></p><p>Since springboot application need to connect to database, both the containers should be present in same docker network.</p><p>1. Created docker network</p><p><span> </span><span style="color: #2b00fe; font-family: courier;">docker network create mynetwork</span></p><p>2.<span> Run database image in docker network</span></p><p><span><span> </span></span><span style="color: #2b00fe; font-family: courier;">docker run -d --name mysqldb -p 3306:3306 -e MYSQL_ROOT_PASSWORD=pass123 -e MYSQL_DATABASE=mydb --network mynetwork mysql</span></p><p>3. Run springboot application</p><p><span> </span><span style="color: #2b00fe; font-family: courier;">docker run -d --name hello-docker -p 8080:8080 -e SPRING_DATASOURCE_URL="jdbc:mysql://mysqldb:3306/mydb?useSSL=false" -e SPRING_DATASOURCE_USERNAME=root -e SPRING_DATASOURCE_PASSWORD=pass123 --network mynetwork madan712/hello-docker:v1.0</span></p><p><b>Run multi-container docker application using docker compose</b></p><p>docker-compose.yaml</p><p>
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fhello-docker%2Fblob%2Fmaster%2Fdocker-compose.yaml&style=github&showBorder=on&showLineNumbers=on&showFileMeta=on&showCopy=on"></script>
<br /></p><p>Compose command</p><p><span style="color: #2b00fe; font-family: courier;">docker-compose up -d</span></p><p>Please find complete github code - <a href="https://github.com/madan712/hello-docker" target="_blank">hello-docker</a></p><p></p></div>Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.com0tag:blogger.com,1999:blog-8882377031456587900.post-82854915016040715072022-02-09T21:33:00.005+05:302022-02-09T21:33:56.238+05:30React native swipe gestures handler example<div class="separator" style="clear: both;">This is a simple <a href="https://en.wikipedia.org/wiki/2048_(video_game)" target="_blank">2048 game</a> demonstrates how to use gestures handler in react native</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both; text-align: center;"><img alt="" border="0" data-original-height="426" data-original-width="240" height="400" src="https://blogger.googleusercontent.com/img/a/AVvXsEi91oDRSBHokouFLlPC2But3sdSmpZ9w1Z7s0gzeKqf7npUkzlkGLn-IEYZ3fquSUGy354X56Je-zcIxtFn-8HDzt6LYp-1H4oMwfiRHndZK7_TWRLXJeEH5IWPkCk0VbmVZqqFys0gQnIEePU3_4FP9uiXJPiunSNS3Lh03Biup8t2myu2a5rXMNOf3g=s400" /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: left;">It is hosted in play store, feel free to install and see the demo</div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://play.google.com/store/apps/details?id=com.javaxp.adfree2048" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img border="0" data-original-height="250" data-original-width="646" height="78" src="https://blogger.googleusercontent.com/img/a/AVvXsEhy8H9oW6F0ptTqoGFhbt2BLqvsIED5gqAeB0P4_m-kWGq1HLzhyjwckSRq_IlXx4wMJsZbASdpNAWP_mmDkazNB6TUXcBt8WIREpy1hhqcnQqCXkFsizQIr71CcC2XCp5ZZbKBjeJ7Do6a_-gmuB_aPAfbs65WMTGe6Tv_ASCdn-VgG33b48OtuLvk_A=w200-h78" width="200" /></a></div><div class="separator" style="clear: both; text-align: left;">It is using npm <a href="https://www.npmjs.com/package/react-native-swipe-gestures" target="_blank">react-native-swipe-gestures</a> package to detect swipe. this component can be used handling swipe gestures in up, down, left and right direction.</div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">Here is the complete github code link</div><div class="separator" style="clear: both; text-align: left;"><br /></div><a href="https://github.com/madan712/2048" target="_blank">https://github.com/madan712/2048</a><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: left;">Code snippet</div>
<script src="https://gist.github.com/madan712/1fb83102c9a15f62057f4567df488b7e.js"></script>
<div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;"><br /></div>Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.com0tag:blogger.com,1999:blog-8882377031456587900.post-30548421624190991242022-01-30T02:12:00.004+05:302022-02-03T02:29:06.963+05:30React native draggable and swipeable list<p>This is a simple todo app demonstrates how to create a draggable and swipeable list in react native</p><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEh312B6dtmzdtg5KfuTRS9nR_3kqACU5kwKBGHUdNs1sVP4BSro16176Nevi34yP_r9teWlaU3c5CUBHjM8S5YwGrrKRIbMubh8bI7Rl6s_80N1-j-Ox1hVcMYnnNh0VyvyjKjpFwAFP4E54H2gGS1PrOL2aeK2VtZt-HkkIq2dOBdGVWhTNY9G7fpxTA=s426" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="426" data-original-width="240" height="320" src="https://blogger.googleusercontent.com/img/a/AVvXsEh312B6dtmzdtg5KfuTRS9nR_3kqACU5kwKBGHUdNs1sVP4BSro16176Nevi34yP_r9teWlaU3c5CUBHjM8S5YwGrrKRIbMubh8bI7Rl6s_80N1-j-Ox1hVcMYnnNh0VyvyjKjpFwAFP4E54H2gGS1PrOL2aeK2VtZt-HkkIq2dOBdGVWhTNY9G7fpxTA=s320" width="180" /></a></div><div class="separator" style="clear: both; text-align: left;">An open source todo app hosted in google play store. Feel free to download and play with it.</div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://play.google.com/store/apps/details?id=com.javaxp.todo" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img border="0" data-original-height="250" data-original-width="646" height="78" src="https://blogger.googleusercontent.com/img/a/AVvXsEiDP8ZQjTQpfI7iT2GihJ9z8Y5JTsEs19skkV_lQEbzXSC3L0qdE-YBVnBod5cBy1_FQFj7Azz1MBcmjt6X69_r1FpZdfQe6B45l68WSzXyBwq52G2xs6DkDYXuoU_NSb9g2OE42SXLI3NNd-7GHXZSTdusVSQ64xPrMF2YG9nhN0UiO8f-HRzX9Kh2Kw=w200-h78" width="200" /></a></div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">It is using npm <a href="https://www.npmjs.com/package/react-native-draggable-flatlist" target="_blank">react-native-draggable-flatlist</a> and <a href="https://www.npmjs.com/package/react-native-swipeable-item" target="_blank">react-native-swipeable-item</a> package</div><p></p><p>Here is the complete github code link</p><p><span face="Roboto, Arial, sans-serif" style="background-color: white; color: #333333; font-size: 14px;"><a target="_blank" href="https://github.com/madan712/simple-todo-app">https://github.com/madan712/simple-todo-app</a></span></p><p>Code snippet</p><p>
<script src="https://gist.github.com/madan712/4059e27253210ae8d3a059d6addadc8d.js"></script>
</p><p><br /></p>Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.com0tag:blogger.com,1999:blog-8882377031456587900.post-61382599600706240542021-12-24T00:22:00.002+05:302021-12-24T00:23:25.315+05:30Why Higher Learning Institution Prefer to Teach Java Than Python<p><span style="font-family: times;"></span></p><div class="separator" style="clear: both; text-align: center;"><span style="font-family: times;"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEipZyN_5kJir5jPLG0alK_R-HkVo8rdk80pMeJdW00mPddZBvByG-74sGk46IKokP8IKsXxOdSKf8uK6hZnLUxpzTZYFO7fGY5TIvXw4om7CXda5jhHUaPap9frgm6j5UCCzpSunhTTAmP4SaHNfHudmiLG5wwJdzamwFYpaqrdw8rAsJq3Gtvu_hiVqQ=s1275" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="590" data-original-width="1275" height="296" src="https://blogger.googleusercontent.com/img/a/AVvXsEipZyN_5kJir5jPLG0alK_R-HkVo8rdk80pMeJdW00mPddZBvByG-74sGk46IKokP8IKsXxOdSKf8uK6hZnLUxpzTZYFO7fGY5TIvXw4om7CXda5jhHUaPap9frgm6j5UCCzpSunhTTAmP4SaHNfHudmiLG5wwJdzamwFYpaqrdw8rAsJq3Gtvu_hiVqQ=w640-h296" width="640" /></a></span></div><span><br /><span style="font-family: inherit;">Python and Java are two of the most widely used programming
languages. Due to its computability, Java is typically more efficient than
Python. Python's syntax is simpler and more succinct than Java's since it is
interpreted. Using less code than Java, it can do the same thing. However,
large number of students, programmers, professors in most reputable
universities spend much time training java.</span></span><p></p><p class="MsoNormal"><span style="font-family: inherit;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: inherit;">Much of Java's efficiency is due to its Just-In-Time (JIT)
compiler and its ability to handle concurrency. The JIT compiler is a component
of the Java Runtime Environment. Compiling byte-codes into native machine code
"just in time" to execute Java applications enhances their
performance. The Java Virtual Machine (JVM) directly calls the built code.
Compiling does not use a lot of resources since the code does not have to be
parsed. This could theoretically make a Java program as quick as a native
application.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: inherit;">Another reason making java most popular among students
looking for <a href="https://thepandapapers.com/articles/programming-assignment-help" target="_blank">programmingassignment help</a> online is due to its user friendliness especially when
doing the coding part. Bugs, errors, and all other issues affecting the code
are clearly indicated in the runtime, not like in python. Programmer errors in
Python are not discovered until the code is executed. This might lead to
operational failures and a longer turnaround time, which is not ideal. Object
mutation is impossible in Java, although it is feasible in Python. This leads
to the creation of secure software. Fixing bugs is an hectic task, that may
make programmers and students look for programming help online and <a href="https://thepandapapers.com/articles/programming-assignment-help" target="_blank">bestwebsites offering programming assignment help.</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: inherit;">Python may be more flexible and user-friendly than Java, but
Java is still the best "formal" language out there. It is statically
typed, has all of the OO implementation bells and whistles, and tends to
function in a manner that rewards proper program design. That makes it a great
choice for teaching at the college and university levels. Computer Science
students find it difficult to spend much time in the laptop while avoiding some
best moments as a college student. However, with good <a href="https://thepandapapers.com/articles/programming-assignment-help" target="_blank">programmingassignment service</a>, such as ThePandaPapers, students may now get
professional help with all sort of programming tasks, may it be java, sql, or
python. They have programming assignment experts</span><o:p></o:p></p>Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.com0tag:blogger.com,1999:blog-8882377031456587900.post-43581347217332930462021-09-26T00:00:00.007+05:302021-09-26T00:07:29.870+05:30Java JSON Web Tokens example<p> What is JSON Web Token?</p><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: left;">JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. For more details, <a href="https://jwt.io/introduction" target="_blank">click here</a>.</div></div><p></p><div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-Ve859B1yPCc/YU9rU5Vaf3I/AAAAAAAAFtU/4ZS5pQ1_cD4sQDwojZnyFp3uBB7PweEyACLcBGAsYHQ/s1013/jwt%2Bjava.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="543" data-original-width="1013" height="344" src="https://1.bp.blogspot.com/-Ve859B1yPCc/YU9rU5Vaf3I/AAAAAAAAFtU/4ZS5pQ1_cD4sQDwojZnyFp3uBB7PweEyACLcBGAsYHQ/w640-h344/jwt%2Bjava.jpg" width="640" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><p>In this example, User object is encrypted to jwt also validating it and decrypting token to user object again. For complete github source code, <a href="https://github.com/madan712/test-jwt" target="_blank">click here</a>. </p><p>JwtTokenService.java</p>
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Ftest-jwt%2Fblob%2Fmain%2Fsrc%2Fmain%2Fjava%2Fcom%2Fjavaxp%2Ftestjwt%2FJwtTokenService.java&style=github&showBorder=on&showLineNumbers=on&showFileMeta=on&showCopy=on"></script>Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.com0tag:blogger.com,1999:blog-8882377031456587900.post-61230906373476502472020-06-13T17:11:00.000+05:302020-06-13T17:14:29.800+05:30Client side load balancing using Eureka and Ribbon<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: left;">
Traditional server side load balancer has some drawbacks. It requires an additional hop from client to load balancer and then load balancer to service. Also there is a burden to run and manage load balancer itself. Client side load balancer is the solution to overcome these problems. In this architecture there is an addition inbuilt load balancer component that resides inside client.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
In this example we will see how client side load balancer works with eureka discovery server.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-XDQLXFjRejA/XuENQYqn5LI/AAAAAAAAFZY/vX8_LudpPHgWdhTt0BZDVMkbupqaTunTgCLcBGAsYHQ/s1600/Ribbon%2Brequest%2Bflow.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="364" data-original-width="676" height="344" src="https://1.bp.blogspot.com/-XDQLXFjRejA/XuENQYqn5LI/AAAAAAAAFZY/vX8_LudpPHgWdhTt0BZDVMkbupqaTunTgCLcBGAsYHQ/s640/Ribbon%2Brequest%2Bflow.jpg" width="640" /></a></div>
<br />
<span style="background-color: white; color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif; font-size: 13.2px;">1. W</span><span style="background-color: white; color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif; font-size: 13.2px;">hen service (discovery client) boots up it registers itself with discovery server. Multiple instances register itself with discovery server. Here </span><span style="background-color: white; color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif; font-size: 13.2px;"><span style="font-size: 13.2px;"><b><span style="font-family: "courier new" , "courier" , monospace;">spring.application.name</span></b><span style="font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"> is use to identify a particular service</span></span></span><br />
<span style="background-color: white; color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif; font-size: 13.2px;"><span style="font-size: 13.2px;"><span style="font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><br /></span></span></span>
<span style="background-color: white;"><span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;">2. Client application will also resister itself to discovery client to find instance for load banacer</span></span></span><br />
<span style="background-color: white;"><span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;"><br /></span></span></span>
<span style="background-color: white;"><span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;">3. Now load balancer within client can find the service with the help of service name</span></span></span><br />
<span style="background-color: white;"><span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;"><br /></span></span></span>
<span style="background-color: white;"><span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;">Please find complete codes from github repository -</span></span></span><br />
<span style="background-color: white;"><span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;"><br /></span></span></span>
<br />
<div class="separator" style="background-color: white; clear: both; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;">
Discovery server code -</div>
<div class="separator" style="background-color: white; clear: both; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;">
<a href="https://github.com/madan712/discovery-server" style="color: #888888; text-decoration-line: none;" target="_blank">https://github.com/madan712/discovery-server</a></div>
<div class="separator" style="background-color: white; clear: both; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;">
<br /></div>
<div class="separator" style="background-color: white; clear: both; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;">
Ribbon service code -</div>
<div class="separator" style="background-color: white; clear: both; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;">
<a href="https://github.com/madan712/ribbon-service" target="_blank">https://github.com/madan712/ribbon-service</a></div>
<div class="separator" style="background-color: white; clear: both; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;">
<br /></div>
<div class="separator" style="background-color: white; clear: both; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;">
<span style="font-size: 13.2px;">Ribbon client code -</span></div>
<div class="separator" style="background-color: white; clear: both; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;">
<a href="https://github.com/madan712/ribbon-client" target="_blank">https://github.com/madan712/ribbon-client</a></div>
<div class="separator" style="background-color: white; clear: both; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;">
<br /></div>
<div class="separator" style="background-color: white; clear: both; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;">
</div>
<a name='more'></a>How to run this example -<br />
<div class="separator" style="background-color: white; clear: both; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;">
<br /></div>
<div class="separator" style="background-color: white; clear: both; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;">
<b>Step 1</b> - Start eureka discovery server, which will run on port 8761</div>
<div class="separator" style="background-color: white; clear: both; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;">
<a href="http://localhost:8761/" target="_blank">http://localhost:8761/</a></div>
<div class="separator" style="background-color: white; clear: both; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;">
<br /></div>
<div class="separator" style="background-color: white; clear: both; font-size: 13.2px;">
<b style="color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;">Step 2</b><span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"> - Start 2 instances of ribbon service on port 4444, 5555. Y</span><span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif; font-size: 13.2px;">ou can do that by passing </span><span style="font-size: 13.2px;"><span style="color: blue; font-family: "courier new" , "courier" , monospace;">server.port</span></span><span style="color: #222222; font-family: "courier new" , "courier" , monospace; font-size: 13.2px;"> </span><span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif; font-size: 13.2px;">argument to start the services as shown below</span></div>
<span style="background-color: white; font-family: "courier new" , "courier" , monospace; font-size: 13.2px;"></span><br />
<div style="color: #222222;">
<span style="background-color: white; font-family: "courier new" , "courier" , monospace; font-size: 13.2px;"><span style="background-color: white; color: #222222; font-family: "courier new" , "courier" , monospace; font-size: 13.2px;"><br /></span></span></div>
<span style="background-color: white; font-family: "courier new" , "courier" , monospace; font-size: 13.2px;">
<span style="color: blue;">--server.port=2222</span></span><br />
<div>
<span style="background-color: white; color: #222222; font-family: "courier new" , "courier" , monospace; font-size: 13.2px;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-KN-ie96lxdc/XuS3RbdgjjI/AAAAAAAAFZ0/1Wp4We5krGAI8OFcVklppEMmFAcHKQWJACLcBGAsYHQ/s1600/Eclipse%2Bpass%2Bserver%2Bport%2Bas%2Bprogram%2Bargument.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="629" data-original-width="772" height="521" src="https://1.bp.blogspot.com/-KN-ie96lxdc/XuS3RbdgjjI/AAAAAAAAFZ0/1Wp4We5krGAI8OFcVklppEMmFAcHKQWJACLcBGAsYHQ/s640/Eclipse%2Bpass%2Bserver%2Bport%2Bas%2Bprogram%2Bargument.jpg" width="640" /></a></div>
<div>
<span style="background-color: white; color: #222222; font-family: "courier new" , "courier" , monospace; font-size: 13.2px;"><br /></span></div>
<div>
<span style="background-color: white; color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif; font-size: 13.2px;">Verify 2 service are running in eureka</span></div>
<div>
<a href="http://localhost:8761/">http://localhost:8761/</a></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-179RY_zq-Ow/XuS6PocDtZI/AAAAAAAAFaM/03VUN1dYpcIWGBmTgqcDg3COGjzDiIhRwCLcBGAsYHQ/s1600/Eureka%2BRibbon%2Bservice.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="683" data-original-width="1351" height="322" src="https://1.bp.blogspot.com/-179RY_zq-Ow/XuS6PocDtZI/AAAAAAAAFaM/03VUN1dYpcIWGBmTgqcDg3COGjzDiIhRwCLcBGAsYHQ/s640/Eureka%2BRibbon%2Bservice.jpg" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<b>Step 3</b> - Run Ribbon client which will run on default 8080 port</div>
<div>
<br /></div>
<div>
RestTemplate bean is created using @LoadBalanced annotation </div>
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fribbon-client%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fjava%2Fcom%2Fjavaxp%2Fribbonclient%2FRibbonClientApplication.java&style=github&showBorder=on&showLineNumbers=on"></script>
<div>
<br /></div>
<div>
Ribbon service is discovered using service name</div>
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fribbon-client%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fjava%2Fcom%2Fjavaxp%2Fribbonclient%2FController.java&style=github&showBorder=on&showLineNumbers=on"></script>
<div>
<br />
<b>Output -</b><br />
<b><br /></b>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-e4JwGdRUpSg/XuS74NlF5zI/AAAAAAAAFaY/MgxqCNwM5T8rK4JdM9IG8sdO2eeIoMBAQCLcBGAsYHQ/s1600/Ribbon%2Boutput.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="312" data-original-width="675" height="295" src="https://1.bp.blogspot.com/-e4JwGdRUpSg/XuS74NlF5zI/AAAAAAAAFaY/MgxqCNwM5T8rK4JdM9IG8sdO2eeIoMBAQCLcBGAsYHQ/s640/Ribbon%2Boutput.jpg" width="640" /></a></div>
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;"><br /></span>
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;">On subsequent request u can see response from different instance</span></div>
</div>
Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.comtag:blogger.com,1999:blog-8882377031456587900.post-73790924680918852182020-06-07T01:22:00.002+05:302020-06-07T01:24:37.692+05:30Server side load balancing using Eureka and Zuul<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: left;">
Routing is an important part of a microservice architecture. In real time cloud application, service instances are added/removed dynamically based on requirement and availability in such scenario its very important to manage traffic load. In the following example you will see how to use Zuul API Gateway to enable sever side load balancing of your RESTful Web Services.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-0IGko32oF6I/XtviZ9p5TrI/AAAAAAAAFXk/g4A8jpSIpf4UeYXvveH1vqL7pryBP8uPwCLcBGAsYHQ/s1600/Eureka%2Bzuul%2Bflow.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="444" data-original-width="814" height="348" src="https://1.bp.blogspot.com/-0IGko32oF6I/XtviZ9p5TrI/AAAAAAAAFXk/g4A8jpSIpf4UeYXvveH1vqL7pryBP8uPwCLcBGAsYHQ/s640/Eureka%2Bzuul%2Bflow.jpg" width="640" /></a></div>
<div class="separator" style="clear: both;">
Request flow -</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
1. W<span style="background-color: white; color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif; font-size: 13.2px;">hen service boots up it registers itself with discovery server. Multiple instances register itself with discovery server. Here </span><span style="color: #222222;"><span style="font-size: 13.2px;"><b><span style="font-family: "courier new" , "courier" , monospace;">spring.application.name</span></b><span style="font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"> is use to identify a particular service</span></span></span></div>
<div class="separator" style="clear: both;">
<span style="background-color: white; color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif; font-size: 13.2px;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="background-color: white; color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif; font-size: 13.2px;">2. Zuul gateway also registers itself with discovery server. Remember Zuul gateway is also a discovery client</span></div>
<div class="separator" style="clear: both;">
<span style="background-color: white; color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif; font-size: 13.2px;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="background-color: white; color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif; font-size: 13.2px;">3. When client sends request to zuul gateway for a particular service, Zuul gateway queries discovery server to fetch available healthy instance of the service and then accordingly send request to that service.</span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
Please check previous example on <a href="https://www.javaxp.com/2020/06/spring-cloud-service-discovery-example.html" target="_blank">Discovery Server</a>.</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
Discovery code -</div>
<div class="separator" style="clear: both;">
<a href="https://github.com/madan712/discovery-server" target="_blank">https://github.com/madan712/discovery-server</a></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<b></b></div>
<a name='more'></a><b>Zuul Server</b><br />
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
pom.xml</div>
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fzuul-server%2Fblob%2Fmaster%2Fpom.xml&style=github&showBorder=on&showLineNumbers=on"></script>
<br />
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
application.properties</div>
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fzuul-server%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fresources%2Fapplication.properties&style=github&showBorder=on&showLineNumbers=on"></script>
<br />
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
ZuulServerApplication.java</div>
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fzuul-server%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fjava%2Fcom%2Fjavaxp%2Fzuulserver%2FZuulServerApplication.java&style=github&showBorder=on&showLineNumbers=on"></script>
<br />
<div class="separator" style="clear: both;">
<b><br /></b></div>
<div class="separator" style="clear: both;">
<b>Zuul Service</b></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
pom.xml</div>
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fzuul-service%2Fblob%2Fmaster%2Fpom.xml&style=github&showBorder=on&showLineNumbers=on"></script>
<br />
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
application.properties</div>
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fzuul-service%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fresources%2Fapplication.properties&style=github&showBorder=on&showLineNumbers=on"></script>
<br />
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
ServiceApplication.java</div>
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fzuul-service%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fjava%2Fcom%2Fjavaxp%2Fzuulservice%2FServiceApplication.java&style=github&showBorder=on&showLineNumbers=on"></script>
<br />
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
Controller.java</div>
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fzuul-service%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fjava%2Fcom%2Fjavaxp%2Fzuulservice%2FController.java&style=github&showBorder=on&showLineNumbers=on"></script>
<br />
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
Here is complete source code in Github</div>
<br />
<a href="https://github.com/madan712/zuul-server" target="_blank">https://github.com/madan712/zuul-server</a><br />
<br />
<a href="https://github.com/madan712/zuul-service" target="_blank">https://github.com/madan712/zuul-service</a><br />
<br />
<b>Output -</b><br />
1. Our discovery server is running on port 8761<br />
<a href="http://localhost:8761/" target="_blank">http://localhost:8761/</a><br />
<b><br /></b>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-DsMhjA9Tk9o/XtvuWS9OIII/AAAAAAAAFXw/mdvZfpjeogAEZsmg_3_zH6zwqnwqA4UFwCLcBGAsYHQ/s1600/Zuul%2Bservices%2Bin%2Beureka%2Bserver.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="687" data-original-width="1341" height="326" src="https://1.bp.blogspot.com/-DsMhjA9Tk9o/XtvuWS9OIII/AAAAAAAAFXw/mdvZfpjeogAEZsmg_3_zH6zwqnwqA4UFwCLcBGAsYHQ/s640/Zuul%2Bservices%2Bin%2Beureka%2Bserver.jpg" width="640" /></a></div>
<b><br /></b>
2. Start Zuul server, by default it will run on port 8080<br />
<br />
3. Starting 2 instances on zuul service on port 1111, 2222<br />
<b>Note </b>- you may need to pass <span style="font-family: "courier new", courier, monospace;">server.port </span>argument to start the services as shown below<br />
<span style="font-family: "courier new" , "courier" , monospace;">--server.port=2222</span><br />
<br />
Now hit zuul url<br />
<a href="http://localhost:8080/zuul-service" target="_blank">http://localhost:8080/zuul-service</a><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-TGXdggsIbnE/Xtvw9_7J6FI/AAAAAAAAFX8/tFPMLHVA2bUVcvYi_UI2ntT4BhnzmvMjwCLcBGAsYHQ/s1600/Zuul%2Boutput.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="399" data-original-width="800" height="318" src="https://1.bp.blogspot.com/-TGXdggsIbnE/Xtvw9_7J6FI/AAAAAAAAFX8/tFPMLHVA2bUVcvYi_UI2ntT4BhnzmvMjwCLcBGAsYHQ/s640/Zuul%2Boutput.jpg" width="640" /></a></div>
<br />
On subsequent request u can see response from different instance</div>
Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.comtag:blogger.com,1999:blog-8882377031456587900.post-33092779759342648172020-06-03T18:04:00.003+05:302021-09-25T17:21:33.396+05:30Spring cloud service discovery example<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: left;">
Real time cloud application consist of a large number of micro services communicating with each other. Service instances are added/removed dynamically based on requirement and availability. Service discovery is the process of one service dynamically discovering the network location (IP address and port) of another service without hard coding their location.</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-WYS76rXXK8A/XuEGQNtTVMI/AAAAAAAAFZM/vzNB2igl7DQc4NLqh7PzPRA3g0AURB-LwCLcBGAsYHQ/s1600/Spring%2Bcloud%2Bdiscovery%2Bservice%2Brequest%2Bflow%2Bdiagram.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="396" data-original-width="731" height="345" src="https://1.bp.blogspot.com/-WYS76rXXK8A/XuEGQNtTVMI/AAAAAAAAFZM/vzNB2igl7DQc4NLqh7PzPRA3g0AURB-LwCLcBGAsYHQ/s640/Spring%2Bcloud%2Bdiscovery%2Bservice%2Brequest%2Bflow%2Bdiagram.jpg" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
Steps involved in service discovery<br />
<br />
1. <b>Service registers location</b> - when service boots up it registers itself with discovery server<br />
<br />
2. <b>Client looks for service location</b> - When client needs to hit a particular service first it goes to discovery server for its location<br />
<br />
3. <b>Discovery server sends back location</b> - Discovery server sends the active location of the particular service<br />
<br />
4. <b>Client request service at location</b> - This is a normal request to the service<br />
<br />
5. <b>Service sends response</b> - Service responds to client accordingly<br />
<br />
<b>Example </b>-<br />
<br />
Started eureka server on default port 8761 and Started 2 instances of Application service on 8081 and 8082<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-CdUlUBAQE2U/XtebDxQNssI/AAAAAAAAFWo/RJnAwRs6VNA2HbH6OuPHVkBVQeA9c92RACLcBGAsYHQ/s1600/eureka%2Bserver%2Bconsole.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="671" data-original-width="1344" height="318" src="https://1.bp.blogspot.com/-CdUlUBAQE2U/XtebDxQNssI/AAAAAAAAFWo/RJnAwRs6VNA2HbH6OuPHVkBVQeA9c92RACLcBGAsYHQ/s640/eureka%2Bserver%2Bconsole.jpg" width="640" /></a></div>
<br />
<br />
<b></b><br />
<a name='more'></a><b>Discovery Server</b><br />
<b><br /></b>
pom.xml<br />
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fdiscovery-server%2Fblob%2Fmaster%2Fpom.xml&style=github&showBorder=on&showLineNumbers=on"></script>
application.properties<br />
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fdiscovery-server%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fresources%2Fapplication.properties&style=github&showBorder=on&showLineNumbers=on"></script>
DiscoveryServerApplication.java<br />
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fdiscovery-server%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fjava%2Fcom%2Fjavaxp%2Fdiscoveryserverdemo%2FDiscoveryServerDemoApplication.java&style=github&showBorder=on&showLineNumbers=on"></script>
<b><br /></b>
<b>Application Service</b><br />
<b><br /></b>
pom.xml<br />
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fdiscovery-application-service%2Fblob%2Fmaster%2Fpom.xml&style=github&showBorder=on&showLineNumbers=on"></script>
application.properties<br />
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fdiscovery-application-service%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fresources%2Fapplication.properties&style=github&showBorder=on&showLineNumbers=on"></script>
ServiceApplication.java<br />
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fdiscovery-application-service%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fjava%2Fcom%2Fjavaxp%2Fdiscoveryapplicationservice%2FServiceApplication.java&style=github&showBorder=on&showLineNumbers=on"></script>
Controller.java<br />
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fdiscovery-application-service%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fjava%2Fcom%2Fjavaxp%2Fdiscoveryapplicationservice%2FController.java&style=github&showBorder=on&showLineNumbers=on"></script>
<b><br /></b>
<b>Client</b><br />
<b><br /></b>
pom.xml<br />
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fdiscovery-client%2Fblob%2Fmaster%2Fpom.xml&style=github&showBorder=on&showLineNumbers=on"></script>
application.properties<br />
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fdiscovery-client%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fresources%2Fapplication.properties&style=github&showBorder=on&showLineNumbers=on"></script>
DiscoveryClientApplication.java<br />
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fdiscovery-client%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fjava%2Fcom%2Fjavaxp%2Fdiscoveryclient%2FDiscoveryClientApplication.java&style=github&showBorder=on&showLineNumbers=on"></script>
Controller.java<br />
<script src="https://emgithub.com/embed.js?target=https%3A%2F%2Fgithub.com%2Fmadan712%2Fdiscovery-client%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fjava%2Fcom%2Fjavaxp%2Fdiscoveryclient%2FController.java&style=github&showBorder=on&showLineNumbers=on"></script>
<br />
Here is complete source code in <b>Github</b><br />
<br />
<a href="https://github.com/madan712/discovery-server">https://github.com/madan712/discovery-server</a><br />
<br />
<a href="https://github.com/madan712/discovery-application-service">https://github.com/madan712/discovery-application-service</a><br />
<br />
<a href="https://github.com/madan712/discovery-client">https://github.com/madan712/discovery-client</a></div>
Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.comtag:blogger.com,1999:blog-8882377031456587900.post-4652531417070550002020-05-31T15:47:00.000+05:302020-06-02T23:52:10.824+05:30Spring boot ActiveMQ example<div dir="ltr" style="text-align: left;" trbidi="on">
<b><span style="font-size: large;">ActiveMQ Setup</span></b><br />
<br />
Download the latest version of ActiveMQ from below link<br />
<br />
<a href="https://activemq.apache.org/components/classic/download/" target="_blank">https://activemq.apache.org/components/classic/download/</a><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglthiz-MOAVPT4W-OABElpQplVqBm9YgjeBw7uVfoNVrpnhSEeUS4TxmXUAjnZ3OqdecxEW961XOL6eUF-7eFQJimMU5iBePCDRgVbhGOJKqtQ_D0q33e4I1Kus4k2Wwh-yC2Dxj8t-ak/s1600/Download+apache+ActiveMQ.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="671" data-original-width="1361" height="314" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglthiz-MOAVPT4W-OABElpQplVqBm9YgjeBw7uVfoNVrpnhSEeUS4TxmXUAjnZ3OqdecxEW961XOL6eUF-7eFQJimMU5iBePCDRgVbhGOJKqtQ_D0q33e4I1Kus4k2Wwh-yC2Dxj8t-ak/s640/Download+apache+ActiveMQ.jpg" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
Extract the zip file, go to bin folder and start activemq server using activemq.bat<br />
<br />
In my case it is<br />
apache-activemq-5.15.11/bin/win32/activemq.bat<br />
<br />
Verify ActiveMQ server is UP and running<br />
<br />
<a href="http://localhost:8161/index.html">http://localhost:8161/</a><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-rTjGkb41uE0/XtaYi9rFcaI/AAAAAAAAFV8/3PSfMOqg8ak4zVQb0TvfllYIZU8mhUfDACLcBGAsYHQ/s1600/ActiveMQ%2Bserver%2Bindex%2Bpage.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="456" data-original-width="1359" height="214" src="https://1.bp.blogspot.com/-rTjGkb41uE0/XtaYi9rFcaI/AAAAAAAAFV8/3PSfMOqg8ak4zVQb0TvfllYIZU8mhUfDACLcBGAsYHQ/s640/ActiveMQ%2Bserver%2Bindex%2Bpage.jpg" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
Note - You can change the default port 8161 by updating below file<br />
apache-activemq-5.15.11/conf/jetty.xml<br />
<br />
Go to admin page<br />
<br />
<a href="http://localhost:8161/admin/">http://localhost:8161/admin/</a><br />
<br />
Login with default credentials<br />
<br />
Username - admin<br />
Password - admin<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgA5ou5bFtcQorYOFwsO-mU0D21SEDKDsEOYldmmXe8OU09sHzfWosqg4NP5NEHqDPmST6mDI5t045tTwG2X0D30tLws0wYWFQ2FkqoOyddUU6al3RUj2HDZQmTq1eiksUFF9adNgTjbCM/s1600/ActiveMQ+admin+page.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="634" data-original-width="1361" height="298" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgA5ou5bFtcQorYOFwsO-mU0D21SEDKDsEOYldmmXe8OU09sHzfWosqg4NP5NEHqDPmST6mDI5t045tTwG2X0D30tLws0wYWFQ2FkqoOyddUU6al3RUj2HDZQmTq1eiksUFF9adNgTjbCM/s640/ActiveMQ+admin+page.jpg" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<br />
Note - You can change default credentials by updating below file<br />
apache-activemq-5.15.11/conf/jetty-realm.properties<br />
<br />
Here is how our data will flow<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsTR4jl5GNeRjrH7EFGDOH3hDZwJh-QNGLymAwTyLUsCaOhr8voOqjCPns2tPEJ1Bl6WMnkxJ8uKkiJqwStfcl8gI7s3tOT4tvwC8p_G0Nn1e-8vdfJ4nI_fSLb2GAyIsPEv7oRaUto1M/s1600/ActiveMQ+flow.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="311" data-original-width="653" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsTR4jl5GNeRjrH7EFGDOH3hDZwJh-QNGLymAwTyLUsCaOhr8voOqjCPns2tPEJ1Bl6WMnkxJ8uKkiJqwStfcl8gI7s3tOT4tvwC8p_G0Nn1e-8vdfJ4nI_fSLb2GAyIsPEv7oRaUto1M/s1600/ActiveMQ+flow.jpg" /></a></div>
<br />
<a name='more'></a><br />
Please see the self explanatory code below, in our example server will push a message (Object) to queue ever 2 seconds and client will read the message.<br />
<br />
<span style="font-size: large;"><b>Server</b></span><br />
<br />
<b>pom.xml</b><br />
<script src="https://gist.github.com/madan712/e56ba46fddb4f70f522b09525e630ff3.js"></script>
<b>TestJmsServerApplication.java</b><br />
<script src="https://gist.github.com/madan712/9e5870b11f6e3e778338f9ad843959e9.js"></script>
<b>application.properties</b><br />
<script src="https://gist.github.com/madan712/945a17b58375bce72d41a8283fe67fce.js"></script>
<b><span style="font-size: large;">Client</span></b><br />
<b><span style="font-size: large;"><br /></span></b>
<b>pom.xml</b><br />
<script src="https://gist.github.com/madan712/33f5850a1a0efde7085eaf8322d67375.js"></script>
<b>TestJmsClientApplication.java</b><br />
<script src="https://gist.github.com/madan712/f642e9f5a630a1641feaa802b66b6ec2.js"></script>
<b>Receiver.java</b><br />
<script src="https://gist.github.com/madan712/5e4259239dc7492ff31ac8f1a2eda3a7.js"></script>
<b>application.properties</b><br />
<script src="https://gist.github.com/madan712/945a17b58375bce72d41a8283fe67fce.js"></script>
<b><br /></b>
<b><br /></b>
Download full source code from github<br />
<br />
<a href="https://github.com/madan712/jms-server.git" target="_blank">https://github.com/madan712/jms-server.git</a><br />
<br />
<a href="https://github.com/madan712/jms-client.git" target="_blank">https://github.com/madan712/jms-client.git</a><br />
<br /></div>
Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.comtag:blogger.com,1999:blog-8882377031456587900.post-89392912872704361382019-07-28T22:39:00.003+05:302022-01-09T23:06:14.007+05:30React with Redux authorization workflow example (react-router-dom v6)<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: inherit;">This a simple React example which demonstrates how </span>to restrict access to routes to authenticated users.</div><div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Complete source code can be found in GitHub -<br />
<a href="https://github.com/madan712/auth-workflow" target="_blank">https://github.com/madan712/auth-workflow</a><br />
<br />
Below packages are used in this example -<br />
<ul style="text-align: left;">
<li>React router - React Router is used to manage navigation in react application</li>
<li>Redux - Redux is used to manage state of react applications</li><li>react-router-dom v6 - React routing library</li>
<li>react-bootstrap - React-Bootstrap is a complete re-implementation of the Bootstrap components using React</li>
<li>react-redux-toastr - Used to show alert messages</li>
<li>Webpack - Webpack is used to create prod ready build which can be used to deployed in production</li>
<li>Babel - Babel is used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments</li>
</ul>
<br />
<b>About the example</b> - We have a landing page i.e public page which can be viewed by anyone. As this is a public page, user need not required to go through any sort of authorization<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-J7oN_xica5E/XT3Q1KKr4fI/AAAAAAAAFCc/KXkAGOjBQVkOU4zT8hxUT-IcRnA1rMcZgCKgBGAs/s1600/react%2Bauth%2Bflow%2B1.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="498" data-original-width="772" height="411" src="https://1.bp.blogspot.com/-J7oN_xica5E/XT3Q1KKr4fI/AAAAAAAAFCc/KXkAGOjBQVkOU4zT8hxUT-IcRnA1rMcZgCKgBGAs/s640/react%2Bauth%2Bflow%2B1.jpg" width="640" /></a></div>
<br />
Our private page is a restricted page. If user clicks on private page link, user is taken to login page where user is asked to enter user name and password<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-Mk1vBdUGT5Q/XT3Q1AHbpXI/AAAAAAAAFCc/Evjv7_LgzvEDBZVfpp7hztbmrHlXmJGewCKgBGAs/s1600/react%2Bauth%2Bflow%2B2.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="498" data-original-width="772" height="412" src="https://1.bp.blogspot.com/-Mk1vBdUGT5Q/XT3Q1AHbpXI/AAAAAAAAFCc/Evjv7_LgzvEDBZVfpp7hztbmrHlXmJGewCKgBGAs/s640/react%2Bauth%2Bflow%2B2.jpg" width="640" /></a></div>
<br />
<br />
<a name='more'></a>If user is a valid user i.e authorized user then only user can see the private page<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-oxEbEIO_AOQ/XT3Q1MbatDI/AAAAAAAAFCc/UE2SvDYrNrovdtjMCy5iPsJ2TbRXa9fogCKgBGAs/s1600/react%2Bauth%2Bflow%2B4.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="498" data-original-width="772" height="412" src="https://1.bp.blogspot.com/-oxEbEIO_AOQ/XT3Q1MbatDI/AAAAAAAAFCc/UE2SvDYrNrovdtjMCy5iPsJ2TbRXa9fogCKgBGAs/s640/react%2Bauth%2Bflow%2B4.jpg" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<b>Steps to run the example -</b></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: blue; font-family: Courier New, Courier, monospace;">>git clone https://github.com/madan712/auth-workflow.git</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: blue; font-family: Courier New, Courier, monospace;">>cd auth-workflow</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: blue; font-family: Courier New, Courier, monospace;">auth-workflow>npm install</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: blue; font-family: Courier New, Courier, monospace;">auth-workflow>npm start</span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
</div>
Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.comtag:blogger.com,1999:blog-8882377031456587900.post-3029692208737843502019-06-29T21:32:00.001+05:302019-06-30T15:08:34.747+05:30Spring Boot + Jasypt example to encrypt database password in property file<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
In this example we will see how to encrypted database password in property file (application.properties or application.yml). We will use Jasypt library for this purpose.<br />
<br />
Jasypt (Java Simplified Encryption) is a java library which allows the developer to add basic encryption capabilities to his/her projects with minimum effort, and without the need of having deep knowledge on how cryptography works.<br />
<br />
To know more about Jasypt, <a href="http://www.jasypt.org/" target="_blank">click here</a>. Go to Jasypt website and download the latest version of jasypt client. I am using <a href="https://www.dropbox.com/s/h2hdl32g31zvnau/jasypt-1.9.2-dist.zip?dl=0" target="_blank">jasypt-1.9.2-dist.zip</a>. Once downloaded extract the zip file and go to folder <b>/jasypt-1.9.2/bin</b> and execute the below command. Here input is your password or any other text that you want to encrypt and password is the secret key used by Jasypt to encode and decode the input.<br />
<br />
<span style="color: blue; font-family: "courier new" , "courier" , monospace;">encrypt.bat input="dummy_password" password="SECRET_KEY"</span><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAZc3tFrT3rn0aEOTTEp-z5nCKigcNa7y8JiNPQ_bDADjANZuF9O7holHugMq4iv2XuphyV7Gt-3o3tofsn_ejv4PjRZdjmE8aZ26zZ1bNOAI7075U6n66N3rJdOkw7s8Vbu829BXDE1A/s1600/jasypt+client.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="342" data-original-width="677" height="323" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAZc3tFrT3rn0aEOTTEp-z5nCKigcNa7y8JiNPQ_bDADjANZuF9O7holHugMq4iv2XuphyV7Gt-3o3tofsn_ejv4PjRZdjmE8aZ26zZ1bNOAI7075U6n66N3rJdOkw7s8Vbu829BXDE1A/s640/jasypt+client.jpg" width="640" /></a></div>
<br />
To know about encrypting from the command line using Jasypt CLI Tools. <a href="http://www.jasypt.org/cli.html" target="_blank">click here</a>.<br />
<br />
Add below maven dependency in your <b>pom.xml</b> file<br />
<br />
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><dependency></span><br />
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span><groupId>com.github.ulisesbocchio</groupId></span><br />
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span><artifactId>jasypt-spring-boot-starter</artifactId></span><br />
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><span style="white-space: pre;"> </span><version>2.1.1</version></span><br />
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"></dependency></span><br />
<br /></div>
<b>application.yml</b><br />
Note - the encrypted password in parenthesis with keyword <b>ENC </b><br />
<script src="https://gist.github.com/madan712/c639efcef4dfa3965d178e32827634b4.js"></script>
<b><br /></b>
<b><br /></b>
There are various options by which you can feed the SECRET_KEY to your application<br />
<br />
- From java code you can set system property jasypt.encryptor.password as shown below. You can do this in a separate secure JAR file.<br />
<br />
<span style="color: blue; font-family: "courier new" , "courier" , monospace;">System.setProperty("jasypt.encryptor.password", "SECRET_KEY");</span><br />
<br />
<br />
- From command line you can pass system properties<br />
<br />
<span style="color: blue; font-family: "courier new" , "courier" , monospace;">$ Java -Djasypt.encryptor.password=SECRET_KEY Application</span></div>
Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.comtag:blogger.com,1999:blog-8882377031456587900.post-9563629698249830342019-06-29T17:32:00.003+05:302019-06-29T17:32:50.343+05:30My Sql + Spring Boot JPA - One to many, many to one example <div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif; font-size: 13.2px;">This is a simple spring boot JPA (hibernate) example. It will demonstrate how o</span><span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;">ne to many, many to one mapping can be done</span></span><br />
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;">
Below are the tables created in MySQL</div>
<div style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;">
<br /></div>
<div style="background-color: white;">
<div>
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><span style="font-size: 13.2px;">create table department</span></span></div>
<div>
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><span style="font-size: 13.2px;">(</span></span></div>
<div>
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><span style="font-size: 13.2px;"> department_id int not null auto_increment,primary key (department_id),</span></span></div>
<div>
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><span style="font-size: 13.2px;"> department_name varchar(50) not null</span></span></div>
<div>
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><span style="font-size: 13.2px;">);</span></span></div>
<div>
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><span style="font-size: 13.2px;"><br /></span></span></div>
<div>
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><span style="font-size: 13.2px;"><br /></span></span></div>
<div>
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><span style="font-size: 13.2px;">create table employee</span></span></div>
<div>
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><span style="font-size: 13.2px;">(</span></span></div>
<div>
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><span style="font-size: 13.2px;"> employee_id int not null auto_increment, primary key (employee_id),</span></span></div>
<div>
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><span style="font-size: 13.2px;"> employee_name varchar(50) not null, </span></span></div>
<div>
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><span style="font-size: 13.2px;"> department_id int not null, foreign key (department_id) references department(department_id)</span></span></div>
<div>
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><span style="font-size: 13.2px;">);</span></span></div>
<div>
<span style="color: blue; font-family: "courier new" , "courier" , monospace;"><span style="font-size: 13.2px;"><br /></span></span></div>
<div>
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;"><b>pom.xml</b></span></span><br />
<script src="https://gist.github.com/madan712/f32423a038d5f007631a3462047cb75a.js"></script>
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;"><b><br /></b></span></span>
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;"><b><br /></b></span></span></div>
<div>
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;"><b>application.yml</b></span></span><br />
<script src="https://gist.github.com/madan712/630b06e21cdfae5694dfd57b6c697f63.js"></script>
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;"><b><br /></b></span></span>
<br /></div>
<div>
<a name='more'></a><span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;"><b>Employee.java</b></span></span><br />
<script src="https://gist.github.com/madan712/c875961c891af95b440192c5ba355e15.js"></script>
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;"><b><br /></b></span></span>
<br /></div>
<div>
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;"><b>Department.java</b></span></span><br />
<script src="https://gist.github.com/madan712/7675f2fc266d5536685ab9e41a5f42c8.js"></script>
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;"><b><br /></b></span></span>
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;"><b><br /></b></span></span>
<b style="color: #222222; font-family: arial, tahoma, helvetica, freesans, sans-serif; font-size: 13.2px;">EmployeeRepository.java</b><br />
<script src="https://gist.github.com/madan712/091440a53c11a2fc7dce54d243d36341.js"></script>
<b style="color: #222222; font-family: arial, tahoma, helvetica, freesans, sans-serif; font-size: 13.2px;"><br /></b>
<b style="color: #222222; font-family: arial, tahoma, helvetica, freesans, sans-serif; font-size: 13.2px;"><br /></b></div>
<div>
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;"><b>DepartmentRepository.java</b></span></span><br />
<script src="https://gist.github.com/madan712/86b8a26cd787bd1e118196d864e3996a.js"></script>
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;"><b><br /></b></span></span>
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;"><b><br /></b></span></span></div>
<div>
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;"><b>Application.java</b></span></span><br />
<script src="https://gist.github.com/madan712/cf93b1d1a60b0afdb73834520b58472a.js"></script>
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;"><b><br /></b></span></span>
<span style="color: #222222; font-family: "arial" , "tahoma" , "helvetica" , "freesans" , sans-serif;"><span style="font-size: 13.2px;"><b><br /></b></span></span></div>
</div>
</div>
Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.comtag:blogger.com,1999:blog-8882377031456587900.post-63393393474224791002019-06-28T02:12:00.001+05:302019-06-28T02:12:41.007+05:30Java - Export database table to CSV file<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px;">This is a sample springboot application with bare minimum code to export database tables to CSV file</span><br />
<b><br /></b>
<b>pom.xml</b><br />
<script src="https://gist.github.com/madan712/12a4b036cc3f5aecfadb6435f6fab36a.js"></script>
<br />
<b>application.yml</b><br />
<script src="https://gist.github.com/madan712/630b06e21cdfae5694dfd57b6c697f63.js"></script>
<br />
<b>Application.java</b><br />
<script src="https://gist.github.com/madan712/d890822770530ae908b1d91395b1c016.js"></script>
<b><br /></b></div>
Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.comtag:blogger.com,1999:blog-8882377031456587900.post-92128655971084048432019-06-28T01:42:00.000+05:302019-06-28T01:42:19.947+05:30Python - Export database table to csv file<div dir="ltr" style="text-align: left;" trbidi="on">
<script src="https://gist.github.com/madan712/f27ac3b703a541abbcd63871a4a56636.js"></script>
<br /></div>
Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.comtag:blogger.com,1999:blog-8882377031456587900.post-53563309060521280492019-06-28T00:51:00.000+05:302019-06-28T00:53:40.332+05:30Java - Export database tables to an excel file<div dir="ltr" style="text-align: left;" trbidi="on">
This is a sample springboot application with bare minimum code to export database tables to an excel file<br />
<br />
<b>pom.xml</b><br />
<script src="https://gist.github.com/madan712/154c85fdbfb1fa9de5112ae91813ce57.js"></script>
<b><br /></b>
<b>application.yml</b><br />
<script src="https://gist.github.com/madan712/630b06e21cdfae5694dfd57b6c697f63.js"></script>
<b><br /></b>
<b>Application.java</b><br />
<script src="https://gist.github.com/madan712/1bdaee47739d3bd3c60ed98ceb259765.js"></script>
<b><br /></b></div>
Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.comtag:blogger.com,1999:blog-8882377031456587900.post-72796884120119903062019-06-27T01:51:00.000+05:302019-06-28T00:54:13.783+05:30Python - Export database tables to an excel file<div dir="ltr" style="text-align: left;" trbidi="on">
<script src="https://gist.github.com/madan712/b01e85eeddecf9b92b53f8d3e11986d7.js"></script>
</div>
Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.comtag:blogger.com,1999:blog-8882377031456587900.post-68216828537443963012019-06-23T15:02:00.001+05:302019-06-23T15:02:13.007+05:30Python - Connect mysql<div dir="ltr" style="text-align: left;" trbidi="on">
Python needs a MySQL driver to access the MySQL database. PIP can be used to install "MySQL Connector". PIP is most likely already installed in your Python environment. Go to command prompt and execute below command<br />
<br />
<span style="color: blue; font-family: Courier New, Courier, monospace;">C:\> python -m pip install mysql-connector</span><br />
<span style="color: blue; font-family: Courier New, Courier, monospace;"><br /></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://1.bp.blogspot.com/-wL1nnDRtWNE/XQ9GW9BOG2I/AAAAAAAAE_I/-K12UvZkZCwMl1Yn837Ttl1yelHCpk8ygCLcBGAs/s1600/python%2Bpip%2Binstall%2Bmysql.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="282" data-original-width="677" height="266" src="https://1.bp.blogspot.com/-wL1nnDRtWNE/XQ9GW9BOG2I/AAAAAAAAE_I/-K12UvZkZCwMl1Yn837Ttl1yelHCpk8ygCLcBGAs/s640/python%2Bpip%2Binstall%2Bmysql.jpg" width="640" /></a></div>
<br />
<br />
test-mysql.sql<br />
<script src="https://gist.github.com/madan712/9e0423bfd9c168f34b75a656c4696425.js"></script>
<br /></div>
Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.comtag:blogger.com,1999:blog-8882377031456587900.post-46954266444030954942019-06-22T01:33:00.004+05:302019-06-22T01:33:40.619+05:30Empty pom.xml for new maven project<div dir="ltr" style="text-align: left;" trbidi="on">
<script src="https://gist.github.com/madan712/9e0a2c77b5991096b0244449b4729988.js"></script>
<br /></div>
Madanhttp://www.blogger.com/profile/05020140911511710072noreply@blogger.com