<?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 kamalika chaudhuri on Medium]]></title>
        <description><![CDATA[Stories by kamalika chaudhuri on Medium]]></description>
        <link>https://medium.com/@kamalikachaudhuri93?source=rss-482328045b86------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RZb0b7SbuCKKPZkO5XyjXw@2x.jpeg</url>
            <title>Stories by kamalika chaudhuri on Medium</title>
            <link>https://medium.com/@kamalikachaudhuri93?source=rss-482328045b86------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 05:50:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kamalikachaudhuri93/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[Thoughts on Error Handling]]></title>
            <link>https://medium.com/another-integration-blog/thoughts-on-error-handling-cc5526be5fbf?source=rss-482328045b86------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc5526be5fbf</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[error-handling]]></category>
            <category><![CDATA[mule]]></category>
            <category><![CDATA[api-development]]></category>
            <category><![CDATA[mulesoft]]></category>
            <dc:creator><![CDATA[kamalika chaudhuri]]></dc:creator>
            <pubDate>Thu, 17 Nov 2022 19:23:24 GMT</pubDate>
            <atom:updated>2022-11-17T19:23:24.151Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9B6CsULWwS7BWxoI6xpTgg.jpeg" /></figure><p>Dear readers,</p><p>I hope you are all doing well. While serving customers of various domains, such as banking, retail, pharmaceutical, and automobile industry, I have helped them with their MuleSoft implementation journeys. Today, in this blog, I want to share some of my observations on the different aspects of error handling in MuleSoft that I have seen.</p><h4><strong>Error Handling Basics</strong></h4><p>In MuleSoft, when any connector encounters an error, the flow execution stops, an error is thrown, and we can handle the error using one of the two error handlers I will describe below, as required.</p><ul><li>On-error continue: this will return success 200 and will not throw the error back to source. Any transactions at this point are committed.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/1*QgpOf2fwSOHzMIcQjBBypw.png" /><figcaption>On Error Continue</figcaption></figure><ul><li>On-error propagate: Error is re-thrown back to source. This rolls back any transaction.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*O0_JKFkJX9KFYHSpIvreVA.png" /></figure><p>We might place this error handler in the following situations:</p><ul><li>In the flows error handling section:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*k-QI3WbX3AcRD-dk4sEhiw.png" /></figure><ul><li>In the try scope’s error handling section:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/163/1*ERLQW-fYQoGqM1NErytC5g.png" /></figure><ul><li>We can define an unattached error handler which can contain one or more on-error continue or on-error propagate handler components. which handles the error. This unattached error handler can be set as the default error handler under global configuration to be applicable throughout the application. It can be referenced from the error handling section of the main flow containing the API kit router.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*hbQU6DmqRkU29-FjHl4tlg.png" /><figcaption>Unattached Error Handler</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*CoPV0n_wNbvgVrS1-3U73A.png" /><figcaption>Error Handler Reference</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*3ZPj7ZKZ7DWOhobOOqkiZg.png" /><figcaption>Set your custom error handler as default</figcaption></figure><p>The next option is the most reusable one; putting all error handling logic in a global-error-handler.xml file is a development best practice.</p><p>Once we have caught the error, we can try to retrieve information from it which can be returned as an API response, logged, or used to form an alert message to send as an error alert to a notification API.</p><p>We can retrieve the error type from the error object to log the original error by getting:</p><blockquote>errorType: (error.errorType.namespace default “MULE”) ++ “:” ++ (error.errorType.identifier default “ANY”)</blockquote><p>Next, we can fetch the error description which provides us with more insights about the error:</p><blockquote>errorDescription: error.detailedDescription</blockquote><p>What happens if we don’t handle errors or don&#39;t define error handlers? Errors will be handled by MuleSoft’s default error handler which will log the error and propagate it.</p><p>Until now, the basics of error handling are covered.</p><p>Let&#39;s go a bit deeper and explore the following topics.</p><h4><strong>Error Propagation</strong></h4><p>Sometimes, when we are calling a downstream API from within the Mule API code, we might want to propagate the same error payload and error status code that is thrown by the downstream API. To do so, we would require the error payload and the error status code. We can retrieve those in two ways:</p><p>First, retrieve from the error object itself:</p><pre>Set payload to error.errorMessage.payload<br>Set variable httpStatus to error.errorMessage.attributes.statusCode</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*yNWkmxqUp5RshGDkHs-5eg.png" /><figcaption>propagate when Api returns 400</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*A5BA2j7dfJTljpmtIokH1w.png" /><figcaption>propagating same error message which is set</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*pkn0Wgoi-ki6K7XgvnqUGw.png" /></figure><p>I am setting variable httpStatus because I have set up my listener as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z9OMUcTe9xufHpWy9kH9hw.png" /></figure><p>For this demonstration, I have created another flow which listens and returns 400 when an empty payload is passed. This shows that the payload and status code I have set in this flow is returned by our test flow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*XQvg1PrEYcspZ1VDXJz_Tg.png" /><figcaption>Complete flow</figcaption></figure><p>This is what the /error endpoint returns:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*VVl8KttrcPZbVeWdyPNFUg.png" /></figure><p>When the /error endpoint is called from within the /test, as we are retrieving the same error payload and status code and resetting it, we will see the same response returned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bYb9ElJUQo0ioW11VQr5MQ.png" /></figure><p>The second option to propagate an error would be to configure the HTTP request connectors success code validator to consider the error status codes as success. In this, the http status and the error payload are available in attributes.statusCode and the payload itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*GRoIasACzFpReCBHcWr8mg.png" /><figcaption>StatusCode Range</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*VWnUIVFmMFQueOiYqGZ1pA.png" /><figcaption>Individual Status Codes</figcaption></figure><h4><strong>Error Handling for a Mule API vs Error Handling for Mule Application</strong></h4><p><strong>Error handling for a Mule API</strong></p><p>By Mule API I mean an API that accepts a request and returns and response. In such cases, when we are designing the error handler, we will log the error and set up appropriate responses for different types of errors that might occur in the API. We can do so by adding a common error handler and adding multiple on-error propagates to handle each error, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*wcIt7j1CY8IxbsaI-2jRtA.png" /></figure><p>Above is the simplest possible example of a common-error-handler for a Mule API.</p><p>It is important that we put the error handler for type ANY last so that it catches all of the error that are not caught by any of the handlers above. Also, if we put the error handler for type ANY at top, then it will catch all errors and we will lose fine grain control of handling the different types of errors.</p><p><strong>Error Handling for Mule Application</strong></p><p>This means an application that does not immediately return a response. For example, an application that is triggered by a scheduler, queue, or a listener of a connector which does not return an immediate response (for example, an IDoc listener). These kind of applications are designed to do batch or sync jobs.</p><p>Now, I will describe how to design an error handler for such Mule applications. We will start by designing an error handler that will log the error, then we need to put logic to implement corrective actions for known error scenarios. For example, updating a row in Salesforce or the database with the error flag against the record. We can separate retriable and nonretriable errors and add logic to retry, if applicable. Retriable errors can result from connectivity issues which might be fixed on retry. An example of a nonretriable error can result from a bad request or faulty data. Corrective actions for nonretriableable errors can be flagging in the record, sending an alert to the respective team. If the sync job is constructed in a way such that the faulty record is picked up in all cycles, then logic to flag the data should be implemented, so that it is not picked up in the next cycle. For such scenarios, the data is pushed to a dead letter queue or saved in a location such as a database or file location for manual processing.</p><p>The error handler snippet shown below is taken from a sync job API which fetches new/updated record details from Salesforce, updates the record details in an external system, and updates the status of the update back in Salesforce by the record’s ID. If at any point the external system update operation encounters a non-retry-able error, then, as part of corrective action, a flag is updated in Salesforce that prevents the error-prone record from being picked up in next cycle and requires a manual intervention.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*hu42otzEGa8DJdJNIQC0-g.png" /><figcaption>flag records in salesforce which encounter non retryable error</figcaption></figure><p><strong>Custom Errors</strong><br>MuleSoft provides the option of raising a custom error to identify and handle specific error scenarios. We can broadly classify errors in any Mule application as one of the following:</p><ul><li>Business errors</li><li>Technical errors</li></ul><p><strong>Business errors</strong> are scenarios where a business condition is not satisfied. For example, trying to create a record that already exists. We can put checks and validations in place for such conditions and raise appropriate custom errors for easy error identification in logs and can be handled in the error handler.</p><p>Custom errors can be raised in two ways via the raise error component or the error-mapping option in Mule connectors. See the example below where we are raising a custom error if the requested payload is empty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*1_Mpx2y6AKqSi6qzA5y6fg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tITFD5dRhNZR51GHVC3Mpg.png" /><figcaption>Setting custom error in error mapping section</figcaption></figure><p>We can also do this using the choice and raise error component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/253/1*K1Q_KmHasMAIVcle4J5RVw.png" /><figcaption>Raise custom error using raise error component</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*u-SWGPA6XshI0yWP-P75Zw.png" /></figure><p>Finally, we can handle the custom error that we just raised.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*lu03Kxs8qu7T3ndar4-n3A.png" /><figcaption>Handling a custom error</figcaption></figure><p><strong>Technical Errors</strong></p><p>Technical errors mostly occur in runtime. We generally do not raise custom errors for technical errors. But consider when a legacy system API results in an internal server error (500), we want to handle it in a unique way and send a notification to the team with details for the payload and failure. Then, a custom error can be mapped to the error HTTP: INTERNAL_SERVER_ERROR to APP: INTERNAL_SERVER_ERROR and handler logic which listens for APP: INTERNAL_SERVER_ERROR type of error.</p><h4><strong>Packaging the Error Handler</strong></h4><p><strong>Part of the project: </strong>error handlers can be part of the project structure. This option is not reusable and mostly used for projects having very few APIs.</p><p><strong>Custom Connector: </strong>error handling code for an API can be packaged as a connector and used while implementing a project. This option offers flexibility, such us adding an error message. However, a large part of additional or external logic remains in the code.</p><p><strong>Mule Plugin:</strong> error handlers can be packaged as a Mule plugin and can be plugged in as Maven dependency in any Mule application project. If you are using this option, remember to add an import statement in the global configurations for the error-handler’s xml file. This plugin, if added with options to add extend and override logic by the error-handler code, gives a lot of flexibility for project implementation.</p><p>Lastly, to make all reusable error handler diverse, it is essential to add basic error handler code for both Mule APIs (i.e., implemented with API kit router) and Mule applications (i.e., async or batch APIs). Both handlers give options to the implementing project to extend and override.</p><p>Thank you for reading this blog. If you like this article, please leave a clap and follow me so you can read more blog like this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc5526be5fbf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/another-integration-blog/thoughts-on-error-handling-cc5526be5fbf">Thoughts on Error Handling</a> was originally published in <a href="https://medium.com/another-integration-blog">Another Integration Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scatter Gather — Beyond the basics]]></title>
            <link>https://medium.com/another-integration-blog/scatter-gather-beyond-the-basics-efe5b72a5d80?source=rss-482328045b86------2</link>
            <guid isPermaLink="false">https://medium.com/p/efe5b72a5d80</guid>
            <category><![CDATA[message-processor]]></category>
            <category><![CDATA[thoughts]]></category>
            <category><![CDATA[mule]]></category>
            <category><![CDATA[mulesoft-training]]></category>
            <category><![CDATA[mulesoft]]></category>
            <dc:creator><![CDATA[kamalika chaudhuri]]></dc:creator>
            <pubDate>Wed, 09 Nov 2022 19:35:42 GMT</pubDate>
            <atom:updated>2022-11-18T18:39:36.513Z</atom:updated>
            <content:encoded><![CDATA[<h3>Scatter-Gather: Beyond the Basics</h3><p>Scatter-Gather is a message router in MuleSoft. You can read about it in detail via Mule docs <a href="https://docs.mulesoft.com/mule-runtime/4.1/scatter-gather-concept">here</a>. I wrote this blog to share some observations, which are tested below in Runtime.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*5tS1F4R63W0PxlA7wihgZw.png" /></figure><p>We know that Scatter-Gather needs at least two routes to be functional. But where would it fail if I included only one route? Will it fail when it builds or when it is getting deployed? Let’s check.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*47NRu2ZWW_qQfwmnr3W0IQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6mlrvLhVdmeou2wVWa0tFQ.png" /></figure><p>As you can see above, Scatter-Gather will fail while it is being built.</p><p>Let’s check out the variable behavior in Scatter-Gather next. Observe the Mule flow below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*8ylqTwjtTfilB5xH8w8KXQ.png" /></figure><p>You will observe there is a variable called fruits and it is being modified in each route by the addition of one more item. Let’s debug and observe the state variable from the start:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*qFI6rxqgTAwam136TYQRhg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n8ZGV-gfTmYbSIy-23luvQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*NuJPHM6NljFFJDry7mTZ8A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*Vh_oUUp7rJKA4-0Flnsdiw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*syrj_EaWts4oqwRMPILKlg.png" /></figure><p>So, we saw that each route received the same variable, and individual routes changes were added to each route. Let see what the final result looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HwqQRXnzZnqQcYhWEv5rgA.png" /></figure><p>Because I wanted to see all distinct fruits that were added,<br> I have the final transformation as:</p><pre><strong>%dw 2.0<br> output application/json<br> ---<br> {<br>     &quot;content&quot; : payload..payload,<br>     &quot;fruits&quot; : flatten(vars.fruits) distinctBy $<br> }</strong></pre><p>The final result looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*JOENM-U4f29_oc5yCH_qew.png" /></figure><p>Now, we observed the behavior in the case of success, but what happens if one route fails? How much can we salvage from the error object? Let’s try by giving 0 as input which will cause a divide by zero error in route 2 or 1 if we start counting from 0. You will observe that when we are inside the Scatter-Gather, the variable behavior remains same as in case of success as the variable is not the error causing component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*p08myPpdk1S5_x7FpIEp7Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rhaOnZi8dLfFYHpVWXlPIQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*2d0DgUINcXLn1m4CNocFZA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*iTs3FzwSPeQ_yBxMFwL0rw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xdv-Tc4DWMVt2aR2YQ4y9w.png" /></figure><p>Let’s now check the variable value just after the Scatter-Gather.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7-IBjo5-i4856M_9TyvaiA.png" /></figure><p>To our surprise, we have lost most of our fruit when an error occurs.</p><p>Let’s see if we can salvage the payload details from the error by doing some transformations on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*QtLe1rJiLjQUcJYMpQWjmw.png" /></figure><p>So, we were able to salvage the success payloads, cause for failure, and the Scatter-Gather route number that failed. The transformation I used here is shown below. I know it’s not sophisticated but it works for the purpose of demonstration.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f244c8867d952b38553d9e46d6660c98/href">https://medium.com/media/f244c8867d952b38553d9e46d6660c98/href</a></iframe><p>I feel destructive, so let’s fail all the routes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0kMiEYxV8RXEXR0kaDcUZg.png" /></figure><p>Let’s compare with the code to verify we are getting the route numbers in correct order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*rxTiP-cW8nlBPga77_SGVg.png" /></figure><p>We have the correct sequence of 100 + “a”, 100/”a”, 10 + “a”, so we are good.</p><p>Let’s try another way where we might be able to save our fruits in case of errors.</p><p>For these, we wrap each route in a try scope and add an on error continue handler for all try scopes. Let’s observe what happens to the variable this time when we fail all the routes.</p><p>So, the changed flow would look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*ZIeI6zVeiU1nP1Zx4NSHaw.png" /></figure><p>The “errorMessage” inside the on error continue contains:</p><pre><strong>%dw 2.0<br> output application/json<br> ---<br> {<br>     errorType: (error.errorType.namespace default &quot;MULE&quot;) ++ &quot;:&quot; ++ (error.errorType.identifier default &quot;ANY&quot;),<br>     errorCause: error.detailedDescription,<br>     route: 0 //this is varying as per route number<br> }</strong></pre><p>Like before, we have passed “a” as payload and failed all routes. We got the response below from our application:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4q6tPs8PExdv-NUswU3CzQ.png" /></figure><p>We got back all of our fruits!<br>In some cases we might not want to have more fruit, so we can keep figuring out the right error handling approach, as per requirements.</p><p>For now, let’s fail one route to verify the behavior with our changed approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BKFfkEisqCoJh0JgA7r5Xw.png" /></figure><p>We have the successful route payload and all fruits in our fruits-variable.</p><p>We have seen a lot of error scenarios in a row, so let’s try the success scenario now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*xUM2NfpJpE1GwWao1nH3_g.png" /></figure><p>Lets try remove a variable inside Scatter-Gather!</p><p>Remove the variable from one route and we will take the fruits without the distinct by function.</p><p>As expected, instead of three apples we have two apples, one banana, and one coconut.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*b3-uPRVwl8naQfGX24jJRQ.png" /></figure><p>What if we use remove variables in all routes, will it completely remove the fruits variable?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*EhDByFr8sGnuSOwRrlaVeg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*YaR9fJiWG_RTwHI77g4DFA.png" /></figure><p>It turns out, the fruits variable remains.<br>If we debug, we will observe that in the individual routes the variable size has become zero inside the Scatter-Gather.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*73c3vOawSOTZNEM4mJGLpw.png" /></figure><p>But, when we move out of the Scatter-Gather, we get back the variable fruits with the original values it had before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ycfZFvk5myz_QMl9FLN8KA.png" /></figure><p>To conclude, we can say that the behavior of a variable around Scatter-Gather is definitely interesting.</p><p>If you like this article, please leave a clap and follow me for more such blogs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=efe5b72a5d80" width="1" height="1" alt=""><hr><p><a href="https://medium.com/another-integration-blog/scatter-gather-beyond-the-basics-efe5b72a5d80">Scatter Gather — Beyond the basics</a> was originally published in <a href="https://medium.com/another-integration-blog">Another Integration Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Error Alerts without any external email hosting service]]></title>
            <link>https://medium.com/another-integration-blog/error-alerts-without-any-external-email-hosting-service-cced43cc2706?source=rss-482328045b86------2</link>
            <guid isPermaLink="false">https://medium.com/p/cced43cc2706</guid>
            <category><![CDATA[mulesoft]]></category>
            <dc:creator><![CDATA[kamalika chaudhuri]]></dc:creator>
            <pubDate>Sat, 13 Aug 2022 12:27:48 GMT</pubDate>
            <atom:updated>2022-09-28T16:39:16.191Z</atom:updated>
            <content:encoded><![CDATA[<h3>Error Alerts: MuleSoft CloudHub Connector</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PqiQWjQEqyKzBmoN.png" /></figure><p>This article will discuss how to use custom CloudHub alerts to configure end-to-end error alerts in MuleSoft. To start, assume we have a project with a huge order load coming from legacy system 1 and are creating orders in CRM system 2. If there are issues in the order, some of the order creation would fail. Without any built-in alert, the customer would only be alerted of the order failure from the order creator (i.e., the end user or when somebody notices the discrepancy). It would be very challenging for a support team to determine where the order failed and what team to redirect the issue to.</p><p>Now imagine this: what if the appropriate team got an email alert as soon as the order failed and could act upon the issue and inform the customer support team in advance? The support team would be able to provide the end-user with a solution in a faster, and sometimes even preemptive, manner, increasing customer satisfaction.</p><p>This is what we will deliver, using MuleSoft. A challenge arises if we don&#39;t have an external email hosting service available to send email alerts; however, we can use the CloudHub Alerts feature in Runtime Manager to overcome this.</p><p>There are some standard alerts provided by MuleSoft that are useful for standard Mule app events, such as deployment success/failure status. In our case, we need a more specific error alert. We want alerts to be sent when a custom business error or any failure in the Mule app occurs. To achieve this, we must implement that feature using the <a href="https://docs.mulesoft.com/runtime-manager/custom-application-alerts">custom application alerts</a>. Using the out-of-the-box CloudHub Connector, we can configure different types of alerts to be sent to particular recipients, allowing the appropriate groups to act upon the alert-causing event.</p><p>For the sake of simplicity, we divide the alert options into three categories: b<strong>usiness error alert, internal error alert, and standard alerts.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/0*seG28BOIeZzWRcoq.png" /></figure><p><strong>Business Alerts:</strong> as the name suggests, business error are related to failures in business validation or logic. Business errors are known scenarios. Suppose an order from system 1 has failed to create an order in system 2. We can implement logic to check the response of the system 2 connector and send the respective alert containing cause of failure and an identification of the order through CloudHub Connector’s <a href="https://docs.mulesoft.com/runtime-manager/custom-application-alerts"><strong>Create Notification</strong></a> operation. For example, an alert for order create failure to the business team would contain order ID 123, along with it a custom cause of failure message explaining the reason of the failure.</p><p>It is important to note that there can be different types of business events, and you don’t necessarily want the same email recipients to be alerted for all types of events. Below I will describe how to specify who receives emails for a particular custom business events. Consider the following scenario:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/0*J-vhMyjx9eUVesKG.png" /></figure><p>In this case, we distinguish errors by providing a unique ID to each alert type. For example, Business Error Alert Type 1 has ID BEA1 and Business Error Alert Type 2 has ID BEA2.</p><p>The process of creating a custom CloudHub alert has two steps:</p><ol><li>Configure the app to send an alert using CloudHub, using the <strong>create notification</strong> operation</li><li>Define the alerts in the Anypoint Platforms Runtime Manager, under the <strong>alerts</strong> section</li></ol><p>In first step, we provide the unique ID (e.g., BEA1) for the alert in the <strong>message</strong> section of CloudHub, using the <strong>create notification</strong> operation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/0*FZqCKxM05KyRRWYA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/0*HEX-v3BSInSOyAZd.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/354/0*rxHXLhOfbmpFOpcP.png" /></figure><p>In the second step, we create the individual alerts in Anypoint Platform Runtime Manager, under the <strong>alerts</strong> section. We specify the same ID (e.g., BEA1) in the <strong>contains section, </strong>which is under <strong>condition</strong> section of the alert.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/0*3pQxbc4m81hlxxIt.png" /></figure><p>In each alert we can define the email addresses of all the recipients of the alert under the <strong>recipients</strong> section.</p><p>We can form form the alert messages in the <strong>message</strong> section of the alert. The required ID (used to recognize the order) can be passed by the application as <strong>custom properties</strong> from the CloudHub <strong>create notification</strong> operation. The ID can also be referred to using ${id} in the <strong>alerts</strong> message section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Npw0a3ZmqRu7Jv0e.png" /></figure><p>CloudHub <strong>create notification</strong> operation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/0*MB7TMwN6YE-fVumQ.png" /></figure><p><strong>Alert in Runtime Manager</strong>:</p><p>The business orchestration logic lies inside the process API(s), so this alert logic can be kept in the process API(s).</p><p><strong>Internal Alerts:</strong> failures in the runtime are unpredictable and we must alert the monitoring team when such failures in the Mule application occur. In such instances, we need an internal error alert.</p><p>A simple way would configure an internal error alert is to package it in your common error handler, which handles all errors in the Mule app and sends notifications to the support team. This type of alerts can occur in any layer, so it can be kept in all API(s).</p><p>What can you use to uniquely identify such errors so that you can identify and find more about the failures in the logs?</p><p>The Mule correlation ID is one solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QLOV5mAtdnnebXkH.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/0*FPwQtZDRvgM6EkWz.png" /></figure><p><strong>Standard Alerts:</strong> we can also set an out-of-the-box alert provided by MuleSoft, such as an alert to indicate a failure in app deployment or if the application exceeds the number of events process. If you want to know more about the standard alerts provided by MuleSoft, please check <a href="https://docs.mulesoft.com/runtime-manager/alerts-on-runtime-manager">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/0*AJOlsqFzBzg2-Miv.png" /></figure><p>Using this simple method, we are able to send seamless email alerts to the appropriate groups. This allows for a quick turn around time for our customer’s support team and we are able to add value to the customer’s business.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cced43cc2706" width="1" height="1" alt=""><hr><p><a href="https://medium.com/another-integration-blog/error-alerts-without-any-external-email-hosting-service-cced43cc2706">Error Alerts without any external email hosting service</a> was originally published in <a href="https://medium.com/another-integration-blog">Another Integration Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Access token management using cache scope in MuleSoft]]></title>
            <link>https://medium.com/@kamalikachaudhuri93/access-token-management-using-cache-scope-in-mulesoft-3682f3a2b0b1?source=rss-482328045b86------2</link>
            <guid isPermaLink="false">https://medium.com/p/3682f3a2b0b1</guid>
            <category><![CDATA[cache-invalidation]]></category>
            <category><![CDATA[object-store]]></category>
            <category><![CDATA[mulesoft]]></category>
            <category><![CDATA[access-token]]></category>
            <dc:creator><![CDATA[kamalika chaudhuri]]></dc:creator>
            <pubDate>Tue, 09 Aug 2022 07:17:50 GMT</pubDate>
            <atom:updated>2022-08-16T11:56:52.059Z</atom:updated>
            <content:encoded><![CDATA[<h3>Managing Access token Expiry:</h3><h3><strong>Managing Access token Expiry:</strong></h3><p>More often than once we have encountered a scenario where to call the actual http endpoint to fetch resource details we have to call another http endpoint to fetch <strong>access token</strong>. This access token has fixed time expiry, for our use case say 10 min. Now we don&#39;t want to call the access token endpoint every time we make the HTTP request in those 10 mins. We want to call the access token endpoint when the access token expires. So In this article we will see how we can configure the cache scope to store the access token and automatically invalidate when the access token expires in 10 mins.</p><p>I have a flow with name get-access-token-sub-flow where I call the access token http endpoint. I have logged the start and end log with time in seconds, to validate the time when this endpoints are getting called.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*gnAS89g4vWVSqNMZsvo1Tw.png" /><figcaption>Flow</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g_fMkqIhyYSVeGV_Siz5qA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*phAqFh2duBZiz5LSrKVjhQ.png" /></figure><p>Now in the test-access-token-caching flow I have put the sub flow reference which calls the access token endpoint in cache scope. And in the start I have put another logger which will log the time in seconds whenever the listener is triggered</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*766xEDUlnHoMXMt-0z6hdg.png" /></figure><pre>&lt;os:config name=”ObjectStore_Config” doc:name=”ObjectStore Config” doc:id=”2c1cdca1-e698–4bea-9125–87697abe8818&quot; &gt;<br> &lt;os:connection &gt;<br> &lt;reconnection &gt;<br> &lt;reconnect /&gt;<br> &lt;/reconnection&gt;<br> &lt;/os:connection&gt;<br> &lt;/os:config&gt;<br> &lt;ee:object-store-caching-strategy name=”Caching_Strategy” doc:name=”Caching Strategy” doc:id=”e7a359f7-f49d-4247–8814–9bad7abb906a” &gt;<br> &lt;os:private-object-store alias=”cache-access-token-os” maxEntries=”1&quot; <strong>entryTtl=”10&quot;</strong> expirationInterval=”5&quot; expirationIntervalUnit=”SECONDS” config-ref=”ObjectStore_Config” /&gt;<br> &lt;/ee:object-store-caching-strategy&gt;</pre><p>Now we detail how you can configure the cache. We are using a object store within cache to store the access token and in the object store we set the entryTtl value as your token validity value so if our token is valid for say 10 seconds my entryTtl = 10 seconds. Know about different object store config parameters <a href="https://docs.mulesoft.com/object-store-connector/1.2/object-store-connector-reference">here</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_rsn5KOHspPY9g6J4xGKXw.png" /></figure><p>If you don&#39;t have object store module imported from exchange you will see this warning as shown below. You can click on adding a module then add object store from exchange. Then close the dialog box remove if any empty caching strategy config created in global section and start again. This time you will see the drop down with options to configure the object store. We have two separate config one where we give the reference in global config and second where we edit inline. I have used edit inline for this scenario. if you need to use the same object store config across multiple config in your project, creating a single separate object store config and giving global reference to that would be a good reusable option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*69ZkKhqdjAwa0KIaBNGm4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*_MOzXOv5DTJi9V8g1s-BSA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NKYYTJdkRqCti63AaKRi9g.png" /></figure><p>Now we deploy the application and test by hitting the listener multiple times. If you see the below log snippets you see</p><p>First request came at 14 seconds so it would be valid till 14+10 = 24 seconds. and if we call in this time we should only see the “Test endpoint called at &lt;XX&gt; seconds” log not the “Start Access Token Call at &lt;XX&gt; seconds” log or “End Access Token Call at &lt;XX&gt; seconds”. Observe the second call at 18 seconds we only see the “Test endpoint called at 18 seconds” log not the “Start Access Token Call at &lt;XX&gt; seconds” log or “End Access Token Call at &lt;XX&gt; seconds . Then again for the third request which came in 48 seconds which is greater than our cache validity of 24 seconds. We see the “Test endpoint called at 48 seconds” log and also the “Start Access Token Call at 48 seconds” log and “End Access Token Call at 49 seconds” log</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*4MW8a3-9iMbZyI4B6WtkFw.png" /></figure><p>In this way we don&#39;t call the access token endpoint multiple times and only call it when it’s validity is over.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3682f3a2b0b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Use salesforce for Oauth Username Password in MuleSoft]]></title>
            <link>https://medium.com/@kamalikachaudhuri93/salesforce-for-oauth-username-password-in-mulesoft-af6467def322?source=rss-482328045b86------2</link>
            <guid isPermaLink="false">https://medium.com/p/af6467def322</guid>
            <category><![CDATA[mulesoft-training]]></category>
            <category><![CDATA[mulesoft]]></category>
            <category><![CDATA[salesforce]]></category>
            <category><![CDATA[oauth]]></category>
            <dc:creator><![CDATA[kamalika chaudhuri]]></dc:creator>
            <pubDate>Sun, 07 Aug 2022 05:56:45 GMT</pubDate>
            <atom:updated>2022-08-07T06:40:10.463Z</atom:updated>
            <content:encoded><![CDATA[<p>This a short blog on how to create a connected app in salesforce to implement Oauth username password authentication in MuleSoft.</p><p>If you don’t have a salesforce account create one <a href="https://developer.salesforce.com/signup">here</a></p><p>To start go to setup-&gt; build-&gt; app-&gt; create connected app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*NBOw4UZaslgimnbgDhdmQQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/1*nr7ytJrUhoMoJ1RhVERYvw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*F6SMytutxH8DDg1NNZIEJg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*KIlmDAhAsQcxxX7YMiAhCg.png" /><figcaption>Fill in you connected app name and give a valid email</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qcZkfI9_wXIR2afSxrchkA.png" /><figcaption>Click on enable Oauth and do the settings as shown</figcaption></figure><p>click save and continue</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*hoOPPxalQkZkS8YV9NwULg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*JUgnc-3Yt1OtyNEFd2ap7g.png" /></figure><p>Now click on manage-&gt; edit policies to relax IP restriction</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fToIgYkGNYCBeBLXyGADHw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N2RZ-g9A84vk2WpvrW4wsQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZD8SPz3aN-G2spNv25NnBQ.png" /></figure><p>Now to get your client id (consumer key)and client secret(consumer secret) go to build -&gt; connected app -&gt; click on your app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lWjdGpoyeh3ocvwdtT3pEQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*iIFhX-EIBiWTybHMQiajuw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*szWt4QQWsy7zRI1PQ1aC-g.png" /></figure><p>With this details now configure it in your studio</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*j7XfWn6dREmOWy9WED0FXA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*bp-qnNI9oymvhODt8pEz7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*dfG0rosGFO-Q3lhhyk6mEg.png" /></figure><p>Thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af6467def322" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SAP Integration with MuleSoft]]></title>
            <link>https://medium.com/another-integration-blog/sap-integration-with-mulesoft-9d3c3b5a3d39?source=rss-482328045b86------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d3c3b5a3d39</guid>
            <category><![CDATA[developer-guide]]></category>
            <category><![CDATA[sap-integration]]></category>
            <category><![CDATA[mulesoft-integration]]></category>
            <category><![CDATA[mulesoft]]></category>
            <dc:creator><![CDATA[kamalika chaudhuri]]></dc:creator>
            <pubDate>Sat, 06 Aug 2022 19:31:08 GMT</pubDate>
            <atom:updated>2022-11-14T22:24:18.543Z</atom:updated>
            <content:encoded><![CDATA[<h3>SAP Integration With MuleSoft</h3><p>This blog is a developers guide to SAP integration with MuleSoft using MuleSoft’s SAP Certified connector. MuleSoft’s SAP Certified connector helps integrate different on-premise and cloud-based business applications with SAP ERP Central Component (ECC) via IDoc or BAPI over RFC, and SAP S/4 Hana via RFC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*s00ehiTo7eX5Iy3x.png" /></figure><p>SAP is an ERP system that holds all of the master data of an organization. For critical use cases, the organization requires CRUD operations to be performed on this master data. SAP is a difficult system to integrate but with MuleSoft’s SAP connector it becomes easy. Using the connector, you can work on an SAP integration with little or no knowledge about SAP, like me. I have successfully worked on two projects involving SAP integration and am currently involved in a third one. I created this blog to share some challenges I have experienced and solutions to over come them. As developers, we face a lot of errors while trying new things; I hope this will be a helpful resource to explain and overcome common errors for anyone who is new to SAP integration and is implementing it in MuleSoft.</p><p><strong>1: Get the connector from Anypoint Exchange: </strong>if the connector is not already present in your studio, you can get it from the Exchange.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*kZ-0pRJHiz6JxxtuX3DgpQ.png" /></figure><p>Once imported, the SAP connector and its operations will be available in the Mule palette, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*nHBBBqnoFpsKhR99TYB0Ug.png" /></figure><p><strong>2.1: Configuration: Setting up the Java Connector Libraries</strong></p><p>The SAP connector supports 3.0.x versions for the libraries. You can add and configure JAR files as Maven dependencies or local files. For Maven dependency, you have to download the JAR file then deploy it in any of your binary repositories. Downloading the JAR from <a href="https://support.sap.com/en/product/connectors/jco.html?anchorId=section_2129803369">SAP Marketplace</a> requires an SAP ID.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*0dF25vU3ES4baLT0.png" /></figure><p><strong>2.2: Configuration: Configure Based on Authentication</strong></p><p>There are two types of authentication: username-password based and certificate based. Certificate based authentication is required when the MuleSoft is the client.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*pgjKP1P6w4k_Cpc_.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*E3ECAgKMz6Wva3JH.png" /></figure><p><strong>2.3: Configuration: Configure Connectivity Based on host</strong></p><p>There are two host types to connect: an application server host or a message server host. You can connect directly to an application server or there might be a message server on top of the application server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ih-LFCujsD3enL3q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*a4T-P6YLKHmNKOGp.png" /></figure><p><strong>3: Operations</strong></p><p>The SAP connector supports a two way exchange of data.</p><p><strong>IDoc:</strong> IDocs is a standard data format defined by SAP for the exchange of information between SAP and non-SAP applications. IDocs are typically used when information needs to be sent to or from SAP without notification requirements. This is primarily used to transfer master data in and out of SAP.</p><p><strong>Business Application Programming Interface (BAPI): </strong>BAPIs are defined interfaces that can be called either by either SAP or non-SAP applications, typically in synchronous scenarios. For example, a customer could use BAPIs to plan new orders or change existing ones. There are hundreds of BAPIs available that provide a broad set of functions for SAP integration.</p><p>Below, we see various IDoc and RFC based operations available in MuleSoft’s SAP Connector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*aw8AePdPPgNn9kFE.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*6RNZ5KqwJX7R25Gc.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*OnEsUH2ogF1U25kA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*maxJ4RWw2Beum14_.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*KRb5z7HH-NbZmcZ3.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Or_r4eICVCJXZCgb.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*XPD0eIShDQzDkb0S.png" /></figure><p><strong>4: Sample Messages</strong></p><p>A Typical RFC XML Payload:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*qL13Vbp9qUsgBjM4.png" /></figure><p>A Typical IDoc XML Payload:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*o4Xf5JUlnS6UZq7v.png" /></figure><p>Based on the configuration on the SAP side, you can receive one of multiple IDocs in a request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*rmTkzbL4KfKW3LaO.png" /></figure><p><strong>5: Troubleshooting</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*j49XNPpLlggbmdMH.png" /></figure><p>Additionally, if the Java Connector (JCo) native library provided is not complaint with the operation system we will get an error. For example, if we have configured sapjco3.dll in CloudHub instead of the libsapjc03.so, we will get an error stating that there is no sapjco3 in the Java library path.</p><p>Some other errors related to the JAR files can occur. For example, an error can occur when we are using a JAR for a 32 bit system, when it should be for a 64 bit system.</p><p>While doing an IDoc connectivity test after deploying to CloudHub, we faced an error that stated gateway registration has failed as the IP was not allowed. Here, we allowed the MuleSoft VPC CIDR range in the SAP external security. Once we received the IDoc, it wasn’t readable. After spending some time on it, we figured out that SAP was not configured to accept Unicode communication. Once that was enabled on SAP side, we were able to read our IDoc and further process it. A gateway registration happens in the connector placed as a listener (i.e. a document listener that listens for IDocs and function listeners that listens for BAPI functions). Program ID creation is required for gateway registration. The SAP system program ID that is registered on the gateway must be unique for the given gateway.</p><p>From this experience, I have listed the addition configuration required on the SAP side for the IDoc or function listener.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*GU2gERy1VOb6JdUM.png" /></figure><p><strong>Reconnection Strategy:</strong></p><p>The reconnection strategy on SAP listeners (document listener and function listener) relies exclusively on the JCo library. This means that the Mule reconnection mechanism has no impact on reconnections.</p><p>The JCo Server that runs in the background manages the reconnection when there is a connection issue. The JCo RFC provider recognizes a communication error between the Java server and the ABAP gateway and attempts to reconnect. If the first reconnection fails, the next reconnection attempt occurs after waiting for one second. If the reconnection fails again, the reconnection wait-time doubles from one second to two seconds, until eventually it reaches the default maximum waiting period of 3600 seconds (or one hour). Set the maximum reconnection timeout using the -Djco.server.max_startup_delay=&lt;reconnect delay in seconds&gt; JMV parameter.</p><p><strong>6 : Useful links</strong></p><ul><li><a href="https://mulesoftprm.force.com/s/article/How-to-tune-automatic-reconnection-in-SAP-Connector">How to tune automatic reconnection in SAP Connector? | MuleSoft Help Center (force.com)</a></li><li><a href="https://docs.mulesoft.com/sap-connector/5.5/sap-connector-studio">SAP Connector 5.5 Studio Configuration — Mule 4 | MuleSoft Documentation</a></li><li><a href="https://docs.mulesoft.com/sap-connector/5.5/sap-connector-troubleshooting">Troubleshooting SAP Connector 5.5 — Mule 4 | MuleSoft Documentation</a></li><li><a href="https://docs.mulesoft.com/sap-connector/5.5/sap-connector-reference">SAP Connector 5.5 Reference — Mule 4 | MuleSoft Documentation</a></li><li><a href="https://support.sap.com/en/product/connectors/jco.html?anchorId=section_2129803369">SAP Java Connector</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d3c3b5a3d39" width="1" height="1" alt=""><hr><p><a href="https://medium.com/another-integration-blog/sap-integration-with-mulesoft-9d3c3b5a3d39">SAP Integration with MuleSoft</a> was originally published in <a href="https://medium.com/another-integration-blog">Another Integration Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Certificate-Based Authentication With the Microsoft Graph API in MuleSoft]]></title>
            <link>https://medium.com/another-integration-blog/using-certificate-based-authentication-with-the-microsoft-graph-api-in-mulesoft-42c58b0b8e2a?source=rss-482328045b86------2</link>
            <guid isPermaLink="false">https://medium.com/p/42c58b0b8e2a</guid>
            <category><![CDATA[microsoft-graph-api]]></category>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[mulesoft]]></category>
            <category><![CDATA[oauth]]></category>
            <dc:creator><![CDATA[kamalika chaudhuri]]></dc:creator>
            <pubDate>Sat, 06 Aug 2022 17:46:52 GMT</pubDate>
            <atom:updated>2022-09-30T19:54:15.819Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*Qshlz3sSO3lqbwPi.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/0*xMww-_xw0EZIU5ez.png" /></figure><p>This article will demonstrate how to get an access token while using <a href="https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow#get-a-token">Microsoft Graph via certificate based authentication</a> in MuleSoft. This is used to access Microsoft Graph API(s) for SharePoint operations, drive operations, etc. As there were no out-of-the-box solutions available for the OAuth client credential authentication using certificate, I have come up with a solution of my own.</p><p>Before we begin, make sure you have set up your <a href="https://docs.microsoft.com/en-us/graph/auth-register-app-v2">Microsoft Azure App</a> and have gotten your certificate (further explanation can be found in <a href="https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-certificate-credentials#register-your-certificate-with-microsoft-identity-platform">Microsoft document</a>). Below, I will cover MuleSoft implementation, assuming that you have the certificate “.pfx” file and the tenant and client ID from the Azure App.</p><p>The steps to get access token are:</p><ol><li>Create a <strong>JWT token</strong> from the .pfx certificate parameters: certificate thumbprint and the private key.</li><li>Using the JWT Token you just created as a parameter, along with client ID and 3 other static parameters, you will get the <strong>bearer access token</strong> to access the Microsoft Graph API resources.</li></ol><p>Please find the implementation steps below. Here is the <a href="https://github.com/kamalikachaudhuri/Using-Certificate-based-Authentication-with-the-Microsoft-Graph-API-MuleSoft">git repo</a> of the implementation to refer to and copy.</p><figure><img alt="Get token sub flow" src="https://cdn-images-1.medium.com/max/736/1*WfL_VCPZdSYogCGapRjHTg.png" /><figcaption>Generate Token Mule Flow</figcaption></figure><ol><li>To create the JWT token, we first extract the thumbprint and and private key from the certificate. I have written two method in Java to fetch the information. Pass the certificate and the password as input to the Java methods from DataWeave. Please find the <a href="https://github.com/kamalikachaudhuri/Using-Certificate-based-Authentication-with-the-Microsoft-Graph-API-MuleSoft/blob/main/src/main/java/com/utils/CommonUtils.java">CommonUtils.java here</a>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/963/1*07xtnumpHTiuiSBP_e8jdQ.png" /><figcaption>Fetching the certificate Thumbprint</figcaption></figure><figure><img alt="Get private key in pem format" src="https://cdn-images-1.medium.com/max/916/1*uorjl6z2hi8Nj51t5P-XEg.png" /><figcaption>Fetching the private key in PEM Format</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f94b8342fcf9afdc63bac92f7b116eef/href">https://medium.com/media/f94b8342fcf9afdc63bac92f7b116eef/href</a></iframe><p>2. To create the JWT token, use the module from this <a href="https://anypoint.mulesoft.com/exchange/68ef9520-24e9-4cf2-b2f5-620025690913/data-weave-jwt-library/minor/1.0/pages/RSA/">DataWeave library</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*WGckm0nXWWbnt8kcsAYNpw.png" /><figcaption>Creating JWT Token for client assertion</figcaption></figure><p>3. Form the multipart payload, as shown below, to do a POST request to Graph API’s endpoint, <a href="https://login.microsoftonline.com/%7Btenant%7D/oauth2/v2.0/token">/{tenant}/oauth2/v2.0/token</a>, using the JWT token, Client ID, and the 3 static parameters.</p><figure><img alt="The input params for the access token request to graph api" src="https://cdn-images-1.medium.com/max/1024/1*CJs4_K1Cy7ZHvki8AkgoxA.png" /><figcaption>Request to graph API for token</figcaption></figure><p>4. After the HTTP request component, form the bearer access token from the Graph API response payload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*V9gLs1DtCYzHJdZTLKFv5w.png" /><figcaption>Form bearer&lt;access-token&gt; from graph API response</figcaption></figure><p>5. Take note of the project structure and the config details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*cLqIQqvDNRpbvK7T-jDjRQ.png" /><figcaption>Project Structure</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PbD84POMaclxiNsrWkEl7g.png" /><figcaption>Config file</figcaption></figure><pre><strong>Please Note Additional Dependencies which are required in POM</strong></pre><pre>&lt;dependency&gt;<br>&lt;groupId&gt;68ef9520–24e9–4cf2-b2f5–620025690913&lt;/groupId&gt;&lt;artifactId&gt;data-weave-jwt-library&lt;/artifactId&gt;&lt;version&gt;1.0.0&lt;/version&gt;<br>&lt;classifier&gt;dw-library&lt;/classifier&gt;<br>&lt;/dependency&gt;</pre><pre>&lt;dependency&gt;<br>&lt;groupId&gt;javax.xml.bind&lt;/groupId&gt;<br>&lt;artifactId&gt;jaxb-api&lt;/artifactId&gt;<br>&lt;version&gt;2.3.1&lt;/version&gt;<br>&lt;/dependency&gt;</pre><p>6. Now, run and test the generate-access-token flow.</p><figure><img alt="Test Access Token Flow" src="https://cdn-images-1.medium.com/max/672/1*it-CYME2wi1dGHuCJNzInA.png" /><figcaption>Test access token flow</figcaption></figure><p>7. And voila, we received the access token!!</p><figure><img alt="Result!!" src="https://cdn-images-1.medium.com/max/1024/1*HP6Ts3hdoJ1dgiQM6WAOsw.png" /><figcaption>After running fetched Access Token in Postman</figcaption></figure><p>And that’s it. Have a great day.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42c58b0b8e2a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/another-integration-blog/using-certificate-based-authentication-with-the-microsoft-graph-api-in-mulesoft-42c58b0b8e2a">Certificate-Based Authentication With the Microsoft Graph API in MuleSoft</a> was originally published in <a href="https://medium.com/another-integration-blog">Another Integration Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>