<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gayath Menuka Senevirathne on Medium]]></title>
        <description><![CDATA[Stories by Gayath Menuka Senevirathne on Medium]]></description>
        <link>https://medium.com/@gayathmenuka?source=rss-6e41d726b7d6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*zec9Eq-870EdpTuJ</url>
            <title>Stories by Gayath Menuka Senevirathne on Medium</title>
            <link>https://medium.com/@gayathmenuka?source=rss-6e41d726b7d6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 19:25:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gayathmenuka/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Art of Controlled Chaos: How to Intentionally Slow Down Your WSO2 Database using ToxiProxy]]></title>
            <link>https://medium.com/@gayathmenuka/the-art-of-controlled-chaos-how-to-intentionally-slow-down-your-wso2-database-using-toxiproxy-405a111599a5?source=rss-6e41d726b7d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/405a111599a5</guid>
            <dc:creator><![CDATA[Gayath Menuka Senevirathne]]></dc:creator>
            <pubDate>Mon, 26 Jan 2026 10:05:00 GMT</pubDate>
            <atom:updated>2026-01-26T10:05:00.006Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bkNUqDlF6zvulTZq4diSBw.png" /></figure><p>When investigating runtime issues, there are situations where intentionally slowing down servers is not a viable option. In such cases, it is often necessary to recreate network-level latency or slowness in order to effectively troubleshoot the problem. And it’s a bit hard to control the network layer in Macbooks. In such cases ToxiProxy can be used as below.</p><h4>Setting up ToxiProxy.</h4><p>First, install the Toxiproxy using brew.</p><pre>brew install toxiproxy</pre><p>Start the toxiproxy as below</p><pre>toxiproxy-server</pre><p>Create a proxy using the below curl command. <em>For the sake of this example we’ll proxy a local database server which is running originally on 3306 port.</em></p><p>Curl command to create a proxy listening on port 3307 that forwards to your real MySQL on 3306.</p><pre>curl -X POST http://localhost:8474/proxies \<br>  -H &quot;Content-Type: application/json&quot; \<br>  -d &#39;{<br>    &quot;name&quot;: &quot;mysql_slow&quot;,<br>    &quot;listen&quot;: &quot;127.0.0.1:3307&quot;,<br>    &quot;upstream&quot;: &quot;127.0.0.1:3306&quot;,<br>    &quot;enabled&quot;: true<br>  }&#39;</pre><p>The delay can be added in the runtime with the below curl command. The latency which is in ms can be adjusted as preferred.</p><pre>curl -X POST http://localhost:8474/proxies/mysql_slow/toxics \<br>  -H &quot;Content-Type: application/json&quot; \<br>  -d &#39;{<br>    &quot;type&quot;: &quot;latency&quot;,<br>    &quot;name&quot;: &quot;latency_delay&quot;,<br>    &quot;stream&quot;: &quot;downstream&quot;,<br>    &quot;toxicity&quot;: 1.0,<br>    &quot;attributes&quot;: {<br>      &quot;latency&quot;: 1000,<br>      &quot;jitter&quot;: 0<br>    }<br>  }&#39;</pre><p>The delay can be removed with the below curl command.</p><pre>curl -X DELETE http://localhost:8474/proxies/mysql_slow/toxics/latency_delay  Add delay</pre><h4>Setting up Micro Integrator.</h4><p>Let’s verify this through a simple <a href="https://apim.docs.wso2.com/en/4.2.0/install-and-setup/setup/mi-setup/deployment/deploying_wso2_ei/">WSO2 MI cluster</a> running on a Macbook (M4). The original WSO2_COORDINATION_DB configurations are as below.</p><pre>[[datasource]]<br>id = &quot;WSO2_COORDINATION_DB&quot;<br>url= &quot;jdbc:mysql://localhost:3306/clusterdb&quot;<br>username=&quot;root&quot;<br>password=&quot;&quot;<br>driver=&quot;com.mysql.jdbc.Driver&quot;<br>pool_options.maxActive=50<br>pool_options.maxWait = 60000<br>pool_options.testOnBorrow = true</pre><p>Since we have the ToxiProxy in place, change the url as below to utilize the proxy.</p><pre>[[datasource]]<br>id = &quot;WSO2_COORDINATION_DB&quot;<br>url=&quot;jdbc:mysql://localhost:3307/clusterdb&quot;<br>username=&quot;root&quot;<br>password=&quot;&quot;<br>driver=&quot;com.mysql.jdbc.Driver&quot;<br>pool_options.maxActive=50<br>pool_options.maxWait = 60000<br>pool_options.testOnBorrow = true</pre><p>Then start the WSO2 MI as usual. And apply the DB slowness by running the above mentioned curl command, and you’ll see the below error just afterwards. As you can see, the database slowness immediately triggers cluster coordination failures, causing the node to become unresponsive and tasks to be interrupted.</p><pre>[2026-01-26 15:01:14,145]  WARN {RDBMSCoordinationStrategy} - Error updating coordinator heartbeat in LEADER_STATUS_TABLE due to database delay. Stopping coordinated tasks for this node. Please increase the heartbeat interval or verify the database connection. Make task Sleep for the duration of : 30000 org.wso2.micro.integrator.coordination.exception.ClusterCoordinationException: Database connection turned unresponsive. Please increase the heartbeat interval or verify the database connection.<br> at org.wso2.micro.integrator.coordination.RDBMSCoordinationStrategy$CoordinatorElectionTask.performDBOperationsWithTimeout(RDBMSCoordinationStrategy.java:516)<br> at org.wso2.micro.integrator.coordination.RDBMSCoordinationStrategy$CoordinatorElectionTask.performCoordinatorTask(RDBMSCoordinationStrategy.java:604)<br> at org.wso2.micro.integrator.coordination.RDBMSCoordinationStrategy$CoordinatorElectionTask.runCoordinationElectionTask(RDBMSCoordinationStrategy.java:446)<br> at org.wso2.micro.integrator.coordination.RDBMSCoordinationStrategy$HeartBeatExecutionTask.run(RDBMSCoordinationStrategy.java:358)<br> at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)<br> at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)<br> at java.base/java.lang.Thread.run(Thread.java:1583)<br>Caused by: java.util.concurrent.TimeoutException<br> at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:204)<br> at org.wso2.micro.integrator.coordination.RDBMSCoordinationStrategy$CoordinatorElectionTask.performDBOperationsWithTimeout(RDBMSCoordinationStrategy.java:509)<br> ... 6 more<br><br>[2026-01-26 15:01:14,146]  WARN {RDBMSMemberEventListenerTask} - Node [node-1] in group [default] has become unresponsive.<br>[2026-01-26 15:01:14,146]  INFO {ClusterCoordinator} - Lost connection to the cluster.<br>[2026-01-26 15:01:14,146]  INFO {TaskEventListener} - Shutting down coordinated task scheduler scheduler since the node became unresponsive.<br>[2026-01-26 15:01:21,522] FATAL {CoordinatedTaskScheduler} - Unexpected error occurred while trying to schedule tasks. java.lang.InterruptedException: Task was interrupted.<br> at org.wso2.micro.integrator.ntask.coordination.task.scehduler.CoordinatedTaskScheduler.checkInterrupted(CoordinatedTaskScheduler.java:144)<br> at org.wso2.micro.integrator.ntask.coordination.task.scehduler.CoordinatedTaskScheduler.run(CoordinatedTaskScheduler.java:101)<br> at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)<br> at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:358)<br> at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)<br> at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)<br> at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)<br> at java.base/java.lang.Thread.run(Thread.java:1583)<br><br>[2026-01-26 15:01:22,144]  WARN {RDBMSCommunicationBusContextImpl} - Transaction rolled back for task: updating coordinator heartbeat</pre><p>Simple as that. I hope this would be helpful with troubleshooting and debugging.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=405a111599a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Study guide for the Certified Kubernetes Administrator (CKA) Exam | 2024]]></title>
            <link>https://medium.com/@gayathmenuka/study-guide-for-the-certified-kubernetes-administrator-cka-exam-2024-dea11cb46762?source=rss-6e41d726b7d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/dea11cb46762</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cka]]></category>
            <category><![CDATA[ckad-exam]]></category>
            <dc:creator><![CDATA[Gayath Menuka Senevirathne]]></dc:creator>
            <pubDate>Mon, 30 Sep 2024 16:58:31 GMT</pubDate>
            <atom:updated>2024-09-30T16:59:02.226Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi Folks,</p><p>I took the CKA exam in September 2024 and successfully completed it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*LnvSiIxOFJH0-jHFL8Ulvg.png" /></figure><p>Thought of sharing some tips and tricks that I think would be helpful. Please note that this guide is for the beginners for Kubernetes. In my case I started from the scratch, simply put from the point ‘what is Kubernetes’.</p><p>The main point is, you should have a proper understanding of basic concepts. But just knowing the theory won’t be enough unless you don’t know how to apply those. Which means you should gain some hands-on experience prior to the exam.</p><h4>Some useful resources</h4><p>Highly recommend the <strong><em>Certified Kubernetes Administrator (CKA) with Practice Tests </em></strong>course by <a href="https://medium.com/u/66bce4899d7b">Mumshad Mannambeth</a> from the Udemy [1] which gives an overall understanding about the core concepts and it provides the chance to practice these in the KubeCloud environment.</p><p>You can practice different scenarios from here [2] Killecoda for free in a linux environment. You get 1 hour for each question/scenario to explore and try out. I believe that’s enough for learning purposes, but you have the option to get the plus version if required.</p><p>While traversing through the internet, I found this underrated youtube channel [3] called <strong>kubernetesWay</strong> which has accurate and clear explanations.</p><p>If you want to practice more exam-like questions, there are some really useful questions available in here [4] I recommend to go through these questions multiple times before the exam.</p><p>The network policy recipes available here [5] offer valuable insights that can expand your understanding of Network Policies. And these [6] practice exercises will also be useful in the process of learning.</p><p><em>All the due credits to the respective owners of above resources who put their time and effort to prepare such great content</em>.</p><h4>When taking the exam…</h4><p>You have access to the Kubernetes documentation in the exam, but you have to be familiar with it and you should know where to look. Otherwise the time won’t be sufficient.</p><p>The weightage of the questions are not marked in the exam, but you’ll have a rough idea of these by the above samples that I pointed.</p><p>You’ll have access for the official mock exam once you register for the exam. You can take this mock exam twice and each session will be active for only 36 hours once you activate this. Practice as much as possible and save these questions for later reference. Please don’t be disappointed by these questions, because these are a little harder than the actual exam questions, the exam would be easier when you are comfortable with these questions.</p><p>Make sure to read the handbook and prepare your environment accordingly.</p><h4>What went wrong for me…</h4><p>On my first attempt, my WIFI got disconnected while I was in the exam and the session was closed due to this. Then I have to go through the whole administration process again. By the time I got back to the exam, I noticed that the time had been calculated (more than 30 mins) while I was going through all the troubles. I tried to explain this to the proctor but there was nothing he/she could do and asked me to continue. I already knew the time wasn’t enough, so I just went through the questions and tried to do as much as possible. Anyway I reached the Linux Support and explained everything though a support ticket, then they agreed to provide me an exception.</p><p>Believe it or not, I faced another difficulty in the last attempt too since the lights of the room went out for a few seconds. But I managed to finish it since I practiced a lot more after the incident in the first attempt.</p><p>So please make sure to take the exam from a stable (ie controlled) environment, test your peripherals (mic, keyboard, mouse etc) before the exam. <strong><em>I do not recommend</em></strong> you take the exam with a small screen. I tried with a MacBook Air 13 inch and it was a nightmare. Please use a bigger monitor, 24 inch monitor would be ideal. But you will have to use an external webcam if you are using an external monitor for the laptop since you can’t use multiple screens in the exam.</p><p>I hope this will be helpful with the exam. Good Luck !</p><pre>&quot;Don&#39;t practice until you get it right. Practice until you can&#39;t get it wrong&quot;</pre><p>[1] <a href="https://www.udemy.com/course/certified-kubernetes-administrator-with-practice-tests/">https://www.udemy.com/course/certified-kubernetes-administrator-with-practice-tests/</a><br>[2] <a href="https://killercoda.com/cka">https://killercoda.com/cka</a><br>[3] <a href="https://www.youtube.com/@kubernetesway">https://www.youtube.com/@kubernetesway</a><br>[4] <a href="https://github.com/sandistorm/CKA-Certified-Kubernetes-Administrator-2022/blob/main/CKA%20Exam.md">https://github.com/sandistorm/CKA-Certified-Kubernetes-Administrator-2022/blob/main/CKA%20Exam.md</a><br>[5] <a href="https://github.com/ahmetb/kubernetes-network-policy-recipes/tree/master">https://github.com/ahmetb/kubernetes-network-policy-recipes/tree/master</a><br>[6] <a href="https://github.com/alijahnas/CKA-practice-exercises/tree/CKA-v1.27">https://github.com/alijahnas/CKA-practice-exercises/tree/CKA-v1.27</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dea11cb46762" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configuring AWS Cognito as a Federated Authenticator for WSO2 APIM 4.X and 3.X versions.]]></title>
            <link>https://medium.com/@gayathmenuka/configuring-aws-cognito-as-a-federated-authenticator-for-wso2-apim-4-x-and-3-x-versions-84770f34c821?source=rss-6e41d726b7d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/84770f34c821</guid>
            <category><![CDATA[aws-cognito]]></category>
            <category><![CDATA[federated-authentication]]></category>
            <category><![CDATA[wso2]]></category>
            <category><![CDATA[wso2-api-manager]]></category>
            <dc:creator><![CDATA[Gayath Menuka Senevirathne]]></dc:creator>
            <pubDate>Sun, 14 Jul 2024 11:53:56 GMT</pubDate>
            <atom:updated>2024-07-14T11:53:56.486Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ahvkfO5-FluMJoKIHacSPw.png" /></figure><p>WSO2 API Manager is designed to meet the needs of modern enterprises, providing a flexible, scalable, and secure solution for managing APIs throughout their lifecycle. It empowers organizations to accelerate their digital transformation initiatives by leveraging APIs to connect systems, services, and applications efficiently.</p><p>AWS Cognito serves as a robust federated authenticator, allowing seamless integration with various identity providers to streamline user authentication across multiple applications. This federated authentication capability simplifies the user experience by enabling Single Sign-On (SSO), where users can log in once and gain access to multiple systems without needing to re-authenticate</p><p>In this blog, we will explore the integration of AWS Cognito as a federated authenticator for WSO2 API Manager to facilitate Single Sign-On (SSO) using OpenID Connect (OIDC).</p><p>Prerequisites</p><ul><li>AWS Account: Ensure you have an AWS account with access to AWS Cognito.</li><li>WSO2 API Manager: <a href="https://wso2.com/api-management/">Have WSO2 API Manager installed and running</a>.</li></ul><p>First I’ll walk you through on creating the user pool from the AWS Cognito.</p><p>Kindly note that the below steps are valid for both APIM 3.X and 4.X versions.</p><h3>Step 1: Create the AWS Cognito User pool</h3><ul><li>Login to the AWS Console and go to the Amazon Cognito User Pools and click on Create user pool.</li><li>Then click the User name under Cognito user pool sign-in options and check the “Allow “users to sign in with a preferred user name” as well and click Next.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aUCcAHbD8LwsWUOJ" /></figure><ul><li>Keep the Password policy as it is and choose Optional MFA under Multi-factor authentication. And Authenticator apps under MFA methods.</li><li>Keep the Password policy as it is and choose Optional MFA under Multi-factor authentication. And Authenticator apps under MFA methods.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KA6wUQ_aO80uGyrI" /></figure><ul><li>For this test setup we kept “Don’t automatically send messages” under Cognito-assisted verification and confirmation. The rest of the information was kept as it is in the “Configure sign-up experience” window.</li><li>“Send email with Cognito” option was selected under the “Configure message delivery” window.</li><li>Provide a proper name for the user pool under the “Integrate your app” window. And check the “Use the Cognito Hosted UI” which will allow you to create a Domain.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Yx7p-IkV09GvnsKw" /></figure><ul><li>Provide a valid cognition domain as per your preference.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W0pZPsh6PQkQvlLH" /></figure><ul><li>Then provide a name for the app client under the “Initial app client” section. And select the Generate a client secret option.</li></ul><pre>Callback URL(s) : https://&lt;APIM HOST&gt;:&lt;PORT&gt;/commonauth</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ByOtY-ujUudjaZXM" /></figure><ul><li>Then add “ALLOW_CUSTOM_AUTH under Authentication flows in Advanced app client settings.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*00O82uiQ_FgfN4WL" /></figure><ul><li>Select the “Authorization code grant as the grant type and the OpenID as the scope. And add “https://&lt;APIM HOST&gt;:&lt;PORT&gt;/commonauth?state=logout” as the sign out url.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lD0LkpQvs5c_ojUT" /></figure><ul><li>Verify everything and create a user pool.</li><li>Finally create a user with a preferred username.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tnkWHBZNOe9WytgR" /></figure><h4>Step 2: Create the Identity Provider in the APIM server</h4><ul><li>Login to the management console (https://&lt;Hostname&gt;:9443/carbon/)</li><li>Go to the Identity Providers section under the Main tab in the left side menu.</li><li>Click on Add and provide an appropriate name as the Identity Provider Name.</li><li>Then expand the Federated Authenticators section and click on OAuth2/OpenID Connect Configuration.</li><li>You have to get the Client Id and Client Secret from the App Client available in the AWS Cognito user pool.</li><li>Then you have to provide the Authorization Endpoint URL and Token Endpoint URL as mentioned here [2], make sure to properly add the user pool domain from the AWS Cognito. You can leave the other configurations as it is. Please be mindful about the Callback Url and the Logout Endpoint URL, you have to configure these with the hostname of the APIM server.</li></ul><pre>Authorization Endpoint URL: https://&lt;Domain of the AWS Cognito&gt;/oauth2/authorize<br>Token Endpoint URL: https://&lt;Domain of the AWS Cognito&gt;/oauth2/token<br>Callback URL - https://&lt;Hostname Of the APIM&gt;:&lt;PORT&gt;/commonauth<br>Logout Endpoint URL - https://&lt;Hostname Of the APIM&gt;:&lt;PORT&gt;/commonauth?state=logout</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z4dfeWS9wpG_gb2o" /></figure><ul><li>Verify everything and click on Register.</li></ul><p>Then you have to create a Service Provider.</p><h4>Step 3: Create the Service Provider in the APIM server</h4><ul><li>Go to the Service Providers section from the left menu in the Management Console.</li><li>Provide an appropriate name and click on Register.</li><li>Click on the configure button inside the OAuth/OpenID Connect Configuration under the Inbound Authentication Configuration.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WFRx6VHOxXd5zVSf" /></figure><ul><li>You can provide the Callback URL of the client application which you want to enable SSO. In our case, we used this pickup-dispatcher [3] web application so the callback URL was configured as <a href="http://localhost:8080/pickup-dispatch/oauth2client">http://localhost:8080/pickup-dispatch/oauth2client</a>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RrFh-ppcVxmSMnWl" /></figure><ul><li>After the keys are generated, you can copy the ClientID (OAuth Client Key) and the client secret (OAuth Client Secret) from the Service Provider and use this in your client application(ex: pickup-dispatch) accordingly.</li><li>Finally, expand the Local &amp; Outbound Authentication Configuration and choose the Identify Provider which was created in the above steps as the Authentication Type. Here you can skip the Login Consent if required.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QLG2SjWAgKvtqlLl" /></figure><p>Those are the steps that have to be followed, then you can try to login to your web application. First, it will be prompt to change the password and you will have to re-login with the new password.</p><p><em>Please refer to the login flow with the application that we tested.</em></p><p>Click on the login.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*v1cDifD_Vmy9J75Y" /></figure><p>Enter username and the password of the user that was created in the Cognito.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6GQt_vOdhLBD7IGX" /></figure><p>Change the password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_pLoAb9KU5udx11g" /></figure><p>It redirects to the consent page since we haven’t disabled that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QBvwR-KitBpOl4Pt" /></figure><p>Then it goes to the main page after clicking the continue button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bscc6GpbMmCnHG5D" /></figure><h4>Appendix</h4><p>How to run a webapp inside the Tomcat server.</p><ol><li>Download the server from here [4], for this we used apache-tomcat-8.0.1 version.</li><li>Make sure to create a logs directory if it’s not available in the home once the above archive is extracted.</li><li>Then deploy the pickup-dispatch app inside the &lt;Tomcat Home&gt;/webapps directory.</li><li>You might need to copy the wso2carbon.jks file from the &lt;APIM HOME &gt;/repository/resources/security to the &lt;Tomcat Home&gt;/webapps/pickup-dispatch/WEB-INF/classes.</li><li>Make sure to update the dispatch.properties file as mentioned above which lies in the &lt;Tomcat Home&gt;/webapps/pickup-dispatch/WEB-INF/classes/dispatch.properties. <strong>This is related to step 05 under “Create the Service Provider in the APIM server”</strong> section of this blog.</li></ol><p>Please refer to a sample of dispatch.properties.</p><pre>consumerKey=xxxxxxxx<br>consumerSecret=xxxxxxxxxx<br>callBackUrl=http://localhost:8080/pickup-dispatch/oauth2client<br>scope=openid<br>authzGrantType=code<br>enableOIDCSessionManagement=false<br>enableOIDCBackchannelLogout=true<br>authzEndpoint=https://localhost:9443/oauth2/authorize<br>OIDC_LOGOUT_ENDPOINT=https://localhost:9443/oidc/logout<br>sessionIFrameEndpoint=https://localhost:9443/oidc/checksession<br>tokenEndpoint=https://localhost:9443/oauth2/token<br>claimManagementEndpoint=https://localhost:9443/services/ClaimMetadataManagementService<br>post_logout_redirect_uri=http://localhost:8080/pickup-dispatch/oauth2client<br>api_endpoint=http://localhost:39090/bookings<br>adminUsername=admin<br>adminPassword=admin</pre><p>Hope this blog will be supportive. Finally I would like to convey my heartfelt gratitude to <a href="https://medium.com/u/20da591f96b0">Lakmini Wathsala</a> for all the assistance while setting and testing these flows.</p><p>Cheers ! Till next time.</p><p>[1] <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/tutorial-create-user-pool.html">https://docs.aws.amazon.com/cognito/latest/developerguide/tutorial-create-user-pool.html</a><br>[2] <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/federation-endpoints.html">https://docs.aws.amazon.com/cognito/latest/developerguide/federation-endpoints.html</a><br>[3] <a href="https://github.com/wso2/samples-is/releases?page=2">https://github.com/wso2/samples-is/releases?page=2</a><br>[4] <a href="https://archive.apache.org/dist/tomcat/tomcat-8/">https://archive.apache.org/dist/tomcat/tomcat-8/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84770f34c821" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying WSO2 APIM In Azure | Setting Up Databases | NFS File Mount]]></title>
            <link>https://medium.com/@gayathmenuka/deploying-wso2-apim-in-azure-setting-up-databases-nfs-file-mount-fb09f5a6b580?source=rss-6e41d726b7d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb09f5a6b580</guid>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[wso2-api-manager]]></category>
            <dc:creator><![CDATA[Gayath Menuka Senevirathne]]></dc:creator>
            <pubDate>Sun, 26 Mar 2023 12:22:00 GMT</pubDate>
            <atom:updated>2023-03-26T12:27:53.226Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b1BzE7YL8ilzfIWRcG_Dcg.jpeg" /></figure><p>In this blog I will be covering the areas below.</p><ul><li>Deploying APIM 3.2.0 in an Azure Linux virtual machine</li><li>Connecting the WSO2 APIM with Mysql database hosted in Azure.</li><li>Mounting the Azure File Shares to the WSO2 APIM.</li></ul><h3><strong>Creating the Azure VM</strong></h3><p>The type of the VM and the other resources can be chosen depending on your requirement. I’ll be using Standard D4s v3.</p><p>As the first step we’ll create a Virtual Machine (VM). There are multiple ways to create a VM [1], here I’ll be using Azure Portal.</p><p>1.First log in to the Azure Portal, Search for Virtual Machines in the top search bar, It’ll list down all the current Virtual Machines that you have (If you have any).</p><p>2.Then click on the Create button top left corner to begin VM creation. There are few options and here I’m going with Azure Virtual Machine.</p><p>3.From the basic tab, under the project details choose the correct subscription and would be better to create a new Resource Group.</p><p>4.Under the Instance details, provide a unique machine name and choose an image based on your requirement. If you need an ubuntu instance you can go with the available options, here I have chosen CentOS 7 -x64 Gen 1. And the Standard D4s_v3–4 vcpus was chosen as the Size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*zYnxODaaS2kiLnyjWPgpwA.png" /></figure><p>5.Then select the SSH public key as the Authentication Type and provide a preferred username and Key pair name.</p><p>6.Under the Select inbound port, choose Allow selected ports and then select SSH (22) and HTTP (80) from the drop-down.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*oE-_tcHrDF0p4u3r0DjpEg.png" /></figure><p>7.Now we can move on to the Disks tab, you can select OS disk type and add a Data Disk as per your preference. A data disk can be added after creating the VM as well.</p><p>8.You can keep the other configurations as it is and go to the Review + create tab. And click on the create button once the validation is passed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*RbSo-QUUxXegpqZL4O7rRQ.png" /></figure><p>9.Afterwards select Download private key and create resource from the popup window. Your key file will be downloaded as samplevm_key.pem. Make sure you know where the .pem file was downloaded; as you need this to access the newly created VM.</p><p>10.Then you can connect to the VM from your local machine using the below command.</p><pre>ssh -i ~/Downloads/myKey.pem azureuser@11.111.11.111</pre><h4><strong>Installing Java and setting up JAVA_HOME.</strong></h4><p>1.We should install Java to run WSO2 APIM.</p><p>2.As the first step you can install java using the below command. Here we have used Zulu java 8.</p><p>3.sudo yum localinstall jdk-8u345b01-linux-x64.rpm</p><p>4.Then set the JAVA_HOME</p><p>5.vim /etc/profile</p><pre>export JAVA_HOME=&quot;/usr/lib/jvm/zulu-8&quot; <br>export PATH=$JAVA_HOME/bin:$PATH</pre><p>6.You can further confirm this echo JAVA_HOME command.</p><h3><strong>Deploying WSO2 APIM 3.2 All-in-one in the Azure VM</strong></h3><p>1.There are several ways to deploy the APIM package in the VM.</p><p>2.One way would be to directly download the package from the Internet.</p><p>3.Another option is to use SCP (secure copy) which is a command-line utility that allows you to securely copy files and directories between two locations.</p><p>4.The other option is to use a client application like FileZilla. I’ll provide the steps with FileZilla.</p><ul><li>Open Filezilla client and go to the click on File and select Site Manager.</li><li>Then click on New Site, select SFTP as the Protocol, provide the Ip address of the above VM and select the 22 as the port.</li><li>Select Key file from the Logon Type drop down menu.</li><li>Add azureuser as the User and provide the path .pem (samplevm_key.pem) file we downloaded earlier after the VM creation.</li><li>Then click on the connect and it’ll allow you to copy files directly from the local machine.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oGz6vZA8ONTsc1QzOhcE4g.png" /></figure><p>5.Then get the latest U2 updated WSO2 package, compress it and copy to the VM.</p><h3>Connecting to MYSQL Database</h3><p>By default, WSO2 API Manager uses the embedded H2 database as the database for storing user management and registry data. H2 is a file based database which can be corrupted easily.</p><p>Therefore it’s recommended to use a production ready Relational database with the production environment. In this case I’ll be using MySql as the database.</p><ul><li>As the first Step you have to create an Azure Database for MySQL servers. For that you can search the same (Azure Database for MySQL servers) in the top search bar to start the creation process.</li><li>Then select the Resource Group and enter the other Server Details as you prefer. In this case I have used General Purpose, D2ds_v4, 2 vCores, 8 GiB RAM, 64 storage, 1000 IOPS.</li><li>Make sure to choose same the <strong>Location</strong> and the <strong>Availability Zone</strong> as the aligns with the above VM.</li><li>Provide information to the Administrator account as well and go to the <strong>Review and Create </strong>tab.</li><li>In here I will not be using secure transport, to disable that, go to the mysql resource and Server Parameters from the left side tab.</li><li>Then search for <strong>require_secure_transport </strong>and make the value as OFF.</li></ul><p>Now we have the running mysql server, as the next step you have to add the relevant driver to the APIM. Then create the databases and create the tables using the db scripts which reside in the &lt;APIM-HOME&gt;/dbscripts directory. <a href="https://apim.docs.wso2.com/en/3.2.0/install-and-setup/setup/setting-up-databases/changing-default-databases/changing-to-mysql/#setting-up-mysql.">The detailed steps can be found from the WSO2 APIM Manager documentation.</a></p><p>Finally you can add the configurations in the deployment.toml which lies in the &lt;APIM-HOME&gt;/repository/conf directory.</p><pre>[database.shared_db]<br>type = &quot;mysql&quot;<br>url = &quot;jdbc:mysql://&lt;db_name&gt;.mysql.database.azure.com:3306/shared_db_final?useSSL=false&quot;<br>username = “menuka”<br>password = “****&quot;<br><br>[database.apim_db]<br>type = &quot;mysql&quot;<br>url = &quot;jdbc:mysql://&lt;db_name&gt;.mysql.database.azure.com:3306/apim_db_final?useSSL=false&quot;<br>username = “menuka”<br>password = “****”</pre><h3><strong>How to create Azure file share and mount it on a Linux VM.</strong></h3><p>Here I’ll walk you through Different File Share accounts and how to mount them on a VM. Performance wise there are two types of instances as Standard and Premium. Here we’ll be discussing the Premium.</p><p>First I’ll explain how to create a Storage Account. As usual, search for Storage Account in the top search bar in the Azure portal.</p><p>1.Add the Project details as you prefer and provide an appropriate name to the Storage Account.</p><p>2.Select Premium for the Performance under Instance details.</p><p>3.The select File Shares for the Premium account type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7PAgoWJc_8qBdzrmTowDOg.png" /></figure><p>4.We can leave the other details as it is for now. And create the resource.</p><p>5.Then go to the resource and click on the File Shares under Data Storage from the left side panel.</p><p>6.The click on the File Share button and provide a name with a Provisioned capacity</p><p>7.Then select NFS as the protocol.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*SB9DhSrKGfqdYhJaCsDDEA.png" /></figure><p>8.Afterwards click on the create and go to the resource.</p><p><a href="https://learn.microsoft.com/en-us/azure/storage/files/storage-files-quick-create-use-linux#set-up-a-private-endpoint">9.Then we have to create a private endpoint and disable secure transfer as mentioned in the Microsoft documentation</a>.</p><p>10.Then go to the Connect from linux tab and select the distribution from the drop down. Here we can go with RHEL/CentOS.</p><p>11.Connect to the VM from the command line interface and execute the command mentioned in the Azure portal to mount the NFS share.</p><p>12.When it comes to the WSO2 APIM, it’s recommended to mount the</p><ul><li><em>&lt;API-M_HOME&gt;/repository/deployment/server/synapse-configs</em></li><li><em>&lt;API-M_HOME&gt;/repository/deployment/server/executionplans</em></li><li><em>&lt;API-M_HOME&gt;/repository/resources/security/client-truststore.jks directories</em></li></ul><p>Now we have completed basic setup, and you can simply start the server by executing the wso2server.sh script from &lt;APIM-HOME&gt;/bin directory.</p><p>Hope this will help you ! See you again with another blog !</p><p>Cheers !!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb09f5a6b580" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WSO2 Data Mapper Mediator - Custom Functions]]></title>
            <link>https://medium.com/@gayathmenuka/wso2-data-mapper-mediator-custom-functions-31bb1b5a197b?source=rss-6e41d726b7d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/31bb1b5a197b</guid>
            <category><![CDATA[wso2-ei]]></category>
            <category><![CDATA[meditation]]></category>
            <category><![CDATA[wso2-mi]]></category>
            <category><![CDATA[wso2]]></category>
            <category><![CDATA[data-mapper]]></category>
            <dc:creator><![CDATA[Gayath Menuka Senevirathne]]></dc:creator>
            <pubDate>Sun, 31 Jul 2022 09:40:11 GMT</pubDate>
            <atom:updated>2022-07-31T09:40:11.188Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FLo122-XgItymf8Kn0t5rQ.jpeg" /></figure><p>WSO2 caters message transformation and translation via a wide range of mediators such as DataMapper, PayloadFactory, Enrich etc. This blog is mainly focusing on the custom functions of data mapper mediator.</p><p>Data Mapper mediator is a data mapping solution that can be integrated into a mediation sequence. This is a content-aware mediator which means the data mapper mediator always access the message content when mediation the message.It converts and transforms one data format to another, or changes the structure of the data in a message. Refer to the official WSO2 official documentation for more information [1]</p><p>It provides WSO2 Integration Studio with a graphical mapping configuration and generates the files required for executing this graphical mapping configuration through the WSO2 Data Mapper engine.</p><p>Custom functions are for catering advanced functionality which are not offered with data mapper.The data mapper uses Javascript to define the mapping configurations. To execute the generated Javascript, Java’s scripting API is used [2].</p><p>let’s see how to implement a custom function step by step.</p><ul><li>Create a new Integration Studio project.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/0*DsNvp6J3u4WjQfK9" /></figure><ul><li>For the sake of simplicity, let’s create a REST API for this demonstration.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*i-QacjAq54SpBh6B" /></figure><ul><li>Then add a data mapper mediator to the meditation simply by dragging from the palette.</li><li>Create a New Data Mapper Configuration.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/0*dTxqWqQH9LKXE19G" /></figure><ul><li>Load the Input file and output file from the file system.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eeacc0f9a8bc534a3a475682edf3bed3/href">https://medium.com/media/eeacc0f9a8bc534a3a475682edf3bed3/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/406cb002f6e24616a1a460714c853b68/href">https://medium.com/media/406cb002f6e24616a1a460714c853b68/href</a></iframe><ul><li>Then click on the APPLY button and let the AI do the mapping.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/0*pCUAZNu54doRokJ1" /></figure><ul><li>Well here comes the important part of this blog, <strong>I want to generate a random number and use it as the ID for the output file</strong>. Drag a custom function from the palette (Common tab).</li><li>Now we can implement the custom function using javascript.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/0*9BpU37vay72woKkd" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/24d3569a9352d9ede9251a7377075eca/href">https://medium.com/media/24d3569a9352d9ede9251a7377075eca/href</a></iframe><ul><li>In this example I’m using three constants to feed the above function in order generate a random alphanumeric value.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tlCJxc2CCx775IsT" /></figure><ul><li>Now we are good to go and test the implementation. Deploy this in MI or EI. I’m using MI 1.2 for this example.</li><li>Then we can invoke the API and see the response, you’ll see a random alphanumeric value has been assigned to the ID as we wanted.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cEbgQDu9H59u5Oty" /></figure><p>See you again with another blog. Cheers !!!</p><p>[1] <a href="https://ei.docs.wso2.com/en/7.2.0/micro-integrator/references/mediators/data-Mapper-Mediator/">https://ei.docs.wso2.com/en/7.2.0/micro-integrator/references/mediators/data-Mapper-Mediator/</a></p><p>[2] <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/scripting/prog_guide/api.html">https://docs.oracle.com/javase/8/docs/technotes/guides/scripting/prog_guide/api.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31bb1b5a197b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>