Tallan's Technology Blog

Tallan's Top Technologists Share Their Thoughts on Today's Technology Challenges

Executing a Boomi Process using the AtomSphere RESTish API

Paul Gutierrez

There are a wide range of scheduling options that are made available to a Boomi application once it is deployed. Depending on the inbound connector used in the application, once deployed the process can run on a schedule or it can continuously poll some existing data source. How the process runs is dependent on if the inbound connector being a “Get” operation or a “Listen” operation.

A “Get” operation allows the process to get a set of inbound records from a data source. Upon deployment this process can either be triggered manually or can have a schedule set up so that it runs on set intervals, for example perhaps it is desired that the process runs every Tuesday and Thursday of every week.

A “Listen” operation  allows a data source to be continuously polled and will retrieve data as it comes in. An example of this would be a having a “Listen” operation on an atom queue that would poll that queue and retrieve records as they come in.

The problem that some may encounter is that there are times when “Listen” functionality is desired but only a “Get” operation is available. As a result, the only option that may seem available is to settle for using the “Get” operation. The problem with using a “Get” operation is that it does not allow for the creation of a schedule that polls any faster than one minute at a time. For some scenarios that may be sufficient but for others it can quickly become a bottleneck within the application.

Fortunately, there is a way around this limitation. Dell Boomi offers a robust SOAP and RESTish based API that can be utilized to perform numerous different operations and actions. Executing processes is one of actions that are made readily available using the API. This blog post will show how to programmatically execute a Dell Boomi process utilizing C# and the AtomSphere RESTish API.

Before developing the necessary C# code to execute a Boomi process the following steps should be taken:

  1. Determine what API endpoint(s) we need
  2. Determine what parameters we need

Upon inspecting the Boomi AtomSphere API documentation it can be determined that the Execute Process Operation is the operation that is desired.

Based on the documentation the desired API request will be a POST operation to the https://api.boomi.com/api/rest/v1/{Account Id}/executeProcess endpoint.

Also based on the documentation the following XML request is necessary:

<ProcessExecutionRequest processId="{process id}" atomId="{atom id}" xmlns="http://api.platform.boomi.com/">
    <ProcessProperties>
        <!—Zero or more repetitions:—>
        <ProcessProperty>
            <Name>priority</Name>
            <Value>medium</Value>
        </ProcessProperty>
    </ProcessProperties>
</ProcessExecutionRequest>

The necessary parameters that must be determined are the: account id, process id, and the atom id. Once those three values are known then they can be used within the code to make the request.

The account id can be found under setup -> Account Information as shown below:

 

The process id can be found by going to the desired process and looking at the revision history. In the revision history the process id is referred to as the “Component ID”. You can see the screen shot below:

processidlocation

 

The atom id can be found by going to under Atom -> Atom Management -> Selected Atom as shown below:

atomid

 

With all the necessary parameter values known. We can now go about writing the code that will handle the process execution:

public void KickoffBoomiProcess(string fileName = "Batch", int batchCount = -1)
{
    string result = "500";
    try
    {
        string postDataTemplate = "<ProcessExecutionRequest processId=\"{0}\" atomId=\"{1}\" xmlns=\"http://api.platform.boomi.com/\">{2}</ProcessExecutionRequest>";
        string processProps = (batchCount > 0 ? "<ProcessProperties><ProcessProperty><Name>BatchCount</Name><Value>" + batchCount+"</Value></ProcessProperty></ProcessProperties>" : "");
        string postData = String.Format(postDataTemplate, Settings.ComponentId, Settings.AtomId, processProps);
        string authInfo = Settings.UserName + ":" + Settings.UserPassword;

        WebRequest request = WebRequest.Create("https://api.boomi.com/api/rest/v1/" + Settings.AccountId + @"/executeProcess");
        request.Method = "POST";
        byte[] byteArray = Encoding.UTF8.GetBytes(postData);
        request.ContentType = "application/xml";
        request.ContentLength = byteArray.Length;
        authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
        request.Headers["Authorization"] = "Basic " + authInfo;

        using (Stream dataStream = request.GetRequestStream())
        {
            dataStream.Write(byteArray, 0, byteArray.Length);
            dataStream.Close();
            using (WebResponse response = request.GetResponse())
            {
                result = ((HttpWebResponse)response).StatusDescription;
                using (Stream s = response.GetResponseStream())
                {
                    using (StreamReader reader = new StreamReader(s))
                    {
                        string r = reader.ReadToEnd();
                        Logger.Log(string.Format("Successfully started Boomi Process {0} on Atom {1} with Account ID {2}\r\nFor file: {3}\r\nHTTP Response: {4}\r\n",
                                     Settings.ComponentId
                                    , Settings.AtomId
                                    , Settings.AccountId
                                    , fileName
                                    , result) +
                                    (string.IsNullOrWhiteSpace(r) ? "" : "Result: " + r));
                    }
                }
            }
        }
    }
    catch (Exception e)
    {
        Logger.Log(string.Format("Failed to start Boomi Process {0} on Atom {1} with Account ID {2}\r\nHTTP Response: {3}\r\nError: {4}",
                                     Settings.ComponentId
                                    , Settings.AtomId
                                    , Settings.AccountId
                                    , result
                                    , e.ToString()),Logger.LogType.Error);
    }
}

What the above code does is it generates an XML string that mimics the request XML needed by the endpoint using the desired parameters specified earlier. It then generates the web request using the credentials of the user who will be executing the process. The code then makes the request and retrieves the response and logs a message.

While this code by itself does not solve the initial scenario of being able to continuously poll a data source it can easily be wrapped in a windows service which would solve that problem. By programmatically executing processes with a windows service and deploying that service to a server we can get constant polling of any data source which in turn can greatly increase performance of an application which would have otherwise contained a bottleneck at the point of data retrieval.

Dell Boomi AtomSphere

The Dell Boomi AtomSphere integration platform is a shared-everything, multi-tenant platform that supports cloud-to-cloud, SaaS-to-SaaS, cloud-to-on-premises, on-premises-to-on-premises and B2B integration. Boomi AtomSphere supports real-time integration and elastically scales to meet high-volume needs in mobile, batch (ETL) and EDI environments. Easily accessed via a browser, it delivers an impressive range of integration, master data management (MDM) and platform extension capabilities.

Tallan Integration Solutions for Dell Boomi
Tallan is a certified Dell Boomi Partner specializing in iPaaS platform integrations. We specialize in Integrations using EDI and Dell Boomi as the iPaaS platform of choice. Leverage Tallan’s vast integration experience for your AtomSphere platform needs.  Our certified architects and developers provide the expertise, best practices, and guidance to deliver a successful integration solution.

We hope this guide will help you in your use of AtomSphere. If you have any questions or comments, or need assistance with any Integrations or development questions, please contact us at integrations@tallan.com.

No comments

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>