<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Manik Magar</title>
    <description>The latest articles on DEV Community by Manik Magar (@manikmagar).</description>
    <link>https://dev.to/manikmagar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F55221%2Fd8e56e17-3f7a-4636-b970-3203cca81c83.jpeg</url>
      <title>DEV Community: Manik Magar</title>
      <link>https://dev.to/manikmagar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/manikmagar"/>
    <language>en</language>
    <item>
      <title>Introducing - Mule Flow Diagrams</title>
      <dc:creator>Manik Magar</dc:creator>
      <pubDate>Fri, 17 Apr 2020 00:00:00 +0000</pubDate>
      <link>https://dev.to/manikmagar/introducing-mule-flow-diagrams-47fe</link>
      <guid>https://dev.to/manikmagar/introducing-mule-flow-diagrams-47fe</guid>
      <description>&lt;p&gt;Mule applications are written in xml language with predefined XML schemas. Flows and sub-flows, along with other components are the base constructs of a Mule application. An application is usually a collection of multiple flows and sub-flows, spread across multiple configuration files. All of these can reference each other for processing messages. Often times, data can also be exchanged synchronously or asynchronously using connectors. When analyzing mule application, it can get difficult to see the complete data processing flow and their dependencies. In studio, you can keep jumping between flows to understand the processing flow but it is time consuming.&lt;/p&gt;

&lt;p&gt;Have you ever wished to visualize your flow dependencies in a diagram? How does message flows through your application? Which sub-flows are called and in which order?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If yes, then this is for you!&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Introducing&lt;/em&gt; &lt;strong&gt;Mule flow diagrams&lt;/strong&gt; , a tool that can scan your mule projects and generate diagrams such as Graph of your mule application code.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  What it does?
&lt;/h3&gt;

&lt;p&gt;Consider following mule 4 configuration file that has some flows, sub-flow, and connectivity over VM and HTTP connector. Reading this XML or even seeing it in studio design mode may not easily tell how message flows through this application.&lt;/p&gt;

