Adding Flows Dynamically

Reading Time: 5 minutes

Mule has a new really cool module ready to be used in Muleforge called Dynamic Flows. The idea behind this new module might sound strange at first but it is actually quite simple: it allows you to add new flows to your existing mule application without restarting the server. It provides three simple operations for flow management:

1) Add

Creates a new mule context with the name and configuration provided. It allows adding to your application all the flows defined in the config XMLs passed to it. For example, the addFlow:

Could not embed GitHub Gist 1660068: Not Found

Receives a context name and a list of mule configs XMLs (the XMLs, not the files) through a http post, then the transformer creates a map grouping all the XMLs under the same key and finally the module processes those XMLs and creates a new context in your mule server. After the flow finishes, we have new flows ready to be used.

2) Run

It executes a dynamic flow, for example, consider the following flow:

Could not embed GitHub Gist 1660142: Not Found

If we write: http://localhost:10443/run?contextName=testContext&flowName=testVmFlow on our web browser, it executes the dynamic flow called “testVmFlow” in the dynamic context “testContext” added by the module.

There are two ways you can call a flow: using a VM transport or without it. If you choose the first option, remember to declare the vm inbound in your flows.

3) Remove

Removes a entire dynamic context from your mule application.

A demo application

This module is quite useful when you need to execute logic that depends on dynamic information, for example, let’s consider the following requirement:

Our users have several campaigns in Salesforce, all of them have a custom field called ‘info’. The information stored in this custom field depends on the campaign. For example, a user A has two campaigns: ‘Phone marketing’ and ‘Email sales’, for the first one,  the field ‘info’  must contain all the user’s available twilio phone numbers  separated by comas, but for the ‘Email sales’ campaign it must contain the email template stored in constant contact. 

We need to create a mule application that sets the ‘info’ field for our users.

As we can see, this problem is kind of tricky, because we don’t know which process we need to execute before hand, it depends on the salesforce campaign so what do we code in mule?, do we write an if condition in our mule context?, what happen if the user creates a third campaign?. Doing this application with the static mule configuration is hard, however we can simplify it a lot by using Dynamic Flows module. We just open MuleStudio, create the following flows:

And we are done, every time our users create a new campaign, they can tell mule how to get the data that has to stored into the ‘info’ field,  without stopping and starting the mule server.

Links and further reading

For further information, see Dynamic Flows documentation.

To see the code check the Dynamic Flows source code, you can find a demo app to see its usage.

Mule SAP Enterprise Connector is here!

Reading Time: 4 minutes

This week we announced the availability the Mule SAP Enterprise Connector. This is a major milestone since Mule is the only next generation ESB to be certified by SAP.

SAP is one of the most popular Enterprise Resource Planning (ERP) solutions on the market. But the big challenge for SAP customers is how to integrate SAP with other systems and application, which is key to automate and optimize business processes.

Continue reading

5 Biggest IT Trends for 2012 and how Open APIs are a driving force

Reading Time: 3 minutes

Wondering what 2012 will bring for the IT world?

Ross Mason, MuleSoft Founder and CTO, has identified the five major trends you need to watch this year and how they will affect your organization. These trends are:

Continue reading

Announcing Mule 3.3 Milestone 1

Reading Time: 13 minutes

A couple of months back we released Mule 3.2, which is the version we recommend for all Mule users.  The latest release of Mule 3.2 is Mule 3.2.1 which can be found on the download page.

We haven’t stopped though. Since releasing Mule 3.2.1, we’ve been busy working on Mule 3.3 M1.  This is the first of a number of monthly milestones we will be making available to the community on the road towards Mule 3.3.  In this blog post I’ll not only go over what’s new in M1, but also give you an idea of what we have planned for Mule 3.3.

Continue reading

Error Handling Patterns in Mule

Reading Time: 10 minutes

Exception handling in event-driven systems like Mule can sometimes be a challenge because there are usually many more things happening at once, In this blog I will show you how to implement some common error handling patterns in Mule. We are going to cover the following use cases:

  • Route a message before exception through an exception strategy to a dead letter queue
  • Route an original message through an exception strategy to a dead letter queue
  • Route a message based on exception type


For more detailed information about how exception strategies work in Mule please see Getting the most out of Mule Error Handling blog post and Mule Error Handling documentation.

Continue reading

Enterprise IT predictions for 2012

Reading Time: 11 minutes

You went to the gym twice last year yet you are considering renewing your membership; yep, 2012 is here. And while we’ve seen a number of exciting developments in enterprise IT in 2011, it was just the beginning. There’s a lot in store next year, here are 6 key developments to look out for in 2012.


Continue reading