<?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 Janhavi Bhavsar on Medium]]></title>
        <description><![CDATA[Stories by Janhavi Bhavsar on Medium]]></description>
        <link>https://medium.com/@janhavi1408?source=rss-3d6a41eae220------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TaIcmqCgwCWRPp2f2VCanQ.jpeg</url>
            <title>Stories by Janhavi Bhavsar on Medium</title>
            <link>https://medium.com/@janhavi1408?source=rss-3d6a41eae220------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 11:47:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@janhavi1408/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[Mastering Caching in MuleSoft: Detailed guide on server-side and client-side caching]]></title>
            <link>https://medium.com/@janhavi1408/mastering-caching-in-mulesoft-detailed-guide-on-server-side-and-client-side-caching-7e14ac294a91?source=rss-3d6a41eae220------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e14ac294a91</guid>
            <category><![CDATA[mulesoft]]></category>
            <category><![CDATA[object-store]]></category>
            <category><![CDATA[caching]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[postman]]></category>
            <dc:creator><![CDATA[Janhavi Bhavsar]]></dc:creator>
            <pubDate>Sat, 07 Dec 2024 11:41:44 GMT</pubDate>
            <atom:updated>2024-12-07T11:41:44.603Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*v2MyBoELbxE_3_8kEMaL1g.png" /></figure><h3>What is Caching?</h3><p>Caching is a technique of storing frequently accessed data in a temporary storage area called a cache. By retrieving data from the cache instead of recalculating or fetching it repeatedly, applications can achieve:</p><ul><li><strong>Improved performance</strong>: Faster data retrieval reduces latency.</li><li><strong>Reduced load</strong>: Minimises calls to back-end systems or databases.</li><li><strong>Cost optimisation</strong>: Decreases resource consumption, especially in cloud-based solutions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VZm1BpgMsbkEpUXMgyjXIA.png" /><figcaption>Working of Caching</figcaption></figure><h4>Types of Caching:</h4><ul><li><strong>Client-Side Caching</strong>: Imagine your xapi or papi is making external call to your sapi or other third party system. To improve the performance of these xapi or papi we can wrap up the request in cache scope, this is called client-side caching.</li><li><strong>Server-Side Caching: </strong>Imagine you are working on a sapi , with listens on http port, to reduce sapi’s processing load we apply api caching policy in api manager. This is called server-side caching.</li></ul><p>Both of them use object store to persist the data. Object Store is nothing but a mule connector used to store key-value pair. We mainly use object store to store the tokens, user-info etc. Caching scope and OAuth module use object store internally to store the data and tokens respectively. To know more about object-store please go through this documentation <a href="https://docs.mulesoft.com/object-store/osv2-tutorial">https://docs.mulesoft.com/object-store/osv2-tutorial</a> .</p><h4>Implementing Client-side caching:</h4><ul><li>Create a project in Anypoint Studio.</li><li>From Mule palette add the object store module to the project.</li><li>Now got to your pom.xml and check for the dependency of object store module.If you cannot find the dependency add this code snippet in the dependencies tag.</li></ul><pre>&lt;dependency&gt;<br>   &lt;groupId&gt;org.mule.connectors&lt;/groupId&gt;<br>   &lt;artifactId&gt;mule-objectstore-connector&lt;/artifactId&gt;<br>   &lt;version&gt;1.2.2&lt;/version&gt;<br>   &lt;classifier&gt;mule-plugin&lt;/classifier&gt;<br>  &lt;/dependency&gt;</pre><ul><li>Create a global.xml configuration file to configure the global elements.</li><li>Add the global configuration for http listener.</li><li>Create the configuration for object store.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-3fQL7j4QJICxazC_3KMWQ.png" /><figcaption>Configuration for object store</figcaption></figure><ul><li>Here Entry ttl (Time to live) is set to 60 secs, which means the key-value pair stored in object store will be there for 60 secs and expiration interval is set to 30 secs which means mule runtime will check if the key-value pair is valid and clean up if its invalid.</li><li>Now create the caching strategy in globals.xml .</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YaJ9V5WPyC3K0ro0jF1PDQ.png" /><figcaption>Caching Strategy config</figcaption></figure><ul><li>In Key Expression you can add a key for which you want to have your cache. So for each id new cache will be created.</li><li>Now create the flow containing listener, http-request wrapped into cache scope and loggers.</li></ul><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br><br>&lt;mule xmlns:os=&quot;http://www.mulesoft.org/schema/mule/os&quot; xmlns:ee=&quot;http://www.mulesoft.org/schema/mule/ee/core&quot;<br> xmlns:http=&quot;http://www.mulesoft.org/schema/mule/http&quot;<br> xmlns=&quot;http://www.mulesoft.org/schema/mule/core&quot; xmlns:doc=&quot;http://www.mulesoft.org/schema/mule/documentation&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd<br>http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd<br>http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd<br>http://www.mulesoft.org/schema/mule/os http://www.mulesoft.org/schema/mule/os/current/mule-os.xsd&quot;&gt;<br> &lt;http:listener-config name=&quot;HTTP_Listener_config&quot; doc:name=&quot;HTTP Listener config&quot; doc:id=&quot;6cb7e922-1f5c-4cf1-b3b3-82c9397c4d96&quot; &gt;<br>  &lt;http:listener-connection host=&quot;0.0.0.0&quot; port=&quot;8081&quot; /&gt;<br> &lt;/http:listener-config&gt;<br> &lt;ee:object-store-caching-strategy name=&quot;Caching_Strategy&quot; doc:name=&quot;Caching Strategy&quot; doc:id=&quot;436f1637-5349-4501-b4e6-9fced1bc8413&quot; objectStore=&quot;Object_store&quot; keyGenerationExpression=&quot;#[attributes.uriParams.id]&quot;/&gt;<br> &lt;os:object-store name=&quot;Object_store&quot; doc:name=&quot;Object store&quot; doc:id=&quot;11481d6a-44d9-4058-8b2b-65ff799fda83&quot; entryTtl=&quot;60&quot; expirationInterval=&quot;30&quot; expirationIntervalUnit=&quot;SECONDS&quot; /&gt;<br> &lt;flow name=&quot;caching-demo-apiFlow&quot; doc:id=&quot;dcc9cdfb-b960-4e8f-88ee-1a72e8ed00e1&quot; &gt;<br>  &lt;http:listener doc:name=&quot;Listener&quot; doc:id=&quot;7a627659-365b-4953-8d9d-e6bef829307c&quot; config-ref=&quot;HTTP_Listener_config&quot; path=&quot;/test/{id}&quot;/&gt;<br>  &lt;logger level=&quot;INFO&quot; doc:name=&quot;Logger&quot; doc:id=&quot;565928b2-0d89-4d65-a175-5712a8802306&quot; message=&#39;#[&quot;Started&quot;]&#39;/&gt;<br>  &lt;ee:cache doc:name=&quot;Cache&quot; doc:id=&quot;90e9152c-68dc-40d8-8d76-17b347be0138&quot; cachingStrategy-ref=&quot;Caching_Strategy&quot;&gt;<br>   &lt;http:request method=&quot;GET&quot; doc:name=&quot;Dummy Request&quot; doc:id=&quot;979a75ff-c6bb-48e4-bbc8-b56bce35d7ad&quot; url=&quot;https://reqres.in/api/users/{id}&quot; responseTimeout=&quot;60000&quot;&gt;<br>    &lt;http:uri-params&gt;&lt;![CDATA[#[output application/java<br>---<br>{<br> &quot;id&quot; : attributes.uriParams.id<br>}]]]&gt;&lt;/http:uri-params&gt;<br>   &lt;/http:request&gt;<br>  &lt;/ee:cache&gt;<br>  &lt;logger level=&quot;INFO&quot; doc:name=&quot;Logger&quot; doc:id=&quot;5c21b779-0ba4-4a52-ae3c-82bf75c3c2ec&quot; message=&quot;#[payload]&quot;/&gt;<br>  &lt;logger level=&quot;INFO&quot; doc:name=&quot;Logger&quot; doc:id=&quot;04554f50-9eb9-4ede-a294-31bbaf0da52c&quot; message=&#39;#[&quot;Ended&quot;]&#39;/&gt;<br>  &lt;error-handler &gt;<br>   &lt;on-error-continue enableNotifications=&quot;true&quot; logException=&quot;true&quot; doc:name=&quot;On Error Continue&quot; doc:id=&quot;5dd4cb9b-302e-4bfd-b3cb-40d601e25da8&quot; &gt;<br>    &lt;ee:transform doc:name=&quot;Transform Message&quot; doc:id=&quot;f80e693f-5eca-4f09-b576-9d17100d901f&quot; &gt;<br>     &lt;ee:message &gt;<br>      &lt;ee:set-payload &gt;&lt;![CDATA[%dw 2.0<br>output application/json<br>---<br>error.errorMessage.payload]]&gt;&lt;/ee:set-payload&gt;<br>     &lt;/ee:message&gt;<br>    &lt;/ee:transform&gt;<br>    &lt;logger level=&quot;INFO&quot; doc:name=&quot;Logger&quot; doc:id=&quot;f41b24b1-deec-4231-9789-ad174b607d18&quot; message=&quot;#[error.errorMessage.payload]&quot;/&gt;<br>   &lt;/on-error-continue&gt;<br>  &lt;/error-handler&gt;<br> &lt;/flow&gt;<br>&lt;/mule&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CkGJJVv43PgaFiPTQbZ5yQ.png" /><figcaption>Cache-Scope demo flow</figcaption></figure><ul><li>Now run the project. You’ll see the time which took to return the response first is higher than the response time of second call.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*928TYZi_9Ehx37W5n7vQTw.png" /><figcaption>first call response</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OP6mHy48idb38Q9EvS6qFQ.png" /><figcaption>second call response</figcaption></figure><p><strong>Note:</strong> Cache scope cannot cache variables it can only cache payload so don’t sent the target variable for payload received by request.</p><ul><li>Lets deploy our api to cloud-hub 2.0 and hit the endpoints to check if it is working as expected.</li><li>Go to object store on runtime manager.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PIMERFduylq9MHMCiV6lug.png" /><figcaption>Object Store</figcaption></figure><ul><li>You can check the keys present in cache, you can also delete the cache keys or clear the cache by using invalidate key and invalidate cache respectively in your flow.</li><li>Lets try to see the working of invalidate cache and invalidate key.</li><li>Update the code by adding choice condition, if the action provided in queryParams is ClearCache it clears cache, if its ClearKey it clears the particular id which is in uriParams, if action is not provided it should make external call to fetch the user details.</li><li>Here is the code snippet for your help.</li></ul><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br><br>&lt;mule xmlns:os=&quot;http://www.mulesoft.org/schema/mule/os&quot; xmlns:ee=&quot;http://www.mulesoft.org/schema/mule/ee/core&quot;<br> xmlns:http=&quot;http://www.mulesoft.org/schema/mule/http&quot;<br> xmlns=&quot;http://www.mulesoft.org/schema/mule/core&quot; xmlns:doc=&quot;http://www.mulesoft.org/schema/mule/documentation&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd<br>http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd<br>http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd<br>http://www.mulesoft.org/schema/mule/os http://www.mulesoft.org/schema/mule/os/current/mule-os.xsd&quot;&gt;<br> &lt;http:listener-config name=&quot;HTTP_Listener_config&quot; doc:name=&quot;HTTP Listener config&quot; doc:id=&quot;6cb7e922-1f5c-4cf1-b3b3-82c9397c4d96&quot; &gt;<br>  &lt;http:listener-connection host=&quot;0.0.0.0&quot; port=&quot;8081&quot; /&gt;<br> &lt;/http:listener-config&gt;<br> &lt;ee:object-store-caching-strategy name=&quot;Caching_Strategy&quot; doc:name=&quot;Caching Strategy&quot; doc:id=&quot;436f1637-5349-4501-b4e6-9fced1bc8413&quot; objectStore=&quot;Object_store&quot; keyGenerationExpression=&quot;#[attributes.uriParams.id]&quot;/&gt;<br> &lt;os:object-store name=&quot;Object_store&quot; doc:name=&quot;Object store&quot; doc:id=&quot;11481d6a-44d9-4058-8b2b-65ff799fda83&quot; entryTtl=&quot;60&quot; expirationInterval=&quot;30&quot; expirationIntervalUnit=&quot;SECONDS&quot; /&gt;<br> &lt;flow name=&quot;caching-demo-apiFlow&quot; doc:id=&quot;dcc9cdfb-b960-4e8f-88ee-1a72e8ed00e1&quot; &gt;<br>  &lt;http:listener doc:name=&quot;Listener&quot; doc:id=&quot;7a627659-365b-4953-8d9d-e6bef829307c&quot; config-ref=&quot;HTTP_Listener_config&quot; path=&quot;/test/{id}&quot;/&gt;<br>  &lt;logger level=&quot;INFO&quot; doc:name=&quot;Logger&quot; doc:id=&quot;565928b2-0d89-4d65-a175-5712a8802306&quot; message=&#39;#[&quot;Started&quot;]&#39;/&gt;<br>  &lt;choice doc:name=&quot;Choice&quot; doc:id=&quot;553b98bd-6c5d-4929-b615-50e2afa2cdfc&quot; &gt;<br>   &lt;when expression=&#39;#[attributes.queryParams.action~=&quot;ClearKey&quot;]&#39;&gt;<br>    &lt;ee:invalidate-key doc:name=&quot;Invalidate Key&quot; doc:id=&quot;c9f6cb57-8f37-4120-8ba1-ca5fee57e9cf&quot; cachingStrategy-ref=&quot;Caching_Strategy&quot; keyGenerationExpression=&quot;#[attributes.uriParams.id]&quot;/&gt;<br>   &lt;/when&gt;<br>   &lt;when expression=&#39;#[attributes.queryParams.action~=&quot;ClearCache&quot;]&#39;&gt;<br>    &lt;ee:invalidate-cache doc:name=&quot;Invalidate Cache&quot; doc:id=&quot;4580a070-8d8f-4ef4-8863-f2ae6990b974&quot; cachingStrategy-ref=&quot;Caching_Strategy&quot;/&gt;<br>   &lt;/when&gt;<br>   &lt;otherwise &gt;<br>    &lt;ee:cache doc:name=&quot;Cache&quot; doc:id=&quot;90e9152c-68dc-40d8-8d76-17b347be0138&quot; cachingStrategy-ref=&quot;Caching_Strategy&quot;&gt;<br>   &lt;http:request method=&quot;GET&quot; doc:name=&quot;Dummy Request&quot; doc:id=&quot;979a75ff-c6bb-48e4-bbc8-b56bce35d7ad&quot; url=&quot;https://reqres.in/api/users/{id}&quot; responseTimeout=&quot;60000&quot;&gt;<br>    &lt;http:uri-params&gt;&lt;![CDATA[#[output application/java<br>---<br>{<br> &quot;id&quot; : attributes.uriParams.id<br>}]]]&gt;&lt;/http:uri-params&gt;<br>   &lt;/http:request&gt;<br>  &lt;/ee:cache&gt;<br>   &lt;/otherwise&gt;<br>  &lt;/choice&gt;<br>  &lt;logger level=&quot;INFO&quot; doc:name=&quot;Logger&quot; doc:id=&quot;5c21b779-0ba4-4a52-ae3c-82bf75c3c2ec&quot; message=&quot;#[payload]&quot;/&gt;<br>  &lt;logger level=&quot;INFO&quot; doc:name=&quot;Logger&quot; doc:id=&quot;04554f50-9eb9-4ede-a294-31bbaf0da52c&quot; message=&#39;#[&quot;Ended&quot;]&#39;/&gt;<br>  &lt;error-handler &gt;<br>   &lt;on-error-continue enableNotifications=&quot;true&quot; logException=&quot;true&quot; doc:name=&quot;On Error Continue&quot; doc:id=&quot;5dd4cb9b-302e-4bfd-b3cb-40d601e25da8&quot; &gt;<br>    &lt;ee:transform doc:name=&quot;Transform Message&quot; doc:id=&quot;f80e693f-5eca-4f09-b576-9d17100d901f&quot; &gt;<br>     &lt;ee:message &gt;<br>      &lt;ee:set-payload &gt;&lt;![CDATA[%dw 2.0<br>output application/json<br>---<br>error.errorMessage.payload]]&gt;&lt;/ee:set-payload&gt;<br>     &lt;/ee:message&gt;<br>    &lt;/ee:transform&gt;<br>    &lt;logger level=&quot;INFO&quot; doc:name=&quot;Logger&quot; doc:id=&quot;f41b24b1-deec-4231-9789-ad174b607d18&quot; message=&quot;#[error.errorMessage.payload]&quot;/&gt;<br>   &lt;/on-error-continue&gt;<br>  &lt;/error-handler&gt;<br> &lt;/flow&gt;<br>&lt;/mule&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aptaNNEdWeyUjIDuqcOebA.png" /><figcaption>code for invalidate cache and invalidate key</figcaption></figure><ul><li>Lets check it by deploying it to cloud-hub. Hit the endpoint with add 2–3 keys in cache.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I-UE0QUni7kjTCaVwmunjw.png" /><figcaption>Cache created for userIds</figcaption></figure><ul><li>Now lets delete the key for id 2 by hitting endpoint giving action as clearKey.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mt-mzVA-ahmggA4Esj57yg.png" /><figcaption>The key is cleared</figcaption></figure><ul><li>Now lets clear the cache by hitting the endpoint giving action as clearCache.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ulwT4YdkjbFQXsTtyTL6Pg.png" /><figcaption>Cache is cleared</figcaption></figure><p>Now lets implement server-side caching strategy.</p><ul><li>Create an API instance in API Manager.</li><li>Create a sample api with auto-discovery and deploy it on cloud-hub with object store v2 enabled.</li><li>In API Manager apply http caching policy for the api.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KgMA6p-ZRfpBo_qVnNTqqA.png" /><figcaption>Applying HTTP Caching Policy</figcaption></figure><ul><li>If we check distributed, the cache will be distributed across workers.</li><li>We check persistent cache to ensure no data is lost.</li><li>We can also add invalidate cache headers, to clean up the cache.</li><li>In invalidate headers we can pass the header we will use to invalidate the cache.</li><li>Conditional request checks for the condition and only caches the data if the conditions are met. In our case if the method is post and the response returned has 200 status code then only it will cache the data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7KAeUo-rxM5iK_YyQCaTiQ.png" /></figure><ul><li>Lets apply this policy and make calls to this api.</li><li>You can observe the cache created in object store.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sqOqCVuorB0mKCW9KGLaSg.png" /></figure><ul><li>Now lets clear the cache by using invalidate header which we provided.</li><li>In postman add the header which you added in invalidate headers while creating policy. I had used “x-remove-cache”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FZsqakvE0EE7i43PnBNEDQ.png" /></figure><ul><li>Now when you hit the endpoint you’ll notice the cache has been cleared except for the id 1.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bmOL-dXVL3P1QK2xnITZWA.png" /></figure><ul><li>This is because when you hit the endpoint all cache got cleared but at the same time cache got created for test/1.</li></ul><p>This how we implement cache scope and caching policy in MuleSoft. Caching plays a very import role when the external calls are time consuming, or the data doesn&#39;t change that frequently.</p><p>Thanks for making it till the end and I hope this guide has covered all the aspects of caching in MuleSoft and you’ll be comfortable in handling time consuming calls in your upcoming projects. See you soon with another interesting blog! until then</p><p><em>“Keep pushing, Keep achieving!”</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e14ac294a91" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Event Driven Architecture with Solace + MuleSoft: Detailed guide on Pub-Sub+ Module]]></title>
            <link>https://medium.com/@janhavi1408/event-driven-architecture-with-solace-mulesoft-detailed-guide-on-pub-sub-module-1c95621dac3b?source=rss-3d6a41eae220------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c95621dac3b</guid>
            <category><![CDATA[mulesoft]]></category>
            <category><![CDATA[pub-sub]]></category>
            <category><![CDATA[event-driven-architecture]]></category>
            <category><![CDATA[hands-on-tutorials]]></category>
            <category><![CDATA[solace]]></category>
            <dc:creator><![CDATA[Janhavi Bhavsar]]></dc:creator>
            <pubDate>Mon, 02 Dec 2024 05:12:35 GMT</pubDate>
            <atom:updated>2024-12-02T05:12:35.703Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*4gJeSS2Nq5TA0TsGa-soYg.png" /></figure><p>In today’s fast-paced digital world, businesses rely on real-time data processing to enhance customer experiences, optimise operations, and remain competitive. Event-driven architecture (EDA) is pivotal in enabling real-time communication between systems, leveraging events as the core mechanism for integration.</p><h4><strong>What is Event Driven Architecture?</strong></h4><p>Event-driven architecture is a design pattern where components interact through events. An event can be a change in state (e.g., a new customer signup) or a significant occurrence (e.g., an inventory update). EDA comprises three main components:</p><ol><li><strong>Event Producers</strong>: Systems or applications that generate events.</li><li><strong>Event Brokers</strong>: Middleware facilitating the event flow (e.g., Solace).</li><li><strong>Event Consumers</strong>: Systems or applications that react to the events.</li></ol><p>PubSub+ event brokers support the following endpoint types for receiving, storing, and delivering Guaranteed messages:</p><ul><li><a href="https://docs.solace.com/Messaging/Guaranteed-Msg/Queues.htm">Queues</a></li><li><a href="https://docs.solace.com/Messaging/Guaranteed-Msg/Topic-Endpoints.htm">Topic Endpoints</a></li></ul><p><strong>Topics</strong>: A topic is a communication channel where messages are published by producers and subscribed to by consumers, often used in a <strong>publish-subscribe</strong> messaging pattern. Here is a real time example where topics can be used:</p><p>For a food delivery app to show the status to both consumer and Driver topics can be used.</p><ul><li><strong>Topic</strong>: orders/{city}/{status}</li><li>Example: orders/nyc/delivered</li><li>When an order status changes, messages are published to this topic.</li></ul><p><strong>Subscribers</strong>:</p><ul><li><strong>Customer App</strong>: Subscribes to orders/nyc/* to show the current order status in real-time.</li><li><strong>Driver App</strong>: Subscribes to orders/nyc/assigned to get new delivery assignments.</li></ul><p><strong>Queues</strong>: A queue is a messaging endpoint used for point-to-point communication, where each message is processed by only one consumer. Here is a real time example where queue can be used:</p><p>When the food is delivered the feedback from customer is taken to improve the service and performance this can be achieved by queue.</p><p><strong>Queue</strong>: feedback/processing</p><ul><li>Customer feedback messages are stored here for offline processing and sentiment analysis.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v_rzzlDiNo_jIuUWeuklLA.png" /><figcaption>Working of Queues And Topics in Solace</figcaption></figure><p><strong>Note:</strong> In Solace pub-sub+ event portal queues subscriptions can be configured as a property of the queue itself. If you delete a queue for any reason, all topic subscriptions configured for that queue are also deleted. Topic endpoints provide filtering option in solace pub-sub+ event portal and therefore it is widely used.</p><p>Here is a demo project to understand pub-sub+ module:</p><ul><li>Go to solace pub-sub+ event portal.(Create a trial account for practice purpose.)</li><li>Open Cluster-Manager → Create Service.</li><li>Give the name for your service. Select the Cloud,Region ,Broker Release, Broker Version and create the service.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JzzY_GQTwGqDhAt7Lhm2dQ.png" /><figcaption>Create Service in Cluster Manager</figcaption></figure><ul><li>Once the service is created you’ll see a page like this.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PXmNTwZNLrtio4kIua-72w.png" /></figure><ul><li>Now go to the Manage tab and click on queues. Click on + Queue button on top right to create queue.</li><li>Give a Name to your queue and keep the queue settings as default. Now click on create queue.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0n6r2i36rVw8Uk0EfztUlQ.png" /><figcaption>Creating queue in solace</figcaption></figure><ul><li>Click on demo-queue. And click on subscriptions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-lW8zb4oTZUdcf5gU-du5w.png" /></figure><ul><li>Click on + Subscription on the top right corner and give the name of your topic.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-E3smajVbIagtQsNfYjzYg.png" /><figcaption>create two topics for our demo queue</figcaption></figure><ul><li>Now go to Anypoint studio and create a demo project.</li><li>Import solace pubsub+ connector from exchange.</li><li>Go to pom.xml and see if this type of code snippet is added in your pom file. If not please copy paste the below code snippet into your pom.xml inside your dependencies tag .</li></ul><pre>&lt;dependency&gt;<br>   &lt;groupId&gt;com.solace.connector&lt;/groupId&gt;<br>   &lt;artifactId&gt;solace-mulesoft-connector&lt;/artifactId&gt;<br>   &lt;version&gt;1.5.0&lt;/version&gt;<br>   &lt;classifier&gt;mule-plugin&lt;/classifier&gt;<br>  &lt;/dependency&gt;</pre><ul><li>Create the global config for Solace pubSub+ global Connector configuration in your globals.xml .</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UY7DGCUj49cnrkYUlmQXJw.png" /></figure><ul><li>To get these details go to solace → Cluster Manager → Connect → Solace JMS API.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VrljObsOtVl01Uz9B8LYFQ.png" /><figcaption>Use this connection details to configure the Solace PubSub + Connector in Anypoint Studio</figcaption></figure><ul><li>Create a flow to publish messages to a topic.</li></ul><pre>&lt;solace:publish doc:name=&quot;Publish to Topic&quot; doc:id=&quot;b0f47406-a72b-4220-964d-81ef57f4158e&quot; config-ref=&quot;Solace_PubSub__Connector_Config&quot; address=&quot;first/topic/12&quot;/&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*__bIUogo5yJ6YF7zjRhynA.png" /></figure><ul><li>Create a flow to consume message from the topic.</li></ul><pre>&lt;solace:topic-listener topics=&quot;first/topic/12&quot; doc:name=&quot;Direct Topic Subscriber&quot; doc:id=&quot;09c77369-9234-4cf1-b80c-8f305da53d68&quot; config-ref=&quot;Solace_PubSub__Connector_Config&quot;/&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*FYWZgzoOqHZikXmiPy5hyg.png" /></figure><ul><li>Try to publish the flow by hitting the endpoint.You’ll notice the message being published to the topic and then automatically consumed by the subscriber.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3OWjPaJKHMMOObZtBACt2A.png" /><figcaption>Topic being published and subscribed</figcaption></figure><p>Now lets publish and consume messages from queue:</p><ul><li>Create a flow to publish messages to a persistent queue.</li></ul><pre>&lt;solace:publish doc:name=&quot;Publish&quot; doc:id=&quot;5463b3d4-656d-42c6-b190-0af383bb446b&quot; config-ref=&quot;Solace_PubSub__Connector_Config&quot; destinationType=&quot;QUEUE&quot; address=&quot;demo-queue-without-sub&quot;/&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*Ef_9kOm-I5246eKGpPXusA.png" /><figcaption>Flow to publish the message to the queue</figcaption></figure><ul><li>Hit the endpoint and publish the message to the queue.</li><li>Go to solace and see if you can see the message in the queue.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eQPf2RbhAYW2vxJhFXIXFA.png" /><figcaption>See the Message Queued the count is 1 which means message is published to queue</figcaption></figure><ul><li>Create the flow to consume the message.</li></ul><pre>&lt;solace:consume doc:name=&quot;Consume&quot; doc:id=&quot;2a32bc1a-d275-46ba-a386-3bb3b680a4ac&quot; config-ref=&quot;Solace_PubSub__Connector_Config&quot; address=&quot;demo-queue-without-sub&quot;/&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*FnTKb83cPxOHdyXaXQbD8w.png" /><figcaption>Flow to consume the message published to queue</figcaption></figure><ul><li>Hit the endpoint to consume the message.</li><li>Go to solace and see if the message count is reduced to zero.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lt4S_6_Sd9yMR3D4goGKqw.png" /><figcaption>This means our message has been consumed</figcaption></figure><p>Do you want your messages to be consumed as soon as it gets published to the queue? Yes, this can be achieved through Guaranteed endpoint listener. Here is how it works:</p><ul><li>Create the flow by dragging and dropping Guaranteed endpoint listener in the source section.</li></ul><pre>&lt;solace:queue-listener doc:name=&quot;Guaranteed Endpoint Listener&quot; doc:id=&quot;f265c5ef-a763-489c-9945-6194bfc6b603&quot; config-ref=&quot;Solace_PubSub__Connector_Config&quot; address=&quot;demo-queue-without-sub&quot;/&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*IKGwBZJORg8PPKkKx_wpVw.png" /><figcaption>Consume messages using Guaranteed Endpoint Listener</figcaption></figure><ul><li>Now hit the endpoint to publish message to queue.You’ll notice the queued messages count will not increase in solace. This is because as soon as the message is published to the queue, it is consumed.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fk7gRe5ytrkygheGUbq7xw.png" /><figcaption>The message published is consumed immediately</figcaption></figure><p>Now if you don‘t want to immediately consume the messages or want to consume the messages with in some fixed amount of time or schedule to consume the messages in the queue, this can be done with Guaranteed endpoint polling listener.</p><ul><li>Create a flow to consume the messages in the queue after a particular period of time or schedule the consumption of messages using cron expression.</li></ul><pre>&lt;solace:polling-queue-listener address=&quot;demo-queue-without-sub&quot; doc:name=&quot;Guaranteed Endpoint Polling Listener&quot; doc:id=&quot;46238c91-fa73-4a20-9481-9aa1ef0828e1&quot; config-ref=&quot;Solace_PubSub__Connector_Config&quot;&gt;<br>   &lt;solace:polling-config-factory &gt;<br>    &lt;solace:default-polling-config-factory fetchSize=&quot;2&quot; &gt;<br>     &lt;scheduling-strategy &gt;<br>      &lt;fixed-frequency frequency=&quot;6000&quot; startDelay=&quot;20000&quot;/&gt;<br>     &lt;/scheduling-strategy&gt;<br>    &lt;/solace:default-polling-config-factory&gt;<br>   &lt;/solace:polling-config-factory&gt;<br>  &lt;/solace:polling-queue-listener&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*euAXRjldN2Ekt4Yp_a2tWQ.png" /></figure><ul><li>Publish multiple messages to the queue.</li></ul><p>You’ll notice the messages will start to be consumed after start delay in a batch of 2(because we configured the batch size to be 2) and between two consecutive batches the delay of 6 sec can we noticed (as we configured frequency to be 6 secs).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2_xs99FpXk8xvp3hQ70Vag.png" /><figcaption>Logs for Guaranteed Endpoint polling listener</figcaption></figure><p>Now, If you go to consume or guaranteed endpoint listener component component, you see the option to configure the acknowledgement Mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oThdW12fsKviseEuFCFMMg.png" /><figcaption>Acknowledgement Modes</figcaption></figure><p>There are 3 Ack Modes:</p><ul><li><strong>Automatic Immediate:</strong> This sends the acknowledgement as soon as the message is consumed. This is the default setting.</li><li><strong>Automatic on flow completion:</strong> This sends acknowledgement when the flow completes successfully.</li><li><strong>Manual Client:</strong> If you select this mode you’ll have to add the Ack component to get the acknowledgement.</li></ul><p>Let’s see a scenario how manual client works.</p><ul><li>Edit the acknowledgement mode in consume to Manual Client.</li><li>Also Add a raise error component in flow so that the flow goes into error.</li><li>In Error handling part add Recover session, this will redeliver the message if the message has not been consumed/the acknowledgement for message consumption has not be received.</li></ul><pre>  &lt;error-handler&gt;<br>   &lt;on-error-propagate enableNotifications=&quot;true&quot; logException=&quot;true&quot; doc:name=&quot;On Error Propagate&quot; doc:id=&quot;2e98783a-ffcc-41af-bd89-57939fe81f93&quot; &gt;<br>    &lt;solace:recover-session doc:name=&quot;Recover Session&quot; doc:id=&quot;a992bb5d-c1cd-4b10-92be-96552d90c96c&quot; config-ref=&quot;Solace_PubSub__Connector_Config&quot; messageRefId=&quot;#[attributes.messageReferenceId]&quot;/&gt;<br>    &lt;logger level=&quot;INFO&quot; doc:name=&quot;Logger&quot; doc:id=&quot;f4ad392d-47b3-4ca0-92aa-c7fbf0d1c905&quot; message=&quot;#[payload]&quot;/&gt;<br>   &lt;/on-error-propagate&gt;<br>  &lt;/error-handler&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BfwmCT2_RbMK34Ug-7KQdQ.png" /><figcaption>Error in Consuming the message</figcaption></figure><ul><li>Now hit the endpoint and publish the message to the queue. And try to consume the message by hitting the consume endpoint.</li></ul><p>What do you notice? Yes, Even though the message was consumed and after that the error was occurred, you see the message in the queue. This is because the message wasn&#39;t acknowledged , so our Recover session component redelivered the message to the queue.</p><p>In case if you would’ve kept the ack mode as Automatic Immediate the recover session will throw the error that the message is not found in cache.</p><p>This left me wondering what happens if error occurs in guaranteed endpoint listener?Let’s see by adding raise error in guaranteed listener flow. Ohh! Did you get flooded with error logs?How can we handle that? There is circuit breaker for this purpose.You can configure circuit breaker in global config and use it to handle errors in guaranteed listener.</p><ul><li>Create global config for circuit breaker in globals.xml .</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A4qSGVVJ0Yu07c5tv6aayQ.png" /><figcaption>Config for circuit breaker</figcaption></figure><ul><li>Now add this into guaranteed listener endpoint.</li></ul><pre>&lt;solace:queue-listener doc:name=&quot;Guaranteed Endpoint Listener&quot; doc:id=&quot;f265c5ef-a763-489c-9945-6194bfc6b603&quot; config-ref=&quot;Solace_PubSub__Connector_Config&quot; address=&quot;demo-queue-without-sub&quot; ackMode=&quot;AUTOMATIC_ON_FLOW_COMPLETION&quot; circuitBreaker=&quot;Circuit_breaker&quot;/&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JESE-f51M7HOEBDeV_9LIw.png" /></figure><ul><li>Publish the message to the queue.You’ll notice it will try to consume the messages for 2 times then wait for 1 min as per our configuration and try again till we get the ack of message being consumed.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e4mhlsKNnEtnllN71V__4A.png" /><figcaption>logs showing the working of circuit breaker</figcaption></figure><p>I hope you were able to get a clear picture of Event driven Architecture and implementing Event driven architecture with pub sub + Module. Thanks for staying till the end! Hope to see you soon with another interesting blog. Till then</p><p><em>“Keep learning, Keep growing”!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c95621dac3b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Secure and Efficient Data Handling in DataWeave: A Guide to Binary, Crypto and MIME Modules]]></title>
            <link>https://medium.com/@janhavi1408/secure-and-efficient-data-handling-in-dataweave-a-guide-to-binary-crypto-and-mime-modules-46aa2711fd53?source=rss-3d6a41eae220------2</link>
            <guid isPermaLink="false">https://medium.com/p/46aa2711fd53</guid>
            <category><![CDATA[file-processing]]></category>
            <category><![CDATA[dataweave]]></category>
            <category><![CDATA[mulesoft]]></category>
            <category><![CDATA[mime]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Janhavi Bhavsar]]></dc:creator>
            <pubDate>Fri, 15 Nov 2024 12:04:43 GMT</pubDate>
            <atom:updated>2024-11-15T12:18:51.525Z</atom:updated>
            <content:encoded><![CDATA[<p>DataWeave as we know is well-known for handling a wide range of data formats and its transformations. Among its advanced features are modules like <strong>MIME</strong>, <strong>Binary</strong>, and <strong>Crypto</strong>, which play a pivotal role in real-world integration scenarios.</p><p>These modules are designed to address specific needs, such as handling file formats, encoding/decoding binary data, and securing sensitive information through encryption and hashing.</p><ul><li><strong>Binary Module</strong> (dw::core::Binaries): Provides tools for handling binary data, such as encoding to and decoding from Base64. This is especially useful for file processing, handling secure data, and encoding non-text data formats.</li></ul><p>Here are the built-in functions and their uses :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qpydIBJADWtJYuvqhj4vgA.png" /><figcaption>Examples of built-in functions in Binary Module</figcaption></figure><ul><li><strong>Crypto Module</strong> (dw::Cypto): Provides us the functions to perform the cryptographic operations such as hashing, encryption, decryption etc using some of the common algorithms such as MD5,SHA1,SHA256,SHA512,AES etc.</li></ul><p>Here are the built-in functions and their uses :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cjnr8pQKST9UQoGhjQOc2g.png" /><figcaption>Examples of built-in functions in Crypto-Module</figcaption></figure><ul><li>Mime Module (dw::module::Mime ): Provides tools to work with <strong>MIME-compliant data</strong>. MIME (Multipurpose Internet Mail Extensions) is a standard used for encoding and structuring different types of data, such as text, images, videos, and other multimedia, into a format that can be safely transmitted over protocols like email or HTTP.</li></ul><p>Here are the built-in functions and their uses :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VIMoQ5-u_bN3Ljv5bq9dwg.png" /><figcaption>Examples of built-in functions in Mime Module</figcaption></figure><p>Combining the <strong>MIME</strong>, <strong>Crypto</strong>, and <strong>Binary</strong> modules in DataWeave provides a comprehensive solution for securely handling files and data. Use cases include:</p><ul><li>Secure file upload and download with encryption and integrity checks.</li><li>Secure Email Attachment Handling with Encryption and MIME Types.</li><li>API communication with authentication and encrypted file transfers.</li><li>Handling of sensitive data for secure storage, with HMAC for authentication and hashing for integrity verification.</li></ul><p>By leveraging these modules together, you can ensure confidentiality, authenticity, and integrity across various integration and communication workflows.</p><p><em>Thanks for staying till the end. I hope you found it helpful. Please reach out to me in case of any questions or suggestions. See you soon with another interesting blog!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46aa2711fd53" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sleep Processor in Munit]]></title>
            <link>https://medium.com/@janhavi1408/sleep-processor-in-munit-720a0bfe9c28?source=rss-3d6a41eae220------2</link>
            <guid isPermaLink="false">https://medium.com/p/720a0bfe9c28</guid>
            <category><![CDATA[munit]]></category>
            <category><![CDATA[async]]></category>
            <category><![CDATA[mulesoft]]></category>
            <category><![CDATA[sleep]]></category>
            <dc:creator><![CDATA[Janhavi Bhavsar]]></dc:creator>
            <pubDate>Fri, 08 Nov 2024 12:58:47 GMT</pubDate>
            <atom:updated>2024-11-08T12:58:47.190Z</atom:updated>
            <content:encoded><![CDATA[<p>The Sleep processor allows us to pause the test for a specific time. We can use this processor to simulate a delay in the processing of the flow:</p><pre>&lt;munit-tools:sleep time=&quot;100&quot; timeUnit=&quot;MILLISECONDS&quot;/&gt;</pre><p>Use-cases where you can use sleep processor:</p><ol><li>The processes going on into async scope can be time consuming , sleep processor can help simulate delays or ensure that asynchronous processing completes before asserting results.</li><li>In case of batch job, it is an Asynchronous process where the threads execute in parallel and asynchronously and since, Munit is a synchronous process for which it’s a challenge.</li></ol><p>In such scenarios where the flow runs asynchronously we can leverage sleep processor as it will let the main thread in Munit sleep for the expected time in which the threads executing into asynchronous/ batch will complete the processing and by the time the main thread will be awake we can assert the results in the validation part of Munit flow.</p><p>Here is a sample flow which uses sleep processor to cover the Munit for the asynchronous flow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Pm_LccQveMX6Tlth3tihA.png" /><figcaption>Sample Async Flow</figcaption></figure><p>The sample async flow sends the acknowledgement of flow being called immediately , calls external rest service and sends the response through email asynchronously.</p><p>Here is the Munit test for the sample async flow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*d-dJDNJZGmoT0BnjfKn1TA.png" /><figcaption>Munit Test for Async Flow</figcaption></figure><p>To test the flow and cover the components used inside of async scope we have leveraged sleep processor as it pauses the main thread for the configured time which will allow the flow inside of async scope to complete.</p><p>Here is the configuration of sleep processor:</p><pre>&lt;munit-tools:sleep time=&quot;100&quot; doc:name=&quot;Sleep&quot; doc:id=&quot;21355b00-7a1c-4866-9da3-ffc3b7c82dd1&quot; timeUnit=&quot;SECONDS&quot; /&gt;</pre><p>We can configure the expected time in which the threads running asynchronously can complete successfully.</p><p><em>Hope this blog helped you understand the use-case of sleep processor so you could use it in your upcoming projects. Thanks !</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=720a0bfe9c28" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>