&lt;h1&gt;
  
  
  Click &lt;strong&gt;&lt;em&gt;here&lt;/em&gt;&lt;/strong&gt; to see an example test-hello-app.xml configuration.
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;mule xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:http="http://www.mulesoft.org/schema/mule/http"
      xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd"&amp;gt;
    &amp;lt;http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="4b9901d3-7256-4899-ba42-e48244bb84fd" &amp;gt;
        &amp;lt;http:listener-connection host="0.0.0.0" port="8081" /&amp;gt;
    &amp;lt;/http:listener-config&amp;gt;
    &amp;lt;db:config name="Database_Config" doc:name="Database Config" doc:id="6d07f955-b6c6-4bb6-8dde-8461669e29f2" &amp;gt;
        &amp;lt;db:my-sql-connection port="${db.port}" host="${db.hostname}" user="${db.user}" password="${db.password}" database="${db.database}"/&amp;gt;
    &amp;lt;/db:config&amp;gt;

    &amp;lt;configuration-properties doc:name="Configuration properties" doc:id="f535d8b1-e94a-47d3-8280-192dfc7f53b4" file="application.properties" /&amp;gt;
    &amp;lt;flow name="test-hello-appFlow1" doc:id="e8a2c60f-ec54-49af-85c7-6a4338658412" &amp;gt;
        &amp;lt;vm:listener doc:name="Listener" doc:id="cedb163e-e702-4c04-9695-712e59e2a0b4" config-ref="Messages_VM" queueName="messagesToProcess"/&amp;gt;
        &amp;lt;db:select doc:name="Select" doc:id="439a447d-3d96-4526-9b94-24e34bb9c938" config-ref="Database_Config"&amp;gt;
            &amp;lt;db:sql &amp;gt;select * from books;&amp;lt;/db:sql&amp;gt;
        &amp;lt;/db:select&amp;gt;
        &amp;lt;flow-ref doc:name="Flow Reference" doc:id="d606631b-f1f5-41d5-9ec8-9eec117bcc5b" name="sub-flow-level-1-1"/&amp;gt;
    &amp;lt;/flow&amp;gt;
    &amp;lt;sub-flow name="sub-flow-level-1-1" doc:id="a33ad865-b9d8-4fbf-8d09-69d0b0300c99" &amp;gt;
        &amp;lt;logger level="INFO" doc:name="Logger" doc:id="dd241f4f-b7b7-4152-a532-999384753969" /&amp;gt;
        &amp;lt;flow-ref doc:name="Flow Reference" doc:id="ae8ed341-07c1-4730-a728-8a5aa98b5e8d" name="sub-flow-level-2-1-1"/&amp;gt;
    &amp;lt;/sub-flow&amp;gt;
    &amp;lt;sub-flow name="sub-flow-level-2-2-0" doc:id="a33ad865-b9d8-4fbf-8d09-69d0b0300c99" &amp;gt;
        &amp;lt;logger level="INFO" doc:name="Logger" doc:id="dd241f4f-b7b7-4152-a532-999384753969" /&amp;gt;
    &amp;lt;/sub-flow&amp;gt;
    &amp;lt;sub-flow name="sub-flow-unused" doc:id="a33ad865-b9d8-4fbf-8d09-69d0b0300c99" &amp;gt;
        &amp;lt;logger level="INFO" doc:name="Logger" doc:id="dd241f4f-b7b7-4152-a532-999384753969" /&amp;gt;
    &amp;lt;/sub-flow&amp;gt;
    &amp;lt;sub-flow name="sub-flow-loop" doc:id="a33ad865-b9d8-4fbf-8d09-69d0b0300c99" &amp;gt;
        &amp;lt;logger level="INFO" doc:name="Logger" doc:id="dd241f4f-b7b7-4152-a532-999384753969" /&amp;gt;
        &amp;lt;flow-ref doc:name="Flow Reference" doc:id="ae8ed341-07c1-4730-a728-8a5aa98b5e8d" name="sub-flow-loop"/&amp;gt;
    &amp;lt;/sub-flow&amp;gt;
    &amp;lt;sub-flow name="sub-flow-level-1-2" doc:id="5dced7e5-9fbc-4138-951f-586e0c1a766f" &amp;gt;
        &amp;lt;logger level="INFO" doc:name="Logger" doc:id="d451a2c2-a520-489a-8660-fb226a246f2a" /&amp;gt;
        &amp;lt;flow-ref doc:name="Flow Reference" doc:id="1fb51667-42c9-4af6-9c7b-a3811e0e509a" name="sub-flow-level-2-2-0"/&amp;gt;
        &amp;lt;async&amp;gt;
            &amp;lt;flow-ref doc:name="Flow Reference" doc:id="1fb51667-42c9-4af6-9c7b-a3811e0e509a" name="sub-flow-level-2-1-1"/&amp;gt;
        &amp;lt;/async&amp;gt;
        &amp;lt;flow-ref doc:name="Flow Reference" doc:id="1fb51667-42c9-4af6-9c7b-a3811e0e509a" name="sub-flow-level-2-2-1"/&amp;gt;
    &amp;lt;/sub-flow&amp;gt;
    &amp;lt;sub-flow name="sub-flow-level-2-1-1" doc:id="1d7a1a3a-777d-4d4b-8461-f11185247ae3" &amp;gt;
        &amp;lt;logger level="INFO" doc:name="Logger" doc:id="9e7481ed-b803-40a3-a720-3d9edf1b5500" /&amp;gt;
    &amp;lt;/sub-flow&amp;gt;
    &amp;lt;sub-flow name="sub-flow-level-2-2-1" doc:id="da46a247-0355-4ace-a255-c28a19e628b9" &amp;gt;
        &amp;lt;logger level="INFO" doc:name="Logger" doc:id="2fabf827-7695-4830-ae9e-ec79eb38ba96" /&amp;gt;
        &amp;lt;flow-ref doc:name="Flow Reference" doc:id="1fb51667-42c9-4af6-9c7b-a3811e0e509a" name="sub-flow-level-2-2-2"/&amp;gt;
    &amp;lt;/sub-flow&amp;gt;
    &amp;lt;sub-flow name="sub-flow-level-2-2-2" doc:id="da46a247-0355-4ace-a255-c28a19e628b9" &amp;gt;
        &amp;lt;logger level="INFO" doc:name="Logger" doc:id="2fabf827-7695-4830-ae9e-ec79eb38ba96" /&amp;gt;
    &amp;lt;/sub-flow&amp;gt;
    &amp;lt;flow name="test-hello-appFlow" doc:id="c13c3670-cd7a-4181-bd9b-8d87f3f114d6" &amp;gt;
        &amp;lt;http:listener doc:name="Listener" doc:id="b0b19843-27ad-45c9-8761-2910af952655" config-ref="HTTP_Listener_config" path="/sayhello"/&amp;gt;
        &amp;lt;set-payload value="#['Hello from container']" doc:name="Set Payload" doc:id="2cfc464b-950a-4645-b7e3-355c5aeb7304" mimeType="text/plain"/&amp;gt;
        &amp;lt;flow-ref doc:name="Flow Reference" doc:id="f8c61d95-28e4-4c4a-8a51-27dc059b89b1" name="sub-flow-level-1-2"/&amp;gt;
        &amp;lt;flow-ref doc:name="Flow Reference" doc:id="f8c61d95-28e4-4c4a-8a51-27dc059b89b1" name="test-hello-appFlow1"/&amp;gt;
    &amp;lt;/flow&amp;gt;
    &amp;lt;flow name="test-hello-appFlow-3" doc:id="c13c3670-cd7a-4181-bd9b-8d87f3f114d6" &amp;gt;
        &amp;lt;http:listener doc:name="Listener" doc:id="b0b19843-27ad-45c9-8761-2910af952655" config-ref="HTTP_Listener_config" path="/sayhello2"/&amp;gt;
        &amp;lt;vm:publish doc:id="7fdcd659-283b-40c7-9550-8b965fd8441f" sendCorrelationId="ALWAYS" correlationId="#[vars.formatType ++ '_' ++ vars.queueBody.properties.documentIdentifier ++ '_' ++ vars.queueBody.properties.serviceInstanceIdentifier]" queueName="messagesToProcess" doc:name="vm Publish" config-ref="VM_Config" transactionalAction="NOT_SUPPORTED" &amp;gt;
            &amp;lt;error-mapping targetType="APP:TRANSMISSION_QUEUE_FAILED" /&amp;gt;
        &amp;lt;/vm:publish&amp;gt;
        &amp;lt;choice&amp;gt;
            &amp;lt;when&amp;gt;
                &amp;lt;flow-ref doc:name="Flow Reference" doc:id="f8c61d95-28e4-4c4a-8a51-27dc059b89b1" name="sub-flow-level-1-2"/&amp;gt;
            &amp;lt;/when&amp;gt;
            &amp;lt;otherwise&amp;gt;
                &amp;lt;logger level="INFO" doc:name="Logger" doc:id="2fabf827-7695-4830-ae9e-ec79eb38ba96" /&amp;gt;
            &amp;lt;/otherwise&amp;gt;
        &amp;lt;/choice&amp;gt;
    &amp;lt;/flow&amp;gt;
