Skip to main content

Development

Using configuration files in IIB

Introduction:
Configuration files can be read/cache to make the service code independent and also it will improve the performance. By using a configuration file with static data, it needs to be loaded into the memory only once when flow starts. So, no need to load it at the time of each and every execution.

How to use Config File:
• Reading a config File: FileRead Node(in case of ESQL) or FileReader and BufferReader class(in case of java) can be used to read the config file, within a message flow.
• Load Config File: Shared variables can be used to load config file data to an in-memory cache within message flow. The data is loaded on first after each broker startup.
• Access Config Data: Environment variables have been used in the following example to access config data. As per requirement change, if editing is required in configuration data, configuration file can be updated.

Implementation of Config file (Using JAVA):

img1

1. Use Java compute Node for transformation and use BufferReader method of Java to read configuration file.
2. Create UserDefinedProperty in the flow.UDP can be created using UserDefinedProperty tab in message flow editor.
img2

3. AddPropertygive a name to UDPprovide the filename.
img3
4. Pick the value of UDP using getUserDefinedAttribute() Method of Java and create ConfigFile DrivePath e.g. C://IIB/ConfigFile.xml.Then,use BufferReader method to read the file.
Coding of PickConfig.java:
img4
a. onInitialiaze Method:This method of java will enable loading the config file only once on restart or deployment.
img5
b. init Method: we have used hashmaps to save the values of errorCode and errorDesc.
img6
c. evaluate Method:we have saved values in hashmap in different keys for errorCode and errorDesc, we can do in the same key value pair and pick the value of errorDesc with the use of ErrorCode as per the requirements.

img7
d. configFilePick Method:
img8
Coding of SetErrorFromConfig.java:
img9

Structure of Config File:
img10

When can a configuration file be used:
• To control the sequence of invocation of applications and message flows.
• To store static variables and environment-specific information outside code i.e. IBM Integration Bus.
• To enable logging and controlling log levels, file names.
• To enable error handling by storing error messages in a configuration file.

In the above scenarios, As configuration files is outside IBM Integration Bus so no need to edit the message flow in case of change to the data. As many entries can be added for Error Code and ErrorDescription as per requirements.Also, no need to load configuration file on each execution and better performance, lesser time consuming and faster data access.

Thoughts on “Using configuration files in IIB”

  1. Would it possible to download the PI for this java implementation of configurable files in IIB? Very much appreciated.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Ruchi Rani

Ruchi Rani

More from this Author

Categories
Follow Us