How do you deal with connector errors during the execution of your BOS processes?
This article will present two different ways to deal with errors in your processes: error events and exceptions. We will provide an example for each, and we will give you their pros and cons so you can choose the one that best fits your needs.
Sending and Receiving error events
This method allows you to associate a error with a name to a connector. If the connector fails, the process will catch that error with a boundary error event associated to that error name.
Error handling with a boundary error event
This will provide an alternate path that is taken to deal with your error.
However, this method has some major drawbacks:
One can only associate a single named error to a connector, even if it can throw different types of errors. For example, for a database query connector, the server might be down or your query’s syntax might be incorrect, but the error raised by the failed connector will be the same.
Upon receiving the error signal, you will no longer have access to the name of the error that occurred.
Throwing and Catching Exceptions
Another solution which is more complex, but also more powerful, is to use Java exceptions for error handling.
In this case, if you are developing your own connectors and using the Bonita API to execute some tasks, you can catch the exceptions that are raised by your connector.
Here is an example of a process that executes a task via a subprocess:
Exception handling via a subprocess
In this example the parent process will execute a “Caller step.”
This caller step will launch the subprocess and execute the “Exception throwing step” with this method:
This automated task will execute a connector that throws a Java Exception. This exception will be then be thrown by the execute task method and can be used to provide appropriate error handling.
You can log the error and even store the Exception object as a reference to the last error that occurred.
Errors happen – so it’s useful to deal with them in advance with boundary events or exception handling.
Here is a recurrent use case: imagine a process design in which you have a human task that is a bottleneck preventing the execution of several other human tasks.
This stalled task might be at risk of exceeding a deadline, or needs to be cancelled. How can you warn the next actors who are waiting for an input to start their own work?
The current available option is to implement this go-around with a boundary event linked to an automated task that sends an email, then loops back to the parent activity. However, this is a bit awkward and clutters up your process diagram.
Here is a contribution that provides a better way of handling this kind of situation: a connector that will allow you to “get the next tasks’ actors.”
With this, you can retrieve a list of unique user names from the human tasks that are directly connected to your bottleneck task. Warning them of a stalled process will simply require adding an email connector, or extending this one to send emails.
In a previous post, I explained how it is possible to add complex widgets made with JavaScript in a Bonita Form Application, and also how this widget can interact with the data in your process. That example widget was a Google Map.
In this post, I’ll start with one of the user requests in the Bonita Community bug tracker, in order to show you how to embed and leverage RIA JavaScript framework, such as jQuery, in your application. We’ll create a dialog box in a form, and as you’ll see, it’s easy.
Add jQuery resources to your application
This is an example of why there is a Resource tab. First get all the necessary resources from jQuery by downloading them from the website, and add all the folders you need in the applications folder.
That’s all!
Tweak your main HTML page to include jQuery
This is a mandatory step that you have to perform whenever you want to add JavaScript to your applocation. First, retrieve the BonitaApplication.html that you can get by hitting Run, and show the source code for the page. This is your main HTML page. Then add the necessary <script…> headers to the head element of the page, in order for jQuery to run.
And then, simply add the modified BonitaApplication.html in the application resource folder.
Now, use jQuery!
jQuery is added and enabled in your application. Just do it! Put an HTML widget in your form, and add the content below (copy-pasted from jQuery documentation):
<divid="dialog"title="Basic dialog">This is a dialog "popped-up" from an application generated with Bonita Open Solution!</div>
In some cases, you can put the script headers wherever you want in the HTML page, and you can put it in other templates for your application, or directly in the HTML widget. However, this is not a good practice for compatibility, and the only way to ensure your scripts are loaded is to put them in BonitaApplication.html.
If your jQuery widget has any input fields, use callbacks on them to set the value of the fields defined in your form designed in Bonita Studio. Add “hidden field” for the data handled by the widget, and change the value of the hidden input with a callback. See the Google Maps example in previous post for a more complete example.
And while I am writing about dialog boxes, I’m hearing this music. Coincidence? I don’t think so. AEED – Dialog Box by AEED
Many Bonita Open Solution users find it useful to extend BOS to integrate it with other applications. When doing this, you can use Maven to manage project dependencies. BonitaSoft belongs to OW2, which is an open source software consortium for middleware providers. At each release, we provide updated Maven artifacts in the OW2 repository. This simplifies the development of an application that uses BOS.
Here’s a quick “How-To” for using Maven to handle BOS dependencies
Step 1 : Create a new Maven project in your favorite IDE
New Maven Project
Step 2 : Configure your pom.xml
Double click on your pom.xml file.
Add the OW2 Maven repository :
Go into the pom.xml tab and add the following code :
You can now add “Bonita” to your dependencies, either by using the Wizard…
Go to Dependencies Tab > Click on Add... > Search for "bonita-client" >Select "org.ow2.bonita bonita-client" entry > Click OK
(This automatically configures your pom.xml, adding the latest available version of the bonita-client artifact to your project dependencies.)
…or by directly editing the pom.xml file :
You can use the bonita-client artifact if your application needs to make requests to an external server. If your application directly manipulates the database or manages events inside the engine, then use the bonita-server artifact.
You can now easily leverage the BOS API in your application, letting Maven resolve the dependencies.
If you work like me, with 2 screens, I’m pretty sure that you will enjoy this tip. To put the “details view” on your second screen, just to drag and drop the view from Bonta Studio to your second screen. Watch the video Read the rest of this entry »
- Do I put it local or global? - That’s a local I’m telling you -Okay, okay … -Allright.. sorry, it should be a global, but don’t worry you can promote it
Most of the time designing business processes requires to adapt your draw and data definition to new incoming needs. This is why in Bonita Open Solution we’ve created some little features Read the rest of this entry »