<?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 Nuwan Buddhika Karunarathna on Medium]]></title>
        <description><![CDATA[Stories by Nuwan Buddhika Karunarathna on Medium]]></description>
        <link>https://medium.com/@nuwankng?source=rss-7a2bbe4cdc93------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*6ltfyXH01_-RfTcPO5F9hQ.jpeg</url>
            <title>Stories by Nuwan Buddhika Karunarathna on Medium</title>
            <link>https://medium.com/@nuwankng?source=rss-7a2bbe4cdc93------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 18:44:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nuwankng/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[Running WSO2 API Manager’s Distributed Gateway Architecture Locally on Kubernetes + K8s based…]]></title>
            <link>https://medium.com/@nuwankng/running-wso2-api-managers-distributed-gateway-architecture-locally-on-kubernetes-k8s-based-5b9c465bbbbc?source=rss-7a2bbe4cdc93------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b9c465bbbbc</guid>
            <category><![CDATA[k8s-secret]]></category>
            <category><![CDATA[wso2-api-manager]]></category>
            <category><![CDATA[secure-vault]]></category>
            <dc:creator><![CDATA[Nuwan Buddhika Karunarathna]]></dc:creator>
            <pubDate>Tue, 28 Jul 2026 10:05:14 GMT</pubDate>
            <atom:updated>2026-07-28T10:09:02.301Z</atom:updated>
            <content:encoded><![CDATA[<h3>Running WSO2 API Manager’s Distributed Gateway Architecture Locally on Kubernetes + K8s based Secure Vault</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g7iWHDd2DzO5MOBTD_czvQ.png" /></figure><p>WSO2 API Manager 4.5+ splits what used to be one monolithic server into three independently scalable components: the <strong>API Control Plane</strong> (Publisher, DevPortal, Key Manager, analytics), the <strong>Traffic Manager</strong> (the throttling engine), and the <strong>Universal Gateway</strong> (the actual request-proxying data plane). Reproducing that topology locally — for debugging, testing a config change, or validating a fix before it goes back to a live environment — means getting all three talking to each other correctly, backed by a real database, on Kubernetes.</p><p>This is the log of doing that from scratch, including the parts that didn’t work the first time.</p><h3>Part 1 : From product zip to Docker image</h3><h4>The wrong way I started with</h4><p>My first attempt built custom images on top of WSO2’s pre-built registry images, layering a local product directory on top with a single COPY. It worked — but those images are often <strong>amd64-only</strong>, and on Apple Silicon that means everything runs under QEMU emulation. Boot times went from what should be single-digit seconds to <strong>four-plus minutes per component</strong>. Worse, each component runs two JVMs — the main server plus a bundled diagnostics sidecar — doubling the memory footprint right when emulation was already straining it.</p><h4>The better way: build from the official Dockerfiles</h4><p>WSO2 publishes the actual Dockerfile source at <a href="https://github.com/wso2/docker-apim/tree/4.6.x/dockerfiles/ubuntu">wso2/docker-apim</a> on GitHub. These install a Temurin JDK matching your <em>host&#39;s real architecture</em> — amd64, arm64, ppc64el, and s390x are handled explicitly in the build — and their entrypoint is a single line: sh $WSO2_SERVER_HOME/bin/&lt;component&gt;.sh. No sidecar.</p><p>Switching to this dropped boot times from minutes to seconds, running natively, with half the JVM count.</p><h4>Adapting the Dockerfile for a local pack</h4><p>The public Dockerfile wgets the GA release zip from GitHub. To use your own pack instead, swap that step for a straight COPY:</p><p>Dockerfile.acp</p><pre>FROM ubuntu:24.04<br># ... JDK install, user/group setup (unchanged from upstream) ...<br><br>COPY --chown=wso2carbon:wso2 docker-entrypoint.sh ${USER_HOME}/docker-entrypoint.sh<br>RUN chmod +x ${USER_HOME}/docker-entrypoint.sh<br>COPY --chown=wso2carbon:wso2 wso2am-acp-4.6.0 ${WSO2_SERVER_HOME}<br>COPY --chown=wso2carbon:wso2 mysql-connector-java-8.0.27.jar \<br>     ${WSO2_SERVER_HOME}/repository/components/lib/<br>RUN mkdir ${USER_HOME}/wso2-tmp \<br>    &amp;&amp; mkdir -p ${USER_HOME}/solr/{indexed-data,database} \<br>    &amp;&amp; chown wso2carbon:wso2 -R ${USER_HOME}/solr \<br>    &amp;&amp; cp -r ${WSO2_SERVER_HOME}/repository/deployment/server/executionplans \<br>          ${USER_HOME}/wso2-tmp<br>USER 10001<br>WORKDIR ${USER_HOME}<br>EXPOSE 9763 9443 9999 11111 8280 8243 5672 9711 9611 9099<br>ENTRYPOINT [&quot;/home/wso2carbon/docker-entrypoint.sh&quot;]</pre><p>Two easy-to-miss details:</p><ol><li><strong>File permissions.</strong> Anything curl&#39;d down and COPY&#39;d in loses its executable bit. Add an explicit chmod +x or the container fails at launch with permission denied.</li><li><strong>The MySQL driver isn’t in the product zip.</strong> The Control Plane and Traffic Manager both need mysql-connector-java dropped into repository/components/lib/. The Gateway doesn&#39;t — it has no direct database dependency.</li></ol><p>Build natively — no --platform flag needed when building on the same architecture as your cluster:</p><pre>docker build -f Dockerfile.acp -t local/wso2am-acp:mytag .</pre><h3>Part 2 : MySQL — the charset trap</h3><p>Point APIM at MySQL 8 and you’ll likely hit this partway through schema load:</p><p><strong>Known Issue — MySQL 8</strong></p><p>ERROR 1071 (42000): Specified key was too long; max key length is 3072 bytes</p><p>Some identity/OAuth tables (IDN_OAUTH2_TOKEN_BINDING, IDN_SCIM_GROUP, plus a performance index on IDN_INVALID_TOKENS) carry composite unique keys sized for a 1–3 byte-per-character charset. MySQL 8&#39;s default utf8mb4 is 4 bytes/char, and the combined key blows past InnoDB&#39;s 3072-byte index limit.</p><p>The fix is a prefix index — it keeps the column’s full length, only bounding what the <em>index</em> covers:</p><p><strong><em>mysql.sql — before / after</em></strong></p><pre>-- before<br>UNIQUE (TOKEN_ID, TOKEN_BINDING_TYPE, TOKEN_BINDING_VALUE)<br>-- after<br>UNIQUE (TOKEN_ID, TOKEN_BINDING_TYPE, TOKEN_BINDING_VALUE(255))</pre><p>One more trap here: if you create the database via Docker’s MYSQL_DATABASE environment variable, it&#39;s created with the <strong>server&#39;s default charset</strong> — before any CREATE DATABASE IF NOT EXISTS ... CHARACTER SET UTF8 you run afterward, since IF NOT EXISTS silently skips it. Always check:</p><pre>SELECT SCHEMA_NAME, DEFAULT_CHARACTER_SET_NAME FROM information_schema.SCHEMATA;</pre><h3>Part 3 : Deploying via Helm — and the chart bugs you’ll hit</h3><p>WSO2 publishes a Helm chart per component and you can add the same.</p><pre>helm repo add wso2 https://helm.wso2.com &amp;&amp; helm repo update</pre><p>And you can use the following commands to deploy the charts</p><pre>helm install apim-acp wso2/wso2am-acp --version 4.6.0-1 \<br>  -n wso2 --create-namespace --dependency-update -f values-acp.yaml<br><br>helm install apim-tm wso2/wso2am-tm --version 4.6.0-1 \<br>  -n wso2 --dependency-update -f values-tm.yaml<br><br>helm install apim-gw wso2/wso2am-universal-gw --version 4.6.0-1 \<br>  -n wso2 --dependency-update -f values-gw.yaml</pre><p>They work well overall, but three things are worth knowing about before you spend an afternoon debugging them as if they were yours.</p><p><strong>Bug 1 — log4j2 ConfigMap</strong></p><p>The chart’s bundled log4j2.properties ships with an invalid line:</p><pre>category.SERVICE_APPENDER._OpenService_ = TRACE_APPENDER, BOTDATA_APPENDER</pre><p>category.X.Y isn&#39;t valid Log4j2 properties syntax. It throws ConfigurationException: No type attribute provided during OSGi bootstrap — and can hang startup indefinitely rather than just log a warning. Since the base product&#39;s own file is clean, the fix is to drop the chart&#39;s ConfigMap volume mount for it entirely and let the container fall back to what&#39;s baked into the image.</p><p><strong>Bug 2 — un-escaped ampersand in JDBC URLs</strong></p><p>A JDBC URL with more than one query parameter — ?useSSL=false&amp;allowPublicKeyRetrieval=true — gets substituted verbatim into a generated master-datasources.xml. Since &amp; starts an XML entity reference, this breaks parsing outright:</p><pre>WstxUnexpectedCharException: Unexpected character &#39;=&#39;<br>  ... expected a semi-colon after the reference for entity<br>  &#39;allowPublicKeyRetrieval&#39;</pre><p>Use &amp;amp; in the source URL, not a bare &amp;.</p><h4>Resource sizing on a local dev cluster</h4><p>Default probe timeouts — 60s delay, 3×10s ≈ 90s tolerance — assume production hardware. On a resource-constrained local VM you’ll get crash-loop restarts on pods that are still legitimately booting. Bump generously during initial bring-up:</p><p><strong>values.yaml</strong></p><pre>startupProbe:<br>  periodSeconds: 15<br>  failureThreshold: 40   # ~11 minutes total tolerance</pre><p>Watch the chart’s built-in HorizontalPodAutoscaler too — under memory pressure it tries to <em>scale up</em> the Gateway, which makes the pressure worse, not better. Pin minReplicas/maxReplicas to the same value while stabilizing a new environment.</p><h3>Part 4 : Secrets — file-based secure vault for the Gateway</h3><p>Since we don’t have the shared DB connectivity from GW to Mysql as per the architecture discussed and planned in here, we want to implement a separate mechanism to persist the secure vault entries</p><p><strong>Steps are as follows</strong></p><p>Configure the enable_secure_vault = true is set in deployment.toml — as its own [apim] block, positioned <strong>before</strong> any other [apim.xxx] subsection, or TOML&#39;s implicit-table rules reject it</p><p>The vault only ever stores <strong>ciphertext</strong> — never plaintext — so the first step is producing that ciphertext with the product’s own ciphertool.sh: This is inside GW-HOME/bin directory</p><pre>./ciphertool.sh -Dorg.wso2.CipherTransformation=RSA/ECB/OAEPwithSHA1andMGF1Padding</pre><p>It prompts for the plaintext value interactively and prints back the encrypted string. That’s the value that gets stored — never the original plaintext, and never written to disk anywhere in this flow.</p><p>From here there are two ways to make that ciphertext resolvable via vault-lookup. The traditional route is registry-based: open the Carbon Console, browse to /_system/config/repository/components/secure-vault, and add a property there with the ciphertext as its value. That works, but it ties the secret to a specific node&#39;s registry rather than something you can template across a fleet of Gateway pods.</p><p>Since we’re already running on Kubernetes, the more natural fit is what Part 4 covers below: store the same ciphertext as a Kubernetes Secret and resolve it through the file vault type instead of the registry.</p><h3>Part 5: Storing and retrieving the secrets via Kubernetes</h3><p>To do this we have to mount a secret volume to every GW pod via its <strong>deployment spec</strong></p><pre>spec:<br>  template:<br>    spec:<br>      containers:<br>        - name: wso2am-universal-gw<br>          volumeMounts:<br>            - name: secure-vault<br>              mountPath: /mnt/secure-vault<br>              readOnly: true<br>      volumes:<br>        - name: secure-vault<br>          secret:<br>            secretName: ugw-secure-vault</pre><p>Plus one JVM system property: -Dei.secret.file.root.dir=/mnt/secure-vault.</p><p>Onboarding a new secret afterward needs <strong>no pod restart</strong> — Kubernetes syncs mounted Secret volumes automatically:</p><pre>kubectl patch secret ugw-secure-vault -n wso2 --type=json \<br>  -p=&#39;[{&quot;op&quot;:&quot;add&quot;,&quot;path&quot;:&quot;/data/new_alias&quot;,<br>        &quot;value&quot;:&quot;&#39;$(echo -n &#39;&lt;ciphertext&gt;&#39; | base64)&#39;&quot;}]&#39;</pre><p>One real gotcha: don’t mount individual keys via subPath — subPath mounts skip the automatic-update behavior entirely, quietly losing the whole no-restart benefit.</p><p>For genuine self-service rotation without handing out full kubectl access, scope a <strong>ServiceAccount</strong> + Role down to get/patch on just that one named Secret, then call the Kubernetes API server&#39;s REST endpoint directly with its token:</p><pre>curl -k -X PATCH \<br>  https://&lt;api-server&gt;/api/v1/namespaces/wso2/secrets/ugw-secure-vault \<br>  -H &quot;Authorization: Bearer $TOKEN&quot; \<br>  -H &quot;Content-Type: application/json-patch+json&quot; \<br>  -d &#39;[{&quot;op&quot;:&quot;add&quot;,&quot;path&quot;:&quot;/data/alias&quot;,&quot;value&quot;:&quot;&lt;base64-ciphertext&gt;&quot;}]&#39;</pre><p>wso2:vault-lookup(&#39;alias&#39;, &#39;file&#39;, &#39;true&#39;) can be backed by a plain Kubernetes Secret:</p><h3>Part 6: The full command reference</h3><p>Everything above in one runnable sequence — MySQL first, then the images, then the Helm releases, then the chart-bug patches, then the vault.</p><h3>1 — Stand up MySQL and the two databases</h3><p>shell</p><pre>kubectl create namespace wso2<br>kubectl apply -f mysql.yaml   # Deployment + Service + PVC + root-password Secret</pre><pre>kubectl exec -n wso2 deploy/mysql -- mysql -uroot -p&#39;&lt;ROOT_PASSWORD&gt;&#39; -e &quot;<br>  CREATE DATABASE IF NOT EXISTS shared_db CHARACTER SET UTF8;<br>  CREATE DATABASE IF NOT EXISTS apim_db CHARACTER SET UTF8;<br>  CREATE USER IF NOT EXISTS &#39;apimadmin&#39;@&#39;%&#39; IDENTIFIED BY &#39;apimadmin&#39;;<br>  GRANT ALL PRIVILEGES ON apim_db.* TO &#39;apimadmin&#39;@&#39;%&#39;;<br>  CREATE USER IF NOT EXISTS &#39;sharedadmin&#39;@&#39;%&#39; IDENTIFIED BY &#39;sharedadmin&#39;;<br>  GRANT ALL PRIVILEGES ON shared_db.* TO &#39;sharedadmin&#39;@&#39;%&#39;;<br>  FLUSH PRIVILEGES;&quot;</pre><pre># load the schemas — shared_db first, then the prefix-indexed apim_db one from Part 2<br>kubectl exec -i -n wso2 deploy/mysql -- mysql --force -uroot -p&#39;&lt;ROOT_PASSWORD&gt;&#39; \<br>  shared_db &lt; dbscripts/mysql.sql<br>kubectl exec -i -n wso2 deploy/mysql -- mysql --force -uroot -p&#39;&lt;ROOT_PASSWORD&gt;&#39; \<br>  apim_db &lt; dbscripts/apimgt-mysql-fixed.sql</pre><p>Run with --force the first time through a new schema — it lets the whole script run to completion and report every failing statement in one pass, instead of stopping at the first one.</p><h3>2 — Build the three images</h3><p>shell</p><pre>docker build -f Dockerfile.acp -t local/wso2am-acp:mytag .<br>docker build -f Dockerfile.tm  -t local/wso2am-tm:mytag  .<br>docker build -f Dockerfile.gw  -t local/wso2am-gw:mytag  .</pre><pre># Helm charts pin images by digest, not just tag — grab it for each<br>docker inspect local/wso2am-acp:mytag --format=&#39;{{index .RepoDigests 0}}&#39;</pre><h3>3 — Extract the keystores and create the shared secret</h3><p>shell</p><pre>mkdir -p keystores<br>docker run --rm -v &quot;$(pwd)/keystores:/keystores&quot; --entrypoint bash \<br>  local/wso2am-acp:mytag -c \<br>  &quot;cp /home/wso2carbon/wso2am-acp-4.6.0/repository/resources/security/wso2carbon.jks \<br>      /home/wso2carbon/wso2am-acp-4.6.0/repository/resources/security/client-truststore.jks \<br>      /keystores/&quot;</pre><pre>kubectl create secret generic apim-keystore-secret \<br>  --from-file=wso2carbon.jks=keystores/wso2carbon.jks \<br>  --from-file=client-truststore.jks=keystores/client-truststore.jks \<br>  -n wso2</pre><h3>4 — Deploy all three via Helm</h3><p>shell</p><pre>helm repo add wso2 https://helm.wso2.com &amp;&amp; helm repo update</pre><pre>helm install apim-acp wso2/wso2am-acp --version 4.6.0-1 \<br>  -n wso2 --create-namespace --dependency-update -f values-acp.yaml</pre><pre>helm install apim-tm wso2/wso2am-tm --version 4.6.0-1 \<br>  -n wso2 --dependency-update -f values-tm.yaml</pre><pre>helm install apim-gw wso2/wso2am-universal-gw --version 4.6.0-1 \<br>  -n wso2 --dependency-update -f values-gw.yaml</pre><h3>5 — Patch around the chart bugs</h3><p>The log4j2 volume mount from Bug 1 has to be removed from <em>every</em> deployment — ACP, TM, and Gateway — and re-removed after any subsequent helm upgrade, since Helm re-applies the chart&#39;s full template each time:</p><p>shell</p><pre># find the index of the log4j2 volumeMount first<br>kubectl get deployment apim-acp-wso2am-acp-deployment-1 -n wso2 -o json \<br>  | python3 -c &quot;<br>import json, sys<br>d = json.load(sys.stdin)<br>for i, vm in enumerate(d[&#39;spec&#39;][&#39;template&#39;][&#39;spec&#39;][&#39;containers&#39;][0][&#39;volumeMounts&#39;]):<br>    print(i, vm[&#39;name&#39;])&quot;</pre><pre># then remove that same index from both volumeMounts and volumes<br>kubectl patch deployment apim-acp-wso2am-acp-deployment-1 -n wso2 --type=json -p=&#39;[<br>  {&quot;op&quot;: &quot;remove&quot;, &quot;path&quot;: &quot;/spec/template/spec/containers/0/volumeMounts/2&quot;},<br>  {&quot;op&quot;: &quot;remove&quot;, &quot;path&quot;: &quot;/spec/template/spec/volumes/2&quot;}<br>]&#39;</pre><p>For Bugs 2 and 3 (the JDBC escaping and the Gateway’s H2 defaults), the fix lives in values-*.yaml before you ever run helm install — nothing to patch after the fact.</p><h3>6 — Secure vault: Secret and mount</h3><p>shell</p><pre>kubectl create secret generic ugw-secure-vault \<br>  --from-literal=test=&#39;&lt;ciphertext-from-ciphertool&gt;&#39; \<br>  -n wso2</pre><pre>kubectl patch deployment apim-gw-wso2am-universal-gw-deployment -n wso2 --type=json -p=&#39;[<br>  {&quot;op&quot;: &quot;add&quot;, &quot;path&quot;: &quot;/spec/template/spec/containers/0/volumeMounts/-&quot;,<br>   &quot;value&quot;: {&quot;name&quot;: &quot;secure-vault&quot;, &quot;mountPath&quot;: &quot;/mnt/secure-vault&quot;, &quot;readOnly&quot;: true}},<br>  {&quot;op&quot;: &quot;add&quot;, &quot;path&quot;: &quot;/spec/template/spec/volumes/-&quot;,<br>   &quot;value&quot;: {&quot;name&quot;: &quot;secure-vault&quot;, &quot;secret&quot;: {&quot;secretName&quot;: &quot;ugw-secure-vault&quot;}}}<br>]&#39;</pre><p>And startupArgs: &quot;-Dei.secret.file.root.dir=/mnt/secure-vault&quot; in values-gw.yaml for the JVM property, applied via the same helm upgrade as any other config change.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b9c465bbbbc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WSO2 API Manager 4.7.0 Analytics]]></title>
            <link>https://medium.com/@nuwankng/wso2-api-manager-4-7-0-analytics-aa261ab69266?source=rss-7a2bbe4cdc93------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa261ab69266</guid>
            <category><![CDATA[elk-stack]]></category>
            <category><![CDATA[wso2-api-manager]]></category>
            <category><![CDATA[analytics]]></category>
            <dc:creator><![CDATA[Nuwan Buddhika Karunarathna]]></dc:creator>
            <pubDate>Tue, 23 Jun 2026 14:16:54 GMT</pubDate>
            <atom:updated>2026-06-23T14:16:54.176Z</atom:updated>
            <content:encoded><![CDATA[<h4>Enriching APIM Analytics with Custom API and Application Metadata</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZkulDo-2tIzPj1SoQHBwsQ.png" /></figure><p><strong>01 — The Problem</strong></p><h3>Your analytics are missing business context</h3><p>When you deploy WSO2 API Manager with the ELK analytics stack, the default apim_metrics.log gives you a solid operational baseline — API name, HTTP method, response code, latency, and application name. What it doesn&#39;t give you is business context: which internal project owns this API? Which team registered the subscribing application?</p><p>Those answers live in two places that the default analytics pipeline never reads:</p><ul><li>An API custom property set by publishers in the Publisher Portal</li><li>An application custom attribute set when teams register their DevPortal applications</li></ul><p>Getting those fields into every analytics event requires no custom handler — the AnalyticsCustomDataProvider extension point does the job cleanly. This article documents exactly how, backed by source-code investigation into what data is actually available at runtime.</p><p>Target environment: WSO2 API Manager 4.7.0, ELK analytics mode (analytics.type = &quot;elk&quot;).</p><p><strong>02 — Architecture</strong></p><h3>How the analytics pipeline works</h3><p>The analytics pipeline fires after every completed API request. Understanding the sequence shows exactly where your code runs and what it can see:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DpIlSMktOo1zUPHx2Uv15g.png" /><figcaption><em>The analytics provider chain — your </em><em>CustomDataProvider is called once per request at the highlighted step</em></figcaption></figure><p>The analytics pipeline — your code runs at the highlighted node.</p><p>AnalyticsMetricsHandler fires on the response-out flow — after the full request-response cycle is complete. It creates a SynapseAnalyticsDataProvider, which calls your AnalyticsCustomDataProvider.getCustomProperties() and merges the result into the event map before it is serialized to the log.</p><p>The key point: by the time your code runs, the MessageContext is fully populated. Authentication is complete, the API entity is loaded, and subscription data is in memory. You can read anything from the context without worrying about in-flight state.</p><p><strong>03 — Approach</strong></p><h3>Analytics Custom DataProvider</h3><ul><li>Fires at publish time — outside mediation</li><li>Read-only access to a fully-populated context</li><li>Registered once in deployment.toml</li><li>Zero added latency on the request path</li><li>Right choice for: enriching analytics data</li></ul><p><strong>04 — Source Investigation</strong></p><h3>What is actually available in the MessageContext</h3><p>This is where most guides stop. “The MessageContext is available” — but which properties carry the data you need? We went to the carbon-apimgt source to find out.</p><h4>API Custom Properties</h4><p>The MessageContext carries the API’s subscription-data entity under the property key &quot;API&quot; (constant APIMgtGatewayConstants.API_OBJECT). The type is org.wso2.carbon.apimgt.keymgt.model.entity.API, and it exposes a getApiProperties() method returning a Map&lt;String, String&gt;.</p><p>This map is populated at API deployment time. In SubscriptionDataStoreImpl.java</p><pre>// At API artifact deployment, apiProperties is populated from<br>// the gateway artifact DTO&#39;s additional properties.<br>subscriptionAPI.setApiProperties(gatewayAPIDTO.getAdditionalProperties());</pre><p>Every additional property set in the Publisher Portal ends up in this map. In the implementation, the constant CUSTOM_PROPERTY_API = &quot;api-property&quot; is the key used to look up the property — rename it to match whatever property name you defined in the portal.</p><p>Lookup path: Cast messageContext.getProperty(&quot;API&quot;) to org.wso2.carbon.apimgt.keymgt.model.entity.API, then call getApiProperties().get(CUSTOM_PROPERTY_API).</p><h4>Application Custom Attributes</h4><p>The AuthenticationContext — available via APISecurityUtils.getAuthenticationContext(messageContext) — does <em>not</em> carry custom attributes. It has only the basics: applicationId, applicationUUID, applicationName, keyType.</p><p>But the gateway’s subscription data store holds a full Application entity (org.wso2.carbon.apimgt.keymgt.model.entity.Application) that does have an attributes map. This is populated from real-time key manager events.</p><p><strong>KeyManagerDataServiceImpl.java</strong></p><pre>// Application custom attributes are loaded from key manager events<br>// into the in-memory Application entity on the gateway.<br>event.getAttributes().forEach(application::addAttribute);</pre><p>The lookup path is: get the application UUID from AuthenticationContext, resolve the tenant domain from the API context, then call SubscriptionDataHolder.getInstance().getTenantSubscriptionStore(tenantDomain).getApplicationByUUID(uuid). This is an in-memory cache read — no database calls at request time.</p><p>Lookup path: Resolve tenant domain from RESTConstants.REST_API_CONTEXT, look up the Application entity by UUID, then call app.getAttributes().get(CUSTOM_PROPERTY_APPLICATION).</p><p><strong>05 — Implementation</strong></p><h3>The complete CustomDataProvider</h3><p>The class implements AnalyticsCustomDataProvider directly. The getCustomProperties() method handles both REST (Synapse MessageContext) and WebSocket (Netty ChannelHandlerContext) paths. The two new fields — &quot;api-property&quot; and &quot;application-property&quot; — are injected on the REST path only, alongside the existing tokenIssuer.</p><p>Rename CUSTOM_PROPERTY_API and CUSTOM_PROPERTY_APPLICATION to match the property and attribute names you&#39;ve defined in the portal.</p><p><strong>CustomDataProvider.java</strong></p><pre>/*<br> *  Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.<br> *<br> *  Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);<br> *  you may not use this file except in compliance with the License.<br> *  You may obtain a copy of the License at<br> *<br> *  http://www.apache.org/licenses/LICENSE-2.0<br> *<br> *  Unless required by applicable law or agreed to in writing, software<br> *  distributed under the License is distributed on an &quot;AS IS&quot; BASIS,<br> *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br> *  See the License for the specific language governing permissions and<br> *  limitations under the License.<br> *<br> */<br><br>package org.wso2.carbon.apimgt.gateway.sample.publisher;<br><br>import io.netty.channel.ChannelHandlerContext;<br>import org.apache.commons.logging.Log;<br>import org.apache.commons.logging.LogFactory;<br>import org.apache.synapse.MessageContext;<br>import org.wso2.carbon.apimgt.common.analytics.collectors.AnalyticsCustomDataProvider;<br>import org.wso2.carbon.apimgt.gateway.handlers.security.AuthenticationContext;<br>import org.wso2.carbon.apimgt.gateway.handlers.streaming.websocket.WebSocketUtils;<br><br>import org.apache.synapse.rest.RESTConstants;<br>import org.wso2.carbon.apimgt.gateway.APIMgtGatewayConstants;<br>import org.wso2.carbon.apimgt.gateway.handlers.security.APISecurityUtils;<br>import org.wso2.carbon.apimgt.keymgt.SubscriptionDataHolder;<br>import org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore;<br>import org.wso2.carbon.apimgt.keymgt.model.entity.API;<br>import org.wso2.carbon.apimgt.keymgt.model.entity.Application;<br>import org.wso2.carbon.utils.multitenancy.MultitenantConstants;<br>import org.wso2.carbon.utils.multitenancy.MultitenantUtils;<br><br>import java.util.HashMap;<br>import java.util.Map;<br><br>public class CustomDataProvider implements AnalyticsCustomDataProvider {<br><br>    private static final Log log = LogFactory.getLog(CustomDataProvider.class);<br>    private static final String SYNAPSE_TOKEN_ISSUER = &quot;issuer&quot;;<br>    private static final String ASYNC_AUTH_CONTEXT = &quot;__API_AUTH_CONTEXT&quot;;<br><br>    private static final String CUSTOM_PROPERTY_APPLICATION = &quot;application-property&quot;;<br><br>    private static final String CUSTOM_PROPERTY_API = &quot;api-property&quot;;<br><br>    public CustomDataProvider() {<br>        log.info(&quot;Successfully initialized&quot;);<br>    }<br><br>    @Override public Map&lt;String, Object&gt; getCustomProperties(Object context) {<br>        if (context instanceof MessageContext) {<br>            MessageContext mc = (MessageContext) context;<br>            Map&lt;String, Object&gt; customProperties = new HashMap&lt;&gt;();<br>            customProperties.put(&quot;tokenIssuer&quot;, getSynapseTokenIssuer(mc));<br>            customProperties.put(&quot;api-property&quot;, getApiProject(mc));<br>            customProperties.put(&quot;application-property&quot;, getApplicationProject(mc));<br>            return customProperties;<br>        }<br>        if (context instanceof ChannelHandlerContext) {<br>            Map&lt;String, Object&gt; customProperties = new HashMap&lt;&gt;();<br>            customProperties.put(&quot;tokenIssuer&quot;, getAsyncTokenIssuer((ChannelHandlerContext) context));<br>            return customProperties;<br>        }<br><br><br>        return null;<br>    }<br><br>    private String getSynapseTokenIssuer(MessageContext context) {<br><br>        if (context.getPropertyKeySet().contains(SYNAPSE_TOKEN_ISSUER)) {<br>            return (String) context.getProperty(SYNAPSE_TOKEN_ISSUER);<br>        }<br>        return null;<br>    }<br><br>    private String getAsyncTokenIssuer(ChannelHandlerContext context) {<br><br>        Object authContext = WebSocketUtils.getPropertyFromChannel(ASYNC_AUTH_CONTEXT, context);<br>        if (authContext != null &amp;&amp; authContext instanceof AuthenticationContext) {<br>            return ((AuthenticationContext)authContext).getIssuer();<br>        }<br>        return null;<br>    }<br>    private String getApiProject(MessageContext context) {<br>        Object apiObj = context.getProperty(APIMgtGatewayConstants.API_OBJECT);<br>        if (apiObj instanceof API) {<br>            Map&lt;String, String&gt; apiProperties = ((API) apiObj).getApiProperties();<br>            if (apiProperties != null) {<br>                return apiProperties.get(CUSTOM_PROPERTY_API);<br>            }<br>        }<br>        return null;<br>    }<br><br>    private String getApplicationProject(MessageContext context) {<br>        AuthenticationContext authCtx = APISecurityUtils.getAuthenticationContext(context);<br>        if (authCtx == null || authCtx.getApplicationUUID() == null) {<br>            return null;<br>        }<br>        String apiContext = (String) context.getProperty(RESTConstants.REST_API_CONTEXT);<br>        String tenantDomain = MultitenantUtils.getTenantDomainFromRequestURL(apiContext);<br>        if (tenantDomain == null) {<br>            tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;<br>        }<br>        SubscriptionDataStore store = SubscriptionDataHolder.getInstance()<br>                .getTenantSubscriptionStore(tenantDomain);<br>        if (store == null) {<br>            return null;<br>        }<br>        Application app = store.getApplicationByUUID(authCtx.getApplicationUUID());<br>        if (app != null) {<br>            return app.getAttributes().get(CUSTOM_PROPERTY_APPLICATION);<br>        }<br>        return null;<br>    }<br>}</pre><p><strong>06 — Packaging &amp; Deployment</strong></p><h3>Building, registering, and deploying</h3><h4>Maven dependencies</h4><p>The implementation requires three artifacts on the compile classpath. All must be declared as provided scope since they are already present in the product runtime.</p><p><strong>pom.xml</strong></p><pre>&lt;!-- Subscription data store entities: API, Application, SubscriptionDataHolder --&gt;<br>&lt;dependency&gt;<br>    &lt;groupId&gt;org.wso2.carbon.apimgt&lt;/groupId&gt;<br>    &lt;artifactId&gt;org.wso2.carbon.apimgt.keymgt&lt;/artifactId&gt;<br>    &lt;version&gt;${carbon.apimgt.version}&lt;/version&gt;<br>    &lt;scope&gt;provided&lt;/scope&gt;<br>&lt;/dependency&gt;</pre><pre>&lt;!-- MultitenantUtils, MultitenantConstants --&gt;<br>&lt;dependency&gt;<br>    &lt;groupId&gt;org.wso2.carbon&lt;/groupId&gt;<br>    &lt;artifactId&gt;org.wso2.carbon.utils&lt;/artifactId&gt;<br>    &lt;version&gt;${carbon.kernel.version}&lt;/version&gt;<br>    &lt;scope&gt;provided&lt;/scope&gt;<br>&lt;/dependency&gt;</pre><pre>&lt;!-- APIMgtGatewayConstants, APISecurityUtils, AuthenticationContext --&gt;<br>&lt;dependency&gt;<br>    &lt;groupId&gt;org.wso2.carbon.apimgt&lt;/groupId&gt;<br>    &lt;artifactId&gt;org.wso2.carbon.apimgt.gateway&lt;/artifactId&gt;<br>    &lt;version&gt;${carbon.apimgt.version}&lt;/version&gt;<br>    &lt;scope&gt;provided&lt;/scope&gt;<br>&lt;/dependency&gt;</pre><h3>Defining the application attribute</h3><p>Declare the custom attribute in deployment.toml so it appears in the DevPortal application registration form. The name value must match CUSTOM_PROPERTY_APPLICATION exactly.</p><p><strong>deployment.toml</strong></p><pre>[[apim.devportal.application_attributes]]<br>required    = true<br>hidden      = false<br>name        = &quot;application-property&quot;<br>description = &quot;Sample description of the attribute&quot;</pre><h3>Registering the provider</h3><p>Add the following to deployment.toml on every Gateway node, then place the built JAR in &lt;APIM_HOME&gt;/repository/components/lib/.</p><p><strong>deployment.toml</strong></p><pre>[apim.analytics]<br>enable = true<br>properties.&quot;publisher.custom.data.provider.class&quot; = &quot;org.wso2.carbon.apimgt.gateway.sample.publisher.CustomDataProvider&quot;<br>type = &quot;elk&quot;</pre><h3>Verifying the output</h3><p>After restarting APIM and invoking an API, both fields appear in apim_metrics.log on every matching request:</p><p><strong>apim_metrics.log</strong></p><pre>16:45:28,585 [-] [PassThroughMessageProcessor-4]  INFO ELKCounterMetric apimMetrics: apim:response, properties :{&quot;apiName&quot;:&quot;PizzaShackAPI&quot;,&quot;proxyResponseCode&quot;:200,&quot;destination&quot;:&quot;https://localhost:9443/am/sample/pizzashack/v1/api/&quot;,&quot;apiCreatorTenantDomain&quot;:&quot;carbon.super&quot;,&quot;platform&quot;:&quot;Other&quot;,&quot;apiMethod&quot;:&quot;GET&quot;,&quot;apiVersion&quot;:&quot;1.0.0&quot;,&quot;gatewayType&quot;:&quot;SYNAPSE&quot;,&quot;apiCreator&quot;:&quot;admin&quot;,&quot;responseCacheHit&quot;:false,&quot;backendLatency&quot;:14,&quot;correlationId&quot;:&quot;334545c8-f9a3-48c7-a0e0-81c1010575f9&quot;,&quot;requestMediationLatency&quot;:5,&quot;keyType&quot;:&quot;SANDBOX&quot;,&quot;apiId&quot;:&quot;03778d8a-8502-4787-ab2a-1e5ba65bc409&quot;,&quot;applicationName&quot;:&quot;Test&quot;,&quot;targetResponseCode&quot;:200,&quot;requestTimestamp&quot;:&quot;2026-06-23T11:15:28.564Z&quot;,&quot;applicationOwner&quot;:&quot;admin&quot;,&quot;userAgent&quot;:&quot;PostmanRuntime&quot;,&quot;userName&quot;:&quot;admin@carbon.super&quot;,&quot;apiResourceTemplate&quot;:&quot;/menu&quot;,&quot;regionId&quot;:&quot;default&quot;,&quot;responseLatency&quot;:20,&quot;responseMediationLatency&quot;:1,&quot;userIp&quot;:&quot;127.0.0.1&quot;,&quot;apiContext&quot;:&quot;/pizzashack/1.0.0&quot;,&quot;applicationId&quot;:&quot;d17fcd16-c64f-4b60-9067-eca8a27bae44&quot;,&quot;apiType&quot;:&quot;HTTP&quot;,&quot;properties&quot;:{&quot;tokenIssuer&quot;:&quot;https://localhost:9443/oauth2/token&quot;,&quot;commonName&quot;:&quot;N/A&quot;,&quot;isGuardrailHit&quot;:false,&quot;responseContentType&quot;:&quot;application/json&quot;,&quot;subtype&quot;:&quot;DEFAULT&quot;,<br>&quot;application-property&quot;:&quot;application-test&quot;,&quot;isEgress&quot;:false,<br>&quot;api-property&quot;:&quot;api-test&quot;,&quot;apiContext&quot;:&quot;/pizzashack/1.0.0&quot;,<br>&quot;responseSize&quot;:0,&quot;userName&quot;:&quot;admin@carbon.super&quot;,&quot;requestSize&quot;:-1}}</pre><p>Final Thoughts</p><h3>The extension point is simple. Knowing what’s inside it is not.</h3><p>The AnalyticsCustomDataProvider interface is deliberately minimal — one method, one Object parameter. That simplicity is deceptive. The MessageContext at analytics time is fully populated with auth context, API metadata, subscription data, and endpoint information. Knowing where each piece lives is the hard part; writing the extension itself is straightforward.</p><p>Both data points are available in memory at the gateway, without any database calls:</p><ul><li>API custom properties — via the API entity at messageContext.getProperty(APIMgtGatewayConstants.API_OBJECT)</li><li>Application custom attributes — via the Application entity in SubscriptionDataHolder, looked up by UUID from AuthenticationContext</li></ul><p>The constants CUSTOM_PROPERTY_API = &quot;api-property&quot; and CUSTOM_PROPERTY_APPLICATION = &quot;application-property&quot; in the implementation are placeholders. Rename them to match the exact property and attribute names you have defined in your environment. The lookup logic is the same regardless of naming.</p><h3>References</h3><ol><li><a href="https://apim.docs.wso2.com/en/latest/monitoring/api-analytics/samples/publishing-custom-analytics-data/#publishing-custom-analytics-events-data">Publishing Custom Analytics Events Data</a></li><li><a href="https://github.com/wso2/samples-apim/blob/master/analytics-custom-data-provider/src/main/java/org/wso2/carbon/apimgt/gateway/sample/publisher/CustomDataProvider.java">Writing Custom Analytics Publishers</a></li><li><a href="https://apim.docs.wso2.com/en/latest/api-developer-portal/manage-application/advanced-topics/add-custom-attributes-to-applications/">Add Custom Attributes to Applications</a></li><li><a href="https://github.com/wso2/carbon-apimgt">carbon-apimgt source</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa261ab69266" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configure ForgeRock as a KeyManager in WSO2 APIM]]></title>
            <link>https://medium.com/@nuwankng/configure-forgerock-as-a-keymanager-in-wso2-apim-c25e9b93eb4f?source=rss-7a2bbe4cdc93------2</link>
            <guid isPermaLink="false">https://medium.com/p/c25e9b93eb4f</guid>
            <category><![CDATA[tomcat]]></category>
            <category><![CDATA[forgerock]]></category>
            <category><![CDATA[wso2-api-manager]]></category>
            <category><![CDATA[external-key-manager]]></category>
            <category><![CDATA[configuration]]></category>
            <dc:creator><![CDATA[Nuwan Buddhika Karunarathna]]></dc:creator>
            <pubDate>Sat, 22 Feb 2025 12:36:02 GMT</pubDate>
            <atom:updated>2025-02-22T12:37:43.037Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Q1Kz9o0mSfyJbqK2hVu-Q.png" /></figure><p>You might have tried to setup Forgerock as a Keymanager for WSO2 APIM and had issue regarding the configuration.</p><p>In this medium let’s check how we can correctly configure Forgerock Keymanager as a Keymanager for WSO2 APIM. I’m lazy so I will use <strong>FR</strong> for Forgerock and <strong>KM</strong> for the Keymanager. :D</p><p>First let’s see how you can configure FR side with the required configuration. The biggest problem I had is getting various errors when starting the FR with VM based tomcat server.</p><p>This lead me to setup FR in a docker container. Here is the<strong> Dockerfile</strong> I used.</p><pre># Use Tomcat 9 with OpenJDK 11<br>FROM tomcat:9.0.48-jdk11-openjdk-slim<br><br># Copy WAR file into Tomcat webapps directory<br>COPY AM-7.1.0.war /usr/local/tomcat/webapps/<br><br># Set Java options (optional, for performance tuning)<br>ENV JAVA_OPTS=&quot;-Xmx512m -Xms256m&quot;<br><br># Expose Tomcat port<br>EXPOSE 8080<br><br># Start Tomcat<br>CMD [&quot;catalina.sh&quot;, &quot;run&quot;]</pre><p>Then used the following commands to build and run the docker image containing FR.</p><pre>docker build -t forgerock .<br><br>docker run -p 8080:8080 forgerock</pre><p>Here I already downloaded a AM-7.1.0.war file which contains a webapp that can be deployed on a tomcat server. Please use tomcat version of 9.0.x with JDK 11 or lower as I got some compatibility issue with higher JDK versions. The tomcat:9.0.48-jdk11-openjdk-slim I used is already available in the <strong>hub.docker.com</strong>.</p><p>If everything is correct then you should be able to access the FR console by accessing the following URL. Your one might be bit changed.</p><pre>http://localhost:8080/AM-7.1.0/</pre><p>Now you have to setup the server. Just use the default configuration option and you will be good in no time. Just remember the password that you have used for the <strong>amAdmin</strong> user.</p><p>After the intial setup is done login to the console using the above provided amAdmin username and its password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XOK6AqgrK3wo9lSZkrriRA.png" /><figcaption>Login Window</figcaption></figure><p>Then choose the top realm and configure the Oauth2 provider like in the screenshots below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2hXQ3FJ7Uy1ts5zZunVRhQ.png" /><figcaption>Top level realm</figcaption></figure><p>Since by default there is no service provider you have to go to the<strong> Services &gt; oauth2 provider </strong>option under the selected top level realm and create a new service provider.</p><p>Once created configure the <strong>oauth2 provider </strong>as shown in the below screenshot. Every config is mandatory here in order to correctly work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mI0laZKfuZD77gAcoaJNHg.png" /><figcaption>OAuth2 provider core configuration</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m6J4pL_0pJv7UxwtV-UTRw.png" /><figcaption>OAuth2 provider advanced configuration</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RXmq8Yd1S9TqPqTudAFf4A.png" /><figcaption>OAuth2 provider DCR configuration</figcaption></figure><p>That’s it for the OAuth2 provider configuration.</p><p>Now we need to create a client which will be used as the service provider for WSO2 APIM. This client will be used as the communication channel between APIM and FR.</p><p>Go to the <strong>Applications &gt; OAuth 2.0 &gt; Clients </strong>section and create new client using <strong>Add Client</strong> option. I have created a client named <strong>test</strong> and here’s how it looks like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*40aEC44qR56vaFTnPuMXrA.png" /><figcaption>Client core configuration</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LKGtPpTMwekvQOu6B3RD8w.png" /><figcaption>Client advanced configuration</figcaption></figure><p>Now we have completed the configuration on the FR side and let’s move to the WSO2 APIM. All the configuration should be done in the Admin portal of WSO2 APIM. You can find detailed information in the official documentation [1].</p><p>Here I have used the<strong> .well-known endpoin</strong>t of FR to fill all the configurations in the Admin portal under the newly created KM. Here’s the URL I used.</p><pre>http://localhost:8080/AM-7.1.0/oauth2/.well-known/openid-configuration</pre><p>Please refer the screenshot on how mine looks like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qy0MRGWNIR3FwqGwxCeZ3w.png" /><figcaption>KM configurations</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*de9XiQ-qPPNCaSuz3Enybw.png" /><figcaption>KM configuration continued ..</figcaption></figure><p>Now here under the connector configuration, you have to provide the credentials of the test client we have created above. Stick to the same configuration so you will not get any issue.</p><p>Now all the things are completed and You can generate new keys using the FR KM you just created on the Admin portal using the devportal.</p><p><strong>Side Note</strong> : If you need to provide already existing client credentials from FR, then add the following to the <strong>deployment.toml</strong> file and restart.</p><pre>[apim.devportal]<br>enable_key_provisioning = true</pre><p>If you got any error on the while loading the application on the devportal please use the following configuration so that it will not validate the credentials provided using the above key_provisioning option.</p><pre>[apim.key_manager]<br>enable_provisioned_app_validation = false</pre><p>That’s it. Comments are welcome.</p><p>Cheers !!!!!!!!!!!!!!!!!!!</p><p>[1]. <a href="https://apim.docs.wso2.com/en/4.2.0/administer/key-managers/configure-forgerock-connector/">https://apim.docs.wso2.com/en/4.2.0/administer/key-managers/configure-forgerock-connector/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c25e9b93eb4f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrate Application Credentials Between WSO2 APIM versions]]></title>
            <link>https://medium.com/@nuwankng/migrate-application-credentials-between-wso2-apim-versions-4d6211d69d2b?source=rss-7a2bbe4cdc93------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d6211d69d2b</guid>
            <category><![CDATA[client-credentials]]></category>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[application]]></category>
            <category><![CDATA[service-provider]]></category>
            <category><![CDATA[wso2-api-manager]]></category>
            <dc:creator><![CDATA[Nuwan Buddhika Karunarathna]]></dc:creator>
            <pubDate>Thu, 13 Feb 2025 10:01:50 GMT</pubDate>
            <atom:updated>2025-02-13T10:09:45.728Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZcBdrs5uImL5DTyKECWrWw.jpeg" /></figure><p>Have you ever come across a scenario where you want to keep the existing client credentials for the subscribed applications from the older WSO2 APIM version (<strong>APIM 2.6.0, APIM 3.2.0</strong> etc) when you are planning to upgrade to a latest version of WSO2 APIM such as APIM 4.3.0 ?</p><p>Then you are at the correct place to find out how it’s done.</p><p>Basically the above requirement will arise when you want to create a fresh deployment of WSO2 APIM pack with the same application credentials as the older APIM version. If you are executing a proper data migration from the older version to the new version of APIM, then you don’t need to worry about this as it has already been covered.</p><p>Now let’s progress with the initial requirement. For this exercise we are going to use APIM 2.6.0 and APIM 4.3.0 version.</p><p>When you created an application in the APIM 2.6.0 this is how you can see it in the store portal and carbon console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pLRgxaWh04-IzF4W3PuX3Q.png" /><figcaption>API Store APIM 2.6.0</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qCYwAwNHSG4GXHXkq6doSA.png" /><figcaption>Carbon Console APIM 2.6.0</figcaption></figure><p>As the next step you want to get the same credentials (Client ID and Secret) and make a new application in the APIM 4.3.0 version using the same.</p><p>Before going further you need to add the following configuration under the <strong>deployment.toml </strong>file in the <strong>APIM-HOME/repository/conf </strong>directory.</p><blockquote><strong>[apim.devportal]</strong></blockquote><blockquote><strong>enable_key_provisioning = true</strong></blockquote><p>Enabling this will enable you to provision the existing client credentials to the applications created on the devportal. If the configuration is successfully added then you can see the following option enabled for the application created on the devportal. But in order to have this option enabled you shouldn’t have already generated the keys.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tU3kclK16wktt7npo0Kqaw.png" /><figcaption>Provide Existing Keys Option</figcaption></figure><p>Ideally this <strong>Provide Existing OAuth Keys </strong>option is used to configure applications (Service Providers) which are already created on the carbon console [1].</p><p>However we are not going to use this UI and do it with the rest APIs exposed in the WSO2 APIM. You can read more information about those APIs here [2]. Here we are using the devportal rest APIs [3].</p><p>First you need to obtain the consumer key/secret key pair by calling the dynamic client registration (DCR) endpoint. Below is an example payload.</p><pre>curl -X POST -H &quot;Authorization: Basic YWRtaW46YWRtaW4=&quot;<br> -H &quot;Content-Type: application/json&quot; https://localhost:9443/client-registration/v0.17/register - data &#39; {<br>&quot;callbackUrl&quot;:&quot;www.google.lk&quot;,<br>&quot;clientName&quot;:&quot;rest_api_devportal&quot;,<br>&quot;owner&quot;:&quot;admin&quot;,<br>&quot;grantType&quot;:&quot;client_credentials password refresh_token&quot;,<br>&quot;saasApp&quot;:true<br>}&#39;</pre><p>Sample response would be as follows.</p><pre>{<br>&quot;clientId&quot;: &quot;5rYCmFqoY4a20qfRoxHiRqYWm84a&quot;,<br>&quot;clientName&quot;: &quot;rest_api_devportal&quot;,<br>&quot;callBackURL&quot;: &quot;www.google.lk&quot;,<br>&quot;clientSecret&quot;: &quot;FQjN5OfM6nByOa3Mr8oWYmfWUKYa&quot;,<br>&quot;isSaasApplication&quot;: true,<br>&quot;appOwner&quot;: &quot;admin&quot;,<br>&quot;jsonString&quot;: &quot;{\&quot;grant_types\&quot;:\&quot;client_credentials password refresh_token\&quot;,\&quot;redirect_uris\&quot;:\&quot;www.google.lk\&quot;,\&quot;client_name\&quot;:\&quot;rest_api_devportal\&quot;}&quot;,<br>&quot;jsonAppAttribute&quot;: &quot;{}&quot;,<br>&quot;applicationUUID&quot;: null,<br>&quot;tokenType&quot;: &quot;DEFAULT&quot;<br>}</pre><p>Here a service provider will be created on the carbon console with the name<strong> rest_api_devportal</strong>. This service provider will be used to authenticate with the APIM to use the rest APIs which are protected by oauth2 security.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LCqsF2CcOCTrTnWWO8FBdw.png" /><figcaption>rest_api_devportal service provider</figcaption></figure><p>Next you must use the above client id and secret to obtain the <strong>access token</strong>. We will be using the password grant type for this, you can use any grant type you desire. You also need to add the proper <strong>scopes</strong> when getting the access token[3]. Below is an example.</p><pre>curl - location &#39;https://localhost:9443/oauth2/token&#39; \<br>- header &#39;Authorization: Basic NXJZQ21GcW9ZNGEyMHFmUm94SGlScVlXbTg0YTpGUWpONU9mTTZuQnlPYTNNcjhvV1ltZldVS1lh&#39; \<br>- header &#39;Content-Type: application/json&#39; \<br>- data &#39;{&quot;grant_type&quot;:&quot;password&quot;,&quot;username&quot;:&quot;admin&quot;,&quot;password&quot;:&quot;admin&quot;,&quot;scope&quot;:&quot;apim:admin apim:api_key apim:app_import_export apim:app_manage apim:store_settings apim:sub_alert_manage apim:sub_manage apim:subscribe openid apim:subscribe&quot;}&#39;</pre><p>Here Authorization header is having a <strong>base64 encoded version</strong> of the <strong>clientID:ClientSecret </strong>of the response from the initial request. As an example.</p><pre>Authorization: Basic Base64Encoded(5rYCmFqoY4a20qfRoxHiRqYWm84a:FQjN5OfM6nByOa3Mr8oWYmfWUKYa)</pre><p>Then you will get a response like below containing the access token which will be used for the next steps.</p><pre>{<br>&quot;access_token&quot;: &quot;d66edd7a-78b4–3d8c-9dcb-dc9b7b18f305&quot;,<br>&quot;refresh_token&quot;: &quot;4dde5464-d5f9–3c86–91d3-fa2f86955f84&quot;,<br>&quot;scope&quot;: &quot;apim:admin apim:api_key apim:app_import_export apim:app_manage apim:store_settings apim:sub_alert_manage apim:sub_manage apim:subscribe openid&quot;,<br>&quot;id_token&quot;: &quot;eyJ4NXQiOiJNek5rWmpVM1ltWmhaRGRpTkRabVpHVTJabVJsT1RoaE9XVXpOV0UzTWpRNFpERmpOV1k0TXciLCJraWQiOiJPREJtTVRVMFpqSmpPREprTkdZMVpUaG1ZamsyWVRZek56UmpZekl6TVRCbFlqRTBNV0prWTJJeE5qZzNPRGRqWVdRNVpXWmhOV0kwTkRBM1pqTTROUV9SUzI1NiIsImFsZyI6IlJTMjU2In0.eyJhdF9oYXNoIjoiOEIyZ0NTdE92cmxCNGhwYTgzQTdCUSIsImF1ZCI6IjVyWUNtRnFvWTRhMjBxZlJveEhpUnFZV204NGEiLCJzdWIiOiJhZG1pbiIsIm5iZiI6MTczOTQzODgxNywiYXpwIjoiNXJZQ21GcW9ZNGEyMHFmUm94SGlScVlXbTg0YSIsImFtciI6WyJwYXNzd29yZCJdLCJpc3MiOiJodHRwczovL2xvY2FsaG9zdDo5NDQzL29hdXRoMi90b2tlbiIsImV4cCI6MTczOTQ0MjQxNywiaWF0IjoxNzM5NDM4ODE3LCJqdGkiOiIwYzMzMWM2My01Y2ZiLTRkNzgtYmI3Ni1jNzZhYWFiMWI1NzMifQ.bCH2UUZ6zta9ItTwQrT28ok-DoXboYwEoDXotf2BMoMUU5Jr4Btw1FLPjTx5rwi4ijHpvrrAwHOSQrELNEyBVSgBOXawhqPhJGZIBh8zbbJgxddFK9gI90mpRWgXaWmOZD_rRz_3EevWgx_za2v3nef6A5vo50xD_rMMszT41tEfDzhJrX7izwP9a8Rdf2xZjWbpiDUQcckOatMz5MMrpoR4IEuEAh3WOXIscMJLFOxU4Z-IjxAKrZCVmXsNsEL4IOTkM0nb9-MeFEhnNYSRA_YJ91uClnImeFDQsIh_UWjtucuPbR_bIcyYef4hsdN_Y3MiBWneFMLaRQWWORi2UA&quot;,<br>&quot;token_type&quot;: &quot;Bearer&quot;,<br>&quot;expires_in&quot;: 3600<br>}</pre><p>Using the access token you got from the above command, you can create an application in the Devportal using the below command.</p><pre>curl - location &#39;https://localhost:9443/api/am/devportal/v3/applications&#39; \<br>- header &#39;authorization: Bearer d66edd7a-78b4–3d8c-9dcb-dc9b7b18f305&#39; \<br>- header &#39;content-type: application/json&#39; \<br>- data &#39;{<br>&quot;name&quot;: &quot;TestApp0115&quot;,<br>&quot;throttlingPolicy&quot;: &quot;Unlimited&quot;,<br>&quot;description&quot;: &quot;Sample Test application&quot;,<br>&quot;tokenType&quot;: &quot;JWT&quot;,<br>&quot;groups&quot;: [],<br>&quot;attributes&quot;: {},<br>&quot;subscriptionScopes&quot;: []<br>}&#39;</pre><p>Response as follows.</p><pre>{<br>&quot;applicationId&quot;: &quot;cbf0e917–9ed2–4deb-a943-af8e92e8b9a9&quot;,<br>&quot;name&quot;: &quot;TestApplication&quot;,<br>&quot;throttlingPolicy&quot;: &quot;Unlimited&quot;,<br>&quot;description&quot;: &quot;Sample Test application&quot;,<br>&quot;tokenType&quot;: &quot;JWT&quot;,<br>&quot;status&quot;: &quot;APPROVED&quot;,<br>&quot;groups&quot;: [],<br>&quot;subscriptionCount&quot;: 0,<br>&quot;keys&quot;: [],<br>&quot;attributes&quot;: {},<br>&quot;subscriptionScopes&quot;: [],<br>&quot;owner&quot;: &quot;admin&quot;,<br>&quot;hashEnabled&quot;: null,<br>&quot;createdTime&quot;: &quot;1739438994090&quot;,<br>&quot;updatedTime&quot;: &quot;1739438994090&quot;<br>}</pre><p>Generate the Keys Providing the existing Keys from the APIM-2.6.0 environment[5]. ( Application_ID can be retrieved from the response of the above step Ex : cbf0e917–9ed2–4deb-a943-af8e92e8b9a9)</p><pre>curl - location &#39;https://localhost:9443/api/am/devportal/v3/applications/&lt;Application_ID&gt;/generate-keys&#39; \<br>- header &#39;authorization: Bearer d66edd7a-78b4–3d8c-9dcb-dc9b7b18f305&#39; \<br>- header &#39;content-type: application/json&#39; \<br>- data &#39;{<br>&quot;keyType&quot;: &quot;PRODUCTION&quot;,<br>&quot;keyManager&quot;: &quot;Resident Key Manager&quot;,<br>&quot;grantTypesToBeSupported&quot;: [<br>&quot;password&quot;,<br>&quot;client_credentials&quot;<br>],<br>&quot;callbackUrl&quot;: &quot;https://client.example.org/callback&quot;,<br>&quot;scopes&quot;: [<br>&quot;am_application_scope&quot;,<br>&quot;default&quot;<br>],<br>&quot;clientId&quot;: &quot;UjeQCPWzL3YxQJYcBYE5cJKtjaIa&quot;,<br>&quot;clientSecret&quot;: &quot;YUmyY53KUafYsgwDIvztwkedATMa&quot;,<br>&quot;additionalProperties&quot;: {}<br>}&#39;</pre><p>Response as follows.</p><pre>{<br>    &quot;keyMappingId&quot;: &quot;c8c01d8d-7a68-48f0-89f8-a87521295081&quot;,<br>    &quot;keyManager&quot;: &quot;Resident Key Manager&quot;,<br>    &quot;consumerKey&quot;: &quot;UjeQCPWzL3YxQJYcBYE5cJKtjaIa&quot;,<br>    &quot;consumerSecret&quot;: &quot;YUmyY53KUafYsgwDIvztwkedATMa&quot;,<br>    &quot;supportedGrantTypes&quot;: [<br>        &quot;password&quot;,<br>        &quot;client_credentials&quot;<br>    ],<br>    &quot;callbackUrl&quot;: &quot;https://client.example.org/callback&quot;,<br>    &quot;keyState&quot;: &quot;APPROVED&quot;,<br>    &quot;keyType&quot;: &quot;PRODUCTION&quot;,<br>    &quot;mode&quot;: &quot;CREATED&quot;,<br>    &quot;groupId&quot;: null,<br>    &quot;token&quot;: {<br>        &quot;accessToken&quot;: &quot;eyJ4NXQiOiJNek5rWmpVM1ltWmhaRGRpTkRabVpHVTJabVJsT1RoaE9XVXpOV0UzTWpRNFpERmpOV1k0TXciLCJraWQiOiJPREJtTVRVMFpqSmpPREprTkdZMVpUaG1ZamsyWVRZek56UmpZekl6TVRCbFlqRTBNV0prWTJJeE5qZzNPRGRqWVdRNVpXWmhOV0kwTkRBM1pqTTROUV9SUzI1NiIsInR5cCI6ImF0K2p3dCIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiJjMDdjNTZiYS1kMjM0LTRlYmQtYTZlZC02YjM5MmFhZjE5ZDciLCJhdXQiOiJBUFBMSUNBVElPTiIsImF1ZCI6IlVqZVFDUFd6TDNZeFFKWWNCWUU1Y0pLdGphSWEiLCJuYmYiOjE3Mzk0MzkxNzksImF6cCI6IlVqZVFDUFd6TDNZeFFKWWNCWUU1Y0pLdGphSWEiLCJzY29wZSI6ImFtX2FwcGxpY2F0aW9uX3Njb3BlIGRlZmF1bHQiLCJpc3MiOiJodHRwczovL2xvY2FsaG9zdDo5NDQzL29hdXRoMi90b2tlbiIsImV4cCI6MTczOTQ0Mjc3OSwiaWF0IjoxNzM5NDM5MTc5LCJqdGkiOiJkYWU2Y2Y5Yi1lYzJlLTRjMDctYmMwZi04ODAyYTRmMjUwMzMiLCJjbGllbnRfaWQiOiJVamVRQ1BXekwzWXhRSlljQllFNWNKS3RqYUlhIn0.N20XddcaF7qymnQ9OeOPOp6W4wZRQqfDWlBGv6Kh2lRWp9j6bE9TolaVDna8HAWYWdR5aYmLphujWGmLvgxGGURYuJc1-sc_tFJwKaUvLsNHbzbjWou2bMhphtePGjFiM1iOUHvK_W87j5rkjdVN6XlS58ZdEhbLNjTt6Q_fvfzfME2YR6ly7f-lPrEzUVgdRqHrfrmoOrvSDDg_r1jx7MROtv2lxmN5aBsgr3aCUAo_k9QaP1_l49Cijn1Nmm_I819TCv48jdm1dudIiupVh7Xe-IXF_OI75PyzP8kg6H_QuG_OELxZyCKURWic_OaeZq3xKPP1a_ZXZcZZ3QGx5Q&quot;,<br>        &quot;tokenScopes&quot;: [<br>            &quot;am_application_scope&quot;,<br>            &quot;default&quot;<br>        ],<br>        &quot;validityTime&quot;: 3600<br>    },<br>    &quot;additionalProperties&quot;: {<br>        &quot;id_token_expiry_time&quot;: 3600,<br>        &quot;application_access_token_expiry_time&quot;: 3600,<br>        &quot;user_access_token_expiry_time&quot;: 3600,<br>        &quot;bypassClientCredentials&quot;: false,<br>        &quot;pkceMandatory&quot;: false,<br>        &quot;pkceSupportPlain&quot;: false,<br>        &quot;refresh_token_expiry_time&quot;: 86400<br>    }<br>}</pre><p>Now go to the devportal and check for an application named <strong>TestApplication.</strong> You will see a similar screen as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ldvQKXw5Nn_-dO8pp2lRLQ.png" /><figcaption>Generated Application</figcaption></figure><p>That’s it. Now you have created an application which has the same credentials as the APIM 2.6.0 version.</p><p>Hope this helps for your experiments with WSO2 APIM. Until next time Good Byeee …. :D</p><p>[1]. <a href="https://apim.docs.wso2.com/en/4.3.0/design/api-security/oauth2/provisioning-out-of-band-oauth-clients/">https://apim.docs.wso2.com/en/4.3.0/design/api-security/oauth2/provisioning-out-of-band-oauth-clients/</a><br>[2]. <a href="https://apim.docs.wso2.com/en/4.3.0/reference/product-apis/overview/">https://apim.docs.wso2.com/en/4.3.0/reference/product-apis/overview/</a><br>[3]. <a href="https://apim.docs.wso2.com/en/4.3.0/reference/product-apis/devportal-apis/devportal-v3/devportal-v3/">https://apim.docs.wso2.com/en/4.3.0/reference/product-apis/devportal-apis/devportal-v3/devportal-v3/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d6211d69d2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configure OKTA as a Keymanager on WSO2 APIM 4.2.0]]></title>
            <link>https://medium.com/@nuwankng/configure-okta-as-a-keymanager-on-wso2-apim-4-2-0-03c4502676a3?source=rss-7a2bbe4cdc93------2</link>
            <guid isPermaLink="false">https://medium.com/p/03c4502676a3</guid>
            <category><![CDATA[okta]]></category>
            <category><![CDATA[wso2-api-manager]]></category>
            <category><![CDATA[key-manager]]></category>
            <dc:creator><![CDATA[Nuwan Buddhika Karunarathna]]></dc:creator>
            <pubDate>Mon, 04 Mar 2024 08:34:48 GMT</pubDate>
            <atom:updated>2024-03-04T08:34:48.957Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi All, In this blog I’m going to explain how you can configure OKTA as Keymanager with WSO2 APIM 4.2.0.</p><p>First let’s see how to do the configuration on OKTA.</p><p>We need to have a account in OKTA to begin with. I used to sign up with google So I don’t have to remember the passwords :D</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t2YiOGsQxO6jiy1CKDKjlQ.png" /></figure><p>Upon the successful signup you will get a developer URL which we will be using as the OKTA url in APIM.</p><p>Ex : dev-44472653.okta.com</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4n85yAH5xb5JGQ-_1pW4gw.png" /></figure><p>Then we need to go to the Security &gt; API section in the left pane to access the authorization servers. Here you can add a different authorization server or use the default one. I’m going with the default one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZgJXgq5X95RRF5P7Pfu9bw.png" /></figure><p>Here you need to select the authorization server and then under the scopes section you need to define a new scope called default and then mark it to be included as a default scope.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IfYRFF5Ksd2x8ht6Ze-zTw.gif" /></figure><p>Then we need to create a token. In the same authorization server select the <strong>Tokens</strong> section and add a new token by giving a name. Please note that you have a save this generated token as it cannot be viewed later and you need it to configure the APIM section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*By6IMbE1K1gEzNrGwXDFyg.gif" /></figure><p>Okay. That is done. Now we have to create a policy for the same authorization server and then add a rule. Select the authorization server &gt; access policies. Create a policy and add a new rule. I have kept the default as it is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B1cKWIb8xuLJJ49hBrOeUg.gif" /></figure><p>Then we are going to create a service provider which is a integration web application. This will be used by APIM to connect with the OKTA. Go to the <strong>Applications</strong> &gt; <strong>Create App Integration</strong> in the left pane.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fNz-ZeekdSSo68tCEJVoLQ.gif" /></figure><p>You have to save the client credentials here as they need to be added on the APIM side.</p><p>Apart from this you need to get the well know endpoint for the Authorization Server. You can find it in the settings tab on the Authorization Server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SGOxfkeC5rXztXUe4alVOA.png" /></figure><p>Now OKTA side configuration is done and we need to configure the APIM.</p><p>You can refer the official documentation [1] on configuring the APIM side. I’m not going to mention it here as it was well described over there.</p><p>Let me know any suggestions. Cheers !!!!!!!!!!!</p><p>[1]. <a href="https://apim.docs.wso2.com/en/latest/administer/key-managers/configure-okta-connector/#step-2-configure-wso2-api-manager">https://apim.docs.wso2.com/en/latest/administer/key-managers/configure-okta-connector/#step-2-configure-wso2-api-manager</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=03c4502676a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Read .xlsx file through WSO2 MI 4.2.0 using Data Service]]></title>
            <link>https://medium.com/@nuwankng/how-to-read-xlsx-file-through-wso2-mi-4-2-0-using-data-service-4919cabad0df?source=rss-7a2bbe4cdc93------2</link>
            <guid isPermaLink="false">https://medium.com/p/4919cabad0df</guid>
            <category><![CDATA[excel]]></category>
            <category><![CDATA[data-services]]></category>
            <category><![CDATA[micro-integrator]]></category>
            <category><![CDATA[integration]]></category>
            <category><![CDATA[wso2]]></category>
            <dc:creator><![CDATA[Nuwan Buddhika Karunarathna]]></dc:creator>
            <pubDate>Sun, 26 Nov 2023 08:06:21 GMT</pubDate>
            <atom:updated>2023-11-26T08:06:21.321Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Read .xlsx file through WSO2 MI 4.2.0 using Data Service</h3><p>Hi All, In this blog I’m going to guide you on how you can use the <strong>Data Service</strong> function to read <strong>.xlsx</strong> files and manipulate the content as per your need.</p><p>First in the Integration Studio you need to create a new <strong>Integration Project</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LidE3c9TNrmehIJO8OGn9w.png" /><figcaption>Integration Project</figcaption></figure><p>As you can see I have enabled the option to include <strong>Data Service Configs</strong> in this project. Next you need to create a new <strong>Data Service</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PTcD36Ts73lt8zR4ILYA-A.png" /><figcaption>Data Service</figcaption></figure><p>After you have given a name the Design view of the Data Service Config will be shown. Use the bottom option to switch this to <strong>source view</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uHT9o6hujI9tCn3mHUQHYA.png" /><figcaption>Source View</figcaption></figure><p>I have used the following Service to read a .xlsx file which resides in the file system.</p><p><strong>Sample xlsx file</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ctQv55WPG2Z5pN5GsExwXw.png" /><figcaption>.xlsx content</figcaption></figure><pre>&lt;data name=&quot;ExcelDataService&quot; serviceNamespace=&quot;&quot; serviceGroup=&quot;&quot; transports=&quot;http https local&quot;&gt;<br>  &lt;config enableOData=&quot;false&quot; id=&quot;Excel001&quot;&gt;<br>      &lt;property name=&quot;driverClassName&quot;&gt;org.wso2.micro.integrator.dataservices.sql.driver.TDriver&lt;/property&gt;<br>      &lt;property name=&quot;url&quot;&gt;jdbc:wso2:excel:filePath=/Users/nuwankarunarathna/IntegrationStudio/8.2.0/workspace/ReadExcel/Test1.xlsx&lt;/property&gt;<br>   &lt;/config&gt;<br>   &lt;query id=&quot;GetAll&quot; useConfig=&quot;Excel001&quot;&gt;<br>      &lt;sql&gt;SELECT Dim2, Dim3, Dim4, Dim5, AccountType, AccountDisplayValue FROM WSO2&lt;/sql&gt;<br>      &lt;result element=&quot;Entries&quot; rowName=&quot;Entry&quot;&gt;<br>         &lt;element column=&quot;Dim2&quot; name=&quot;Dim2&quot; xsdType=&quot;string&quot;/&gt;<br>         &lt;element column=&quot;Dim3&quot; name=&quot;Dim3&quot; xsdType=&quot;string&quot;/&gt;<br>         &lt;element column=&quot;Dim4&quot; name=&quot;Dim4&quot; xsdType=&quot;string&quot;/&gt;<br>         &lt;element column=&quot;Dim5&quot; name=&quot;Dim5&quot; xsdType=&quot;string&quot;/&gt;<br>         &lt;element column=&quot;AccountType&quot; name=&quot;AccountType&quot; xsdType=&quot;string&quot;/&gt;<br>         &lt;element column=&quot;AccountDisplayValue&quot; name=&quot;AccountDisplayValue&quot; xsdType=&quot;string&quot;/&gt;<br>      &lt;/result&gt;<br>   &lt;/query&gt;<br>   &lt;resource method=&quot;GET&quot; path=&quot;GetAll&quot;&gt;<br>      &lt;call-query href=&quot;GetAll&quot;/&gt;<br>   &lt;/resource&gt;<br>&lt;/data&gt;</pre><p>Then you need to package the product and export it as a <strong>.car </strong>file to a location where you running the WSO2 MI 4.2.0 server. <strong>Make sure to include the Data Service we just created as follow.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j4H_Mv6VW72NV0Q5Ttc_0A.png" /><figcaption>Packaging Artifacts</figcaption></figure><p>Then you can use the Export Composite Application Project to export it to the MI server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SKdNt6C3xjtVH8NEjlGcDg.png" /><figcaption>Export .car Application</figcaption></figure><p>If you exported the .car file to the MI server successfully you will see a response similar to the following.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5rynRFViRTcFt8cKXrgpXw.png" /><figcaption>Exported App</figcaption></figure><p>Then using a Rest Client like post you can invoke the Data Service to get the response as needed.</p><p>Curl</p><pre>curl --location &#39;https://localhost:8253/services/ExcelDataService/GetAll&#39;</pre><p>Response in Postman</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IXqJvqz8i-MN3SRweQTbvw.png" /><figcaption>Response</figcaption></figure><p>Here I’m just getting the content. But you can read the content and manipulate them on your desire.</p><p>Hope I helped you in your Integration Process. Thank you. Cheers…..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4919cabad0df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configure WSO2 APIM 3.2.0 with Dynatrace + Zipkin]]></title>
            <link>https://medium.com/@nuwankng/configure-wso2-apim-3-2-0-with-dynatrace-zipkin-5381bdb4db1d?source=rss-7a2bbe4cdc93------2</link>
            <guid isPermaLink="false">https://medium.com/p/5381bdb4db1d</guid>
            <category><![CDATA[zipkin]]></category>
            <category><![CDATA[wso2-api-manager]]></category>
            <category><![CDATA[dynatrace]]></category>
            <category><![CDATA[opentracing]]></category>
            <dc:creator><![CDATA[Nuwan Buddhika Karunarathna]]></dc:creator>
            <pubDate>Wed, 14 Dec 2022 17:12:32 GMT</pubDate>
            <atom:updated>2025-03-20T08:07:54.443Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*N4QZW-GI_hHHS8TE8a0evA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*2Sa74xuIokXdrP2AFjsdMw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*jagIhKWj__MxrNu-PpXgEw.png" /></figure><p>In this writeup I will explain how you can configure both <strong>Dynatrace</strong> and <strong>Zipkin</strong> tools to work with WSO2 APIM 3.2.0. As you may already know with this version of APIM we have enabled the configurations which can be used to connect with third party message tracing tools such as <strong>Jaeger</strong> and <strong>Zipkin</strong>.</p><p>Most importantly APIM provides this feature over the standard called as <strong>OpenTracing</strong> . It is open, vendor-neutral standard and it helps to trace requests from beginning to end with the latencies that took place in each process or method. As this is open standard you can develop your own custom message tracing implementation too. You can find more information from the official documentation.</p><p><a href="https://apim.docs.wso2.com/en/3.2.0/administer/logging-and-monitoring/monitoring/monitoring-with-opentracing/">Enabling Tracing with OpenTracing - WSO2 API Manager Documentation 3.2.0</a></p><p>In this post we are mainly focusing on the <strong>Zipkin</strong> based configuration. Here you need to add the following configurations on the <strong>deployment.toml</strong> file of the APIM server.</p><pre>[apim.open_tracer]<br>remote_tracer.enable = true<br>remote_tracer.name = &quot;zipkin&quot;<br>remote_tracer.properties.hostname = &quot;&lt;hostname-of-zikin-endpoint&gt;&quot;<br>remote_tracer.properties.port = &quot;&lt;port-of-zipkin-endpoint&gt;&quot;</pre><p>After restarting the APIM server and invoking some API calls, you will be able to see the data on the <strong>Zipkin</strong> server like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jnF7lRoq3wwowmaSsOCPvA.png" /><figcaption>Zipkin Data</figcaption></figure><p>Pretty easy ! Right !! Well not exactly 🤔</p><p>Things get somewhat messy when you try to integrate <strong>Dynatrace</strong> which is a famous monitoring tool with the same APIM server which we configured with <strong>Zipkin</strong>. Before going for that lets first see how to configure <strong>Dynatrace</strong> with this existing setup. You can find the steps to configure this on their documentation.</p><p><a href="https://www.dynatrace.com/support/help/technology-support/dynatrace-extensions/supported-out-of-the-box/wso2">WSO2 API Manager monitoring</a></p><p>We have another detailed writeup from one of our colleague as well.</p><p><a href="https://medium.com/@hasarangi/dynatrace-agent-installation-for-monitoring-wso2-products-6ab356fb54f5">Dynatrace agent installation for monitoring WSO2 products</a></p><p>Once you configure <strong>Dynatrace</strong> and deploy <strong>OneAgent</strong> on your instance, You will observe that <strong>Zipkin</strong> is not receiving the data which previously there and in the worst case scenario you could observe that APIM is even refusing to restart throwing a stack trace as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3TgUP20HCQ5uBrGfEX68QQ.png" /><figcaption>Startup-Error</figcaption></figure><p>Now let’s see what cause this behavior. Under the hood OneAgent which is the representative for the <strong>Dynatrace </strong>(😁)<strong>, </strong>trying to override the <strong>Zipkin</strong> or <strong>Jaeger</strong> and trying to access the OpenTracing data. Actually they have already mentioned this out in their documentation too.</p><p><a href="https://www.dynatrace.com/support/help/shortlink/opentracing#enable-opentracing-integration">OpenTracing</a></p><p>As we don’t need <strong>Dynatrace</strong> to take over the <strong>Zipkin, </strong>We can use a config which disables it from accessing OpenTracing data. Under the <strong>Settings-&gt;Preferences-&gt;OneAgent</strong> <strong>features </strong>of <strong>Dyntrace,</strong> we can turn off the <strong>OpenTracing (Java) GlobalTracer auto-injection w/o override</strong> option so it won’t access OpenTracing data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*76dCrQzROswER8zTj_FLfA.png" /><figcaption>Dyntrace-Config</figcaption></figure><p>Now restart the APIM server and you will be able to see the tracing data in the Zipkin server and Monitoring data in the Dyntrace.</p><p>Try it out and let me know the results .Thanks for reading ! Cheerss 👍</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5381bdb4db1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configure WSO2 APIM Analytics Mail Alerts (Update)-3.1.0]]></title>
            <link>https://medium.com/@nuwankng/configure-wso2-apim-analytics-mail-alerts-update-3-1-0-46412b9db42?source=rss-7a2bbe4cdc93------2</link>
            <guid isPermaLink="false">https://medium.com/p/46412b9db42</guid>
            <category><![CDATA[gmail]]></category>
            <category><![CDATA[wso2]]></category>
            <category><![CDATA[apim-analytics]]></category>
            <category><![CDATA[email-alert]]></category>
            <dc:creator><![CDATA[Nuwan Buddhika Karunarathna]]></dc:creator>
            <pubDate>Wed, 28 Sep 2022 16:41:42 GMT</pubDate>
            <atom:updated>2022-09-28T16:41:42.417Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post I want to give you an update on enabling the Mail Notifications for the APIM Analytics 3.1.0 version. You can refer the official documentation on configuring Mail Alerts using the Analytics component.</p><p><a href="https://apim.docs.wso2.com/en/3.1.0/learn/analytics/managing-alerts-with-real-time-analytics/configuring-alerts/#create-an-abnormal-requests-per-minute-alert/">Configuring Alerts - WSO2 API Manager Documentation 3.1.0</a></p><p>Following the above documentation you can configure the Analytics component to send Mail notifications to the subscribed Mail addresses either on the publisher portal or Dev portal depending on your requirement. Basically we can configure Mail Alerts if there are abnormal scenarios rather than expected happens when invoking the APIs.</p><p>In this documentation default service provider for the mail functionality is chosen as Gmail. To configure APIM Analytics to push data to the Gmail server we needed to enable the less secure apps functionality in the past.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*leiFSn5PotYc8DilcRCrfg.png" /><figcaption>Less Secure App Feature</figcaption></figure><p>However with the update on 30th May, 2022 Gmail doesn’t allow the private Email addresses to turn on the Feature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bc5LrWeWNDzpUv2B2Jq91g.png" /><figcaption>Less secure apps disabled</figcaption></figure><p>This in return it causes the following error on the worker profile on the Analytics server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qgW7H42LD259tPHD5_GTvw.png" /><figcaption>Credentials Error</figcaption></figure><p>Luckily there is an alternative. We can use the App password feature to achieve our requirement provided by Gmail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aWMt4aIn9CN4B2niEwyPvg.png" /><figcaption>App Passwords</figcaption></figure><p>In here you can configure an App which is representing the third party client who intend to push data to Gmail. In our case it is the Analytics.</p><p>You can configure an App like below and use the generated unique password in the Analytics configuration as the password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pV8Yw5F7ZJ_bS3-xrtxbjg.png" /><figcaption>Apps</figcaption></figure><p>Here is the generated Password when we are creating the App.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7lE6bYnPhOVlwsnSawXAUA.png" /><figcaption>Generated Password</figcaption></figure><p>We can use this password in the Analytics configuration which is in the &lt;API-M_ANALYTICS_HOME&gt;/conf/worker/deployment.yamlfile as below.</p><pre>siddhi:<br>    extensions:<br>...<br>    -<br>        extension:<br>        name: email<br>        namespace: sink<br>        properties:<br>            username: alex@gmail.com<br>            address: alex@gmail.com<br>            password: hilfcmmdhwxkyucz <br>...</pre><p>Configuring this would allow Analytics Server to push the data to Gmail server.</p><p>Try out and let me know on the results. Cheersss !!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46412b9db42" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Open API Content Validation Issue on WSO2 APIM]]></title>
            <link>https://medium.com/@nuwankng/open-api-content-validation-issue-on-wso2-apim-bb1f3df56153?source=rss-7a2bbe4cdc93------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb1f3df56153</guid>
            <category><![CDATA[wso2-api-manager]]></category>
            <dc:creator><![CDATA[Nuwan Buddhika Karunarathna]]></dc:creator>
            <pubDate>Mon, 20 Jun 2022 17:53:32 GMT</pubDate>
            <atom:updated>2022-06-21T03:25:38.011Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever come across a scenario where you are trying to import API to the WSO2 API manager but failed due to error like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_VJdRWs3WsYJVbHbuVlw5Q.png" /></figure><p>Then you probably though this was an error in the API definition itself and tried to correct the API definition in all possible ways yet no luck. No hint on the logs as well. There might be a hidden issue that you can’t figure out just by looking at it.</p><p>There is a high chance that this issue happen to be on the cloud related infrastructure. Cloud technologies are used more and more as they promise the maximum availability for your services and you might already on the cloud.</p><p>On the cloud, Containerised deployments are the latest trend in deploying services which guarantees minimum impact for your services in the event of a failure.</p><p>However in the containerised environments there are some configurations that need to be handled to suit your requirements. If you look closer and try to analyse the network trace you will catch an error like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G4Eb3n0wzeDLHqodfxnKUw.png" /></figure><p>Although the error saying OpenAPI content validation failed, actual error is something else. It is saying that <strong>413</strong> <strong>Request Entity Too Large</strong>. If you look closer you will be able to see that the response is actually thrown by <strong>nginx</strong> layer. As I mentioned earlier these are some configs you will need to adjust as per your requirement. According to the error it is saying that the Request Payload which is the API definition that we attached is <strong>larger</strong> than the configured value on the container .</p><p>Check for the configs on the container, Adjust the parameters and you are good in no time.</p><blockquote>nginx.ingress.kubernetes.io/<strong>proxy-body-size: 10m</strong><br> nginx.ingress.kubernetes.io/<strong>proxy-connect-timeout: “10”</strong><br> nginx.ingress.kubernetes.io/<strong>proxy-read-timeout: “120”</strong><br> nginx.ingress.kubernetes.io/<strong>proxy-send-timeout: “120”</strong></blockquote><p>Mentioned above is sample configuration on the containerised environment.</p><p>Hope this helps you when using WSO2 API Manger. Cheers !!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb1f3df56153" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Traffic Manager Works in WSO2 API Manager]]></title>
            <link>https://medium.com/@nuwankng/how-traffic-manager-works-in-wso2-api-manager-7f5b981f1ae0?source=rss-7a2bbe4cdc93------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f5b981f1ae0</guid>
            <category><![CDATA[traffic-manager]]></category>
            <category><![CDATA[throttling]]></category>
            <category><![CDATA[wso2-api-manager]]></category>
            <dc:creator><![CDATA[Nuwan Buddhika Karunarathna]]></dc:creator>
            <pubDate>Wed, 27 Apr 2022 18:46:29 GMT</pubDate>
            <atom:updated>2022-05-16T01:15:10.710Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*24Il2DztdQaPIgcy1L6hsg.gif" /></figure><p>Hi All, Objective of this write-up to give you a brief explanation of how the traffic manager component of the WSO2 API manager functions. I will use APIM as an abbreviation to API Manager here onwards</p><p>Traffic manager is the component which takes the throttling/rate limiting decisions of the APIM. As an example you can have limitations on how many requests per specific time window should the APIM process. Inside the Traffic manager all the the calculations with regards to the throttling will be evaluated by very powerful Siddhi runtime.</p><p>When API requests comes to the APIM, Gateway is the first component it will interact. There are multiple other components are inside the Gateway too. As we are interested on the role of Traffic Manager Let us focus on it.. There are mainly two types of deployments in APIM. Namely they are All-in-One and distributed system. For the sake of understanding I will use the distributed setup as in All-in-One deployment all the functionalities are packed inside. You can setup your own distributed pack using the official documentation as a guide.</p><p><a href="https://apim.docs.wso2.com/en/3.2.0/install-and-setup/setup/distributed-deployment/understanding-the-distributed-deployment-of-wso2-api-m/">Distributed Deployment Overview - WSO2 API Manager Documentation 3.2.0</a></p><p>You can get an overall idea using the diagram below on the components in a distributed setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8DhCihPp_YTJVo-gNnHPTA.png" /><figcaption>Image Credits : wso2.com</figcaption></figure><p>For every API request that comes to the Gateway should be checked against the throttle conditions. Let me explain how this happens. Suppose you have created a new API and you are ready to invoke it. When creating the API you defined a condition which the request count should not exceed 50 requests per min. In APIM we call these conditions as throttle policies. You can create your own policies using the APIM admin portal. More on this available here.</p><p><a href="https://apim.docs.wso2.com/en/3.2.0/learn/rate-limiting/adding-new-throttling-policies/">Adding New Throttling Policies - WSO2 API Manager Documentation 3.2.0</a></p><p>Now you are sending a request to the Gateway to invoke the API. After intercepting the request Gateway is creating the throttle request containing fields such as <strong>Message ID, Application Throttle Key, Application Tier, API Throttle Key, API Tier, Subscription Throttle Key, Subscription Tier, Resource Level Throttle Key, Resource Level Tier, End User, API Context, API Version</strong> etc. Internally throttle handler is the component in the Gateway that is responsible for this operation. This request is then sent to the Traffic Manager using binary or thrift transport protocol. If you refer the <strong>deployment.toml</strong> on a brand-new APIM pack you can identify that as follows.</p><pre>traffic_manager_urls = [&quot;tcp://localhost:9611&quot;,&quot;tcp://localhost:9612&quot;]</pre><pre>traffic_manager_auth_urls = [&quot;ssl://localhost:9711&quot;,&quot;ssl://localhost:9712&quot;]</pre><p>In here you can identify the addresses of the traffic manager instances. By default APIM uses the binary transport protocol to send throttle requests to Traffic Manager. Most importantly Gateway will not wait for the decision of the Traffic Manager as it an asynchronous process. Throttle decisions will be later received by the Gateway using JMS protocol.</p><p>Now you have received the throttle request at the Traffic Manager. Based on the received message, Traffic manager internally do some calculations and decide whether the request should be throttled out or not. For each and every request Traffic Manager creates and publishes an Event to the Gateway Component whether the request should be throttled out or not. Event contains following attributes.</p><ul><li><strong><em>throttleKey — Key of particular throttling level</em></strong></li><li><strong><em>isThrottled — Whether message has throttled or not</em></strong></li><li><strong><em>expiryTimeStamp — When the throttling time window will expires</em></strong></li></ul><p>If the request should not be throttled then <strong><em>isThrottled </em></strong>condition will be false. Remember that in above when you are creating the API, you added a policy which limits the requests to 50 requests per minute. Since you are invoking the API for the first time it should not be throttled out. Right ??</p><p>Now you are sending several another API requests within the minute and you are about to hit the threshold which is 50 requests per minute. On the 51st request Traffic Manager decides this request should be throttled out. What it does is, It set the <strong><em>isThrottled </em></strong>condition to be true.</p><p>After creating these Event messages Traffic Manager will publish these messages to a topic in a Message Queue. The Gateway is listening to this topic from their side. Once the topic received a message from Traffic Manager, Gateway is going to consume it. The the throttle handler inside the Gateway put this message into a Java Map called throttle data map. This is like a small storage. Since the request should be throttled out isThrottled property of the message is true. It is a boolean value. Then the Gateway send a response to the invoker similar to the message below.</p><p>Now suppose you are still sending requests within the same minute. Now what Gateway does is, It will generate a throttle key as always which is used in the Event message that will send to the Traffic Manager. Then it will check if that throttle key is exists in the throttle data map. If it exists then it checks for the <strong><em>isThrottled</em></strong><em> </em>status. If that is true then the request is going to be throttle out. Most importantly Gateway does not send a throttle request until the<em> </em><strong><em>expiryTimeStamp</em></strong><em> </em>time window is passed.</p><p>After the <strong><em>expiryTimeStamp</em></strong><em> </em>it will send the requests again to the Traffic Manager.</p><p>Although I haven’t mentioned earlier for the simplicity of understanding, Gateway will first calculate the throttle keys and it checks the throttle data map to see whether there is an entry similar to the throttle key. Based on that request Gateway will decide whether the request should be throttled out or not.</p><p>Hope you got an understanding of the basic procedure of throttling<em>.</em></p><p>Now let us have some understanding on the basic configuration properties on the APIM with regards to the throttling. We are discussing this on a APIM pack which is after 3.x.x serious which had the configurations centralised to the <strong>deployment.toml</strong> file. More information on here.</p><p><a href="https://apim.docs.wso2.com/en/3.2.0/reference/understanding-the-new-configuration-model/">Understanding the New Configuration Model - WSO2 API Manager Documentation 3.2.0</a></p><p>In the <strong>deployment.toml</strong> you can find following configurations.</p><pre><em>[[apim.throttling.url_group]]</em></pre><pre><em>traffic_manager_urls = [&quot;tcp://localhost:9612&quot;,&quot;tcp://localhost:9613&quot;]</em></pre><pre><em>traffic_manager_auth_urls = [&quot;ssl://localhost:9712&quot;,&quot;ssl://localhost:9713&quot;]</em></pre><pre><em>type = &quot;loadbalance&quot;</em></pre><pre><em>[[apim.throttling.url_group]]</em></pre><pre><em>traffic_manager_urls = [&quot;tcp://localhost2:9611&quot;,&quot;tcp://localhost2:9611&quot;]</em></pre><pre><em>traffic_manager_auth_urls = [&quot;ssl://localhost2:9711&quot;,&quot;ssl://localhost2:9711&quot;]</em></pre><pre><em>type = &quot;failover&quot;</em></pre><p>For the sake of understanding we will consider<strong> <em>[[apim.throttling.url_group]]</em></strong><em> </em>as a single server which is having multiple traffic manager instances<em>. </em><strong><em>[“tcp://localhost:9612”,”tcp://localhost:9613&quot;]</em></strong><em> </em>are the addresses of those instances<em>. Since we are having two </em><strong><em>[[apim.throttling.url_group]]</em></strong>s inside the <strong>deployment.toml, </strong>Gateway will send throttle requests to both the groups<strong><em>.</em></strong></p><p>Have you noticed there is an another config as <strong>type = “loadbalance”</strong> or <strong>type = “failover”</strong> ???</p><p>This configuration decides what instance in the group receives the throttle requests. If the type is <strong>loadbalance</strong>, request will be sent to one of the instances in the group which is healthy or available. But on <strong>failover</strong> scenario throttle request will only reach the second instance in the group if first one is unable to receive the request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/0*lBBsjRX9Kc2ppyHp" /><figcaption>Image Credits: wso2.com</figcaption></figure><p>After that, the instance which received the throttle request will evaluate the throttle policies and take decisions based on it. Since we are using two groups having two Traffic manager instances on it, single instance from each group is doing the evaluation and publish the decision as a message to the topic.</p><p>With regards to publishing the message there is another special configurations available on Traffic Manager components.</p><pre>[apim.throttling]</pre><pre>event_duplicate_url = [&quot;tcp://localhost:5672&quot;,&quot;tcp://localhost:5673&quot;]</pre><p>For each and every Traffic manger instances this config stores the addresses of all other Traffic manager instances. Objective is this to synchronise the throttle decision on all the nodes. Using this approach if one Traffic Manager instance is failed, Gateway can still listen on other throttle decision endpoints.</p><p>There is another important configuration is available on the Gateway component of the distributed setup that we are discussing.</p><pre>[apim.throttling]<br>throttle_decision_endpoints = [&quot;tcp://localhost:5672&quot;,&quot;tcp://localhost:5673&quot;]</pre><p>These are the endpoints that the Gateway is listening whether there is a message from the Traffic manager on the subscribed topic. If one endpoint is not reachable Gateway can try the other making sure the throttling process stays robust.</p><p>In this article I have tried to explain about the throttling process happens inside the WSO2 APIM as a summary. You can refer some other brilliant articles written on this concept.</p><p>Cheers !!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f5b981f1ae0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>