&amp;lt;/mule&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s generate a graph for this configuration file by running following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ muleflowdiagrams ~/Downloads/test-hello-app.xml -d GRAPH
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/.%2Fimages%2Fmule-flow-diagram-test-hello-app.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/.%2Fimages%2Fmule-flow-diagram-test-hello-app.png" alt="Mule flow graph diagram - test hello app"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What do we get from this diagram?
&lt;/h3&gt;

&lt;p&gt;Now, this diagram tells us many things about our application code such as -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;How are those flows and sub-flows linked to each other?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is a sub-flow named &lt;code&gt;sub-flow-unused&lt;/code&gt; which is potentially an unused sub-flow.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is an asynchronous communication happening over VM.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sub flow named &lt;code&gt;sub-flow-loop&lt;/code&gt; is marked for a recursion condition.&lt;/p&gt;

&lt;p&gt;Isn’t this more easier to understand the application?&lt;/p&gt;

&lt;h3&gt;
  
  
  How to get this tool?
&lt;/h3&gt;

&lt;p&gt;If you are on Mac OS, then you can get it via &lt;code&gt;homebrew&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install manikmagar/tap/muleflowdiagrams
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alternatively, you can download the latest release from git repository and install it manually. See &lt;a href="https://github.com/manikmagar/mule-flow-diagrams#installation" rel="noopener noreferrer"&gt;installation&lt;/a&gt; section on the repository.&lt;/p&gt;

