Exception handling is the process of responding to the occurrence of exceptions. Exceptions are one of the scenarios that all developers are supposed to deal with. While developing business processes in TIBCO designer, a large number of possible exception types may come across in your way which require your attention.
Step 1: Create a Process with HTTP Receiver as Process Starter
An input parameter ‘name’ is given.
HTTP receiver will start the activities. Created HTTP Connection with host as localhost and port as 8900 for this example. It reads files to store the XML data. Has JDBC update activity. Catch activity to catch the exceptions and finally HTTP response activity to respond to success.
Step 2: Configure Read File Activity
In the example, I have read files from my Desktop. In the HTTP request, whatever data is sent in the name parameter will be used to find from the given directory. I have created a file with my given name.
So if the user sends prathyussha as a parameter in the name area, it consists and finds file as prathyussha.xml.
Step 3: Parsing XML
The data from the read data resource is now sent to Parse XML because it needs to do parsing and send it as text form to JDBC.
The schema is set to capture the data and send it to the JDBC update.
Step 4: Configure JDBC Update Activity
After reading content from the XML file, it will be stored into a database table in our example. For this, we need to configure JDBC Update activity as shown below
They are now sent to the JDBC update to store them into the database.
I have generated Error handling in two ways :
- Inside the group block, have added generate error block which gives us a specified custom error. The custom error is then thrown.
- And we use Catch resources inside the block.
Step 5: Configure Catch Activity to Catch FileNotFound Exception:
Suppose, if we want to use catch resource inside a group, the successful transition will contain following Xpath
Step 6: Configure Send HTTP Response activity
In this scenario, there are three examples where we need to send an Http request.
- When operation gets successful
- When an exception is thrown and is caught properly
- When an exception is thrown but not handled explicitly
If the operation is successful we will send Operation success in transition.
When FileNotFound exception is thrown and caught, Send HTTP Response activity is configured as shown below:
Sending a back error message to display.
For all other exceptions which are unhandled are caught here in this catch resource.
Testing scenarios :
- Testing Success Scenario
- Testing File Not Found Exception Scenario by Catch inside the group.
- Testing File Not Found Exception Scenario by using custom generated error.
- Testing Unhandled Exception Scenario
- Testing Success Scenario:
We have the file stored in name prathyussha.xml in my C:\Users\prathyussha.ravi\Desktop\TIBCO\xml where we will read this and store it in the Oracle database.
- Testing File Not Found Exception Scenario by Catch inside the group.
If the file is not found, the catch resource will be executed.
In case if there is any exception which is not caught inside the group,
- Testing File Not Found Exception Scenario by using custom generated error.
By using generate error if there is an exception we can generate a customized error.
Customized error message printed in the message area.
- Testing another scenario:
We will do other types of error in JDBC so that it is caught in unhandled catch resource.
Interesting stuff, we need to try this.