&lt;p&gt;| | You can make it out from the project repository path that this is by me and has no relation with MuleSoft. |&lt;/p&gt;

&lt;h3&gt;
  
  
  How to use this tool?
&lt;/h3&gt;

&lt;p&gt;It is a CLI tool and supports various arguments. Once you have it installed, you can run it from your terminal.&lt;/p&gt;

&lt;p&gt;CLI Options&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ muleflowdiagrams
Missing required parameter: &amp;lt;sourcePath&amp;gt;
Usage: muleflowdiagrams [-hV] [-d=&amp;lt;diagramType&amp;gt;] [-o=&amp;lt;outputFilename&amp;gt;]
                        [-t=&amp;lt;targetPath&amp;gt;] &amp;lt;sourcePath&amp;gt;
Create Flow diagrams from mule configuration files.
    &amp;lt;sourcePath&amp;gt; Source directory path containing mule configuration files
-d, --diagram=&amp;lt;diagramType&amp;gt;
                    Type of diagram to generate. Valid values: GRAPH, SEQUENCE
                    Default: GRAPH
-h, --help Show this help message and exit.
-o, --out=&amp;lt;outputFilename&amp;gt;
                    Name of the output file
                    Default: mule-diagram
-t, --target=&amp;lt;targetPath&amp;gt;
                    Output directory path to generate diagram
-V, --version Print version information and exit.

Copyright: 2020 Manik Magar, License: MIT
Website: https://github.com/manikmagar/mule-flow-diagrams
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See &lt;a href="https://github.com/manikmagar/mule-flow-diagrams/blob/master/README.adoc#usage" rel="noopener noreferrer"&gt;Readme&lt;/a&gt; on project repository for more details on the usage.&lt;/p&gt;

&lt;p&gt;For example, run the against a mule 4 project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;muleflowdiagrams ~/devlife/AnypointStudio/studio-workspace/test-hello-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/.%2Fimages%2Fmule-flow-diagrams-mule4-run.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/.%2Fimages%2Fmule-flow-diagrams-mule4-run.png" alt="mule flow diagrams mule4 run"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Next?
&lt;/h3&gt;

&lt;p&gt;It is evolving and more will come, so keep watching the repository for new releases. In meantime, please feel free to get the current release and try it out.&lt;/p&gt;

&lt;p&gt;If you run into any issues or have suggestions, please &lt;a href="https://github.com/manikmagar/mule-flow-diagrams/issues" rel="noopener noreferrer"&gt;open a new issue&lt;/a&gt; on project repository.&lt;/p&gt;

&lt;p&gt;Still got a question, comment on this article or find &lt;a href="https://twitter.com/ManikMagar" rel="noopener noreferrer"&gt;me on Twitter&lt;/a&gt;. I am looking forward to hear your thoughts on this.&lt;/p&gt;

</description>
      <category>mule</category>
      <category>diagrams</category>
      <category>integrations</category>
    </item>
    <item>
      <title>How to Run Mule 4 In Docker Container</title>
      <dc:creator>Manik Magar</dc:creator>
      <pubDate>Sun, 18 Feb 2018 00:00:00 +0000</pubDate>
      <link>https://dev.to/manikmagar/how-to-run-mule-4-in-docker-container-403k</link>
      <guid>https://dev.to/manikmagar/how-to-run-mule-4-in-docker-container-403k</guid>
      <description>

&lt;p&gt;Recently I updated javastreets/mule docker image to Mule ESB 4.1.0 Community version. In this post, we will run a Hello Mule 4 application in Docker container.&lt;/p&gt;

&lt;p&gt;Table of Contents &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1. What is Mule Docker Image?&lt;/li&gt;
&lt;li&gt;2. Say Hello Mule 4 Application&lt;/li&gt;
&lt;li&gt;3. Dockerfile&lt;/li&gt;
&lt;li&gt;4. Build and Run&lt;/li&gt;
&lt;li&gt;5. Conclusion&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1. What is a Mule Docker Image?
&lt;/h2&gt;

&lt;p&gt;If you are looking for Mule Docker image, then you can check javastreets/mule docker images on &lt;a href="https://hub.docker.com/r/javastreets/mule/tags/"&gt;docker hub&lt;/a&gt;. It is probably the smallest and compact Mule ESB Image.&lt;/p&gt;

&lt;p&gt;If you have Docker installed on your machine, you can pull the image as &lt;code&gt;docker pull javastreets/mule&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Say Hello Mule 4 Application
&lt;/h2&gt;

&lt;p&gt;I have added a Simple Hello Mule 4 application to &lt;a href="https://github.com/manikmagar/mule4-examples/tree/master/say-hello-mule4-docker"&gt;mule4-examples&lt;/a&gt; repository on github. This application has only one HTTP listener flow that listens on &lt;a href="http://localhost:8081/test/hello"&gt;http://localhost:8081/test/hello&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It is built for current &lt;strong&gt;Mule 4 Community Edition Runtime&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Dockerfile
&lt;/h2&gt;

&lt;p&gt;The Dockerfile to build and package our application to mule -&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM javastreets/mule:latest-4

COPY ./target/say-hello-mule4-docker*.jar /opt/mule/apps/

CMD ["/opt/mule/bin/mule"]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Build and Run
&lt;/h2&gt;

&lt;p&gt;To build and run the application - execute &lt;code&gt;sh buildAndRun.sh&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This performs 3 steps -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Run Maven Build to package application.&lt;/li&gt;
&lt;li&gt; Build Docker image named hellomule4 and adds this application to Mule within docker.&lt;/li&gt;
&lt;li&gt; Starts the docker container to run mule in foreground. (press CTRL+C to stop mule)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To run application in background, you may also run below command -&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker run -d --name hellomule4 -p 8081:8081 hellomule4&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This docker image exposes 8081 port and binds it to the 8081 of localhost.&lt;/p&gt;

&lt;p&gt;Once application is running, access below url to see Hello from Mule -&lt;/p&gt;

&lt;p&gt;&lt;a href="http://localhost:8081/test/hello"&gt;http://localhost:8081/test/hello&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It should output -&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Hello from Mule ESB (Version: 4.1.0). I am running inside docker image javastreets/mule:latest-4&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Conclusion
&lt;/h2&gt;

&lt;p&gt;It is easy to run Mule Applications inside Docker Containers. javastreet/mule docker image provides an easy way to get Mule Up and Kicking! Example source code is available on Github here - &lt;a href="https://github.com/manikmagar/mule4-examples/tree/master/say-hello-mule4-docker"&gt;mule4-examples&lt;/a&gt;&lt;/p&gt;


</description>
      <category>mule</category>
      <category>muleesb</category>
      <category>docker</category>
    </item>
  </channel>
</rss>
