Improving application performance in IBM Business Process Manager V7.5 by using DynaCache

Improve the performance of your WebSphere Process Server or WebSphere Enterprise Service Bus solution

This tutorial describes an easy and efficient caching mechanism based on DynaCache for IBM® Business Process Manager V7.5. DynaCache enhances application performance and provides the flexibility to load or flush cache contents at runtime. For ease of understanding and simplicity, the tutorial depicts how to load data that is accessed frequently by the application into DynaCache via a properties file. For any subsequent read cycle, the data is fetched from DynaCache, thereby improving application performance.


Keerthana Sharath (, IT Specialist, IBM

Photo of Keerthana SharathKeerthana Sharath is an Application Integration and Middleware Solutions Specialist with WebSphere Lab Services at IBM India Software Labs. She has worked on customer engagements involving various products, such as WebSphere Application Server, WebSphere Process Server, ILOG, and WebSphere Lombardi. She has also worked with WebSphere Education Development to develop and deliver WebSphere courses. Keetharna is a certified WebSphere Application Server Administrator, WebSphere Process Server Administrator, and WebSphere Lombardi Business Process Developer.

developerWorks Contributing author

Pritesh Parmar (, Senior System Engineer, IBM

Photo of Pritesh ParmarPritesh Parmar is a Senior System Engineer with IBM Global Business Services. He is currently working as a Senior Developer and Designer on a BPM project at IBM. He has worked on SOA-based projects and has skills on in IBM Business Process Manager, WebSphere Operational Decision Management, WebSphere MQ, WebSphere Message Broker, and WebSphere Transformation Extender. His areas of interest include Enterprise Application Integration and Middleware.

03 October 2012


When developing business process management solutions, you frequently require data that is expensive to fetch or compute. To obtain this data, you can connect to a database, invoke a Web service, and so on. If this data does not change over time, you can often achieve significant performance gains with the appropriate use of caching.

This tutorial shows a simple and effective caching technique to improve application performance based on the IBM Business Process Manager (BPM) product feature called DynaCache. DynaCache stores objects and later retrieves and serves them from its cache based on data-matching rules. It creates a unique user-defined "key" to store and retrieve cache items. Think of DynaCache as a sophisticated Java™ Hashtable. The code used to provide the in-memory cache services extends the Java Dictionary class, which is the abstract parent of the Hashtable.

The object cache instance is used to store, distribute, and share Java objects. The DistributedObjectCache and DistributedMap APIs are provided so that applications can interact with the object cache instances. Caches are stored in the JVM heap memory. If enabled, DynaCache supports overflow to disk when needed.

The default DynaCache instance is created if the DynaCache service is enabled in the Administrative Console. This default instance is bound to the global Java Naming and Directory Interface (JNDI) namespace using the name services, cache, and distributed map.

Each data request (meaning any invocation of a cacheable servlet, JSP, Web service, or other object) is associated with a set of input parameters that are combined to form a unique key called a cache identifier or cache-id. A key policy defines which cache identifiers result in a cacheable response. If a subsequent request generates the same key, the response is served from the cache. If a unique key does not match any rules, the response for the request is not cached. Figure 1 shows how DynaCache works.

Figure 1. Overview of DynaCache
Overview of DynaCache

Additionally, by using DynaCache, the complexities of cache data replication and synchronization between nodes in a network deployment topology are automatically and transparently handled by the infrastructure.

This tutorial covers the following topics:


  • You must have hands-on experience with Java.
  • You must be familiar with IBM Integration Designer (hereafter called Integration Designer), since it will be used as a development tool.

System requirements

  • Microsoft® Windows® machine
  • IBM Integration Designer V7.5 installed with the test environment


This tutorial will take about 2 to 3 hours to complete.

Preparing the environment

In this tutorial, the following installation path variables and directories are used for the components:

  • Integration Designer root: C:\IBM\IntegrationDesigner
  • AppServer root: C:\IBM\WebSphere\AppServer

In this tutorial

This tutorial is based on a fictional service that retrieves Country details, such as Capital City, Population, Continent, and Official Language. You can implement this retrieval in different ways:

  • Straightforward approaches retrieve the values from a database based on the Country name, or invoke a Web service that returns the details.
  • An alternative approach is to use DynaCaching. Since Country details rarely change, this particular service is a strong candidate for caching. With this approach, Country Details are stored in a properties file. A Java class reads the properties file and loads the values into the cache. This prevents the frequent read calls made for the properties file, and the application can effectively read the values from the cache. This approach improves application performance and also optimizes resource utilization.

Creating the properties file

In this section, you create a CountryDetails properties file with the Country Name mapping to Capital City, Population, Continent, and Official Language.

  1. Create a new text file and name it
  2. Populate the properties file as shown in Figure 2.
    Figure 2. CountryDetails properties file
    CountryDetails properties file
  3. Save the properties file in the folder C:\temp.

Creating the business object and the service interface

In this section, you create the business object and the service interface in the DynaCache library.

Setting up the DynaCache Library

  1. Open Integration Designer with a new workspace, and open the Business Integration perspective.
  2. Create a library named DynaCacheLIB.
    1. Select File > New > Library as shown in Figure 3.
      Figure 3. Create a library
      Create a library
    2. Name the library DynaCacheLIB and click Finish as shown in Figure 4.
      Figure 4. Enter the library name
      Enter the library name
  3. Create a business object named CountryDetails.
    1. Select File > New > Business Object as shown in Figure 5.
      Figure 5. Create a business object
      Create a business object
    2. Select the DynaCacheLIB library, enter the business object name as CountryDetails, and click Finish (see Figure 6).
      Figure 6. Enter the business object name
      Enter the business object name
    3. Add the fields to the business object as shown in Figure 7.
      Figure 7. Add fields to the business object
      Add fields to the business object
  4. Create the service interface named RetrieveCountryDetails.
    1. Right-click the Interface folder (see Figure 8) in the Business Integration Explorer of DynaCacheLIB and create a new interface. Name the interface RetrieveCountryDetails.
      Figure 8. Create an interface
      Create an interface
    2. Create a request-response operation named getCountryDetails with an input parameter called request of type CountryDetails and an output parameter called response of type CountryDetails, as shown in Figure 9. Save the changes.
      Figure 9. Create a request-response operation
      Create a request-response operation

Building the caching component

In this section, you build the caching component using the Java component of Integration Designer. The Java component reads the properties file created previously and loads the data into DynaCache. For any subsequent fetches, the data is retrieved from DynaCache.

Creating a DynaCache module

  1. Select File > New > Module as shown in Figure 10 to create a new module named DynaCacheModule (see Figure 11), and click Next.
    Figure 10. Create a new module
    Create a new module
    Figure 11. Enter the module name
    Enter the module name
  2. Select DynaCacheLIB from the Selected Required Libraries and click Finish as shown in Figure 12.
    Figure 12. Select the library
    Select the library

    Note: If you get an error after selecting the library, double-click on Dependencies under DynaCacheModule and change the Version Scheme to "Not Versioned".

  3. Right-click DynaCacheModule and select Properties. Add as an external JAR file in the Java Build Path as shown in Figure 13. This JAR file is located at <AppServer root>/plugins.
    Figure 13. Add an external JAR file
    Add an external JAR file
  4. Expand the DynaCacheModule under the Business Integration Explorer, and double-click the Assembly Diagram to open it.
  5. Once the Assembly Diagram is open, click Java under the Components category from the Palette (see Figure 14), and then click the blank area of the Assembly Diagram.
    Figure 14. Create a Java component
    Create a Java component
  6. Rename the Java Component to CachingComponent. Use its pop-up toolbar to add an interface and a reference to the component (see Figure 15). Use the RetrieveCountryDetails interface for both the interface and the reference. Save the assembly diagram, and then save all changes.
    Figure 15. Add an interface and reference
    Add an interface and reference
  7. Double-click the caching component to generate its implementation. A stub method is generated for the getCountryDetails operation.
    1. Enter the code snippet shown in Listing 1 for the getCountryDetails operation of the CachingComponentImpl Java class.
      Listing 1. Java code for the caching component
      public DataObject getCountryDetails(DataObject request) {
      	 * Initialize BOFactory
      	BOFactory BO_FACTORY = (BOFactory) new ServiceManager().
      	// retrieve key to cache from the request
      	String key = request.getString("Country");
      	// get response from cache
      	DataObject responseObject = null;
      	responseObject = cache.get(key) == null ? 
           null : (DataObject) cache.get(key);
      	// if cache miss read from file and update cache
      	if (responseObject == null) {
      		System.out.println("Getting from properties file");
      		Properties properties = new Properties();
      		try {
      			System.out.println("Inside try");
      			properties.load(new FileInputStream("C:\temp\
      		catch (IOException e) {
      	//creating the response BO - CountryDetails
      	DataObject CountryDetails = BO_FACTORY.create("http://DynaCacheLIB",
      	// retrieves country details represented by comma separated values
      		String responseMsg = properties.getProperty(key);
      	// Split the comma separated string to retrieve individual values
      		String splitArray[] = responseMsg.split(",");
      		for (String string : splitArray) {
      			System.out.println("Items:" + string);
      	// set the fields of the response BO - CountryDetails
      		CountryDetails.setString("CapitalCity", splitArray[0]);
      		CountryDetails.setString("Population", splitArray[1]);
      		CountryDetails.setString("OfficialLanguage", splitArray[3]);
      		responseObject = CountryDetails == null ? null: 
      		if ((cache != null) && 
               (responseObject != null)) {
      			cache.put(key, responseObject);
                  ("******************* Inserting in Cache ****************");
      		} else {
      			System.out.println("Getting from DynaCache");
      		return responseObject;

      Note: Add the required imports to the CachingComponentImpl. Refer to the sample Project Interchange zip file that is provided in the Download section of the article for the complete source code for the Java component.

    2. Enter the code snippet shown in Listing 2 after the CachingComponentImpl constructorto initialize the default DynaCache.
      Listing 2. Java code to initialize cache
      	 * Lookup the default DynaCache object cache instance
      	privatestatic DistributedObjectCache cache 
           = initCache();
      	static DistributedObjectCache initCache() {
      		try {
      			InitialContext ic = new InitialContext();
      			return (DistributedObjectCache) ic
      		} catch (NamingException e) {
    3. Save all changes.

Testing the caching component

In this section, you deploy the module to the test server and verify that the service behaves as expected.

  1. On the Assembly Diagram, right-click CachingComponent and select Test Component. The Integration Test Client pop-up opens.
  2. In the Initial request parameters panel, populate the Country field of the request object with the value of INDIA, as shown in Figure 16. Verify that the Integration Test Component contains the parameters as shown in Figure 16.
    Figure 16. Test the caching component
    Test the caching component
  3. Continue the test by selecting the deployment location and click Finish. At this point, your test server starts and your module is deployed automatically.
  4. For the first run, the Java component fetches the country details for INDIA from the properties file. It then inserts the details into DynaCache. For any subsequent runs, it reads the country details for INDIA from DynaCache. Verify the response Business Object as shown in Figure 17.
    Figure 17. View the output of the caching component
    View the output of the caching component
  5. Verify via the console, which is shown in Figure 18, that the country details were fetched from the properties file and inserted into the cache.
    Figure 18. Verify the console for the properties file fetch and cache insert
    Verify the console for the properties file fetch and cache insert
  6. Rerun the same scenario and use the console (see Figure 19) to verify that for this run, the country details were fetched directly from the cache due to the insertion in the previous step.
    Figure 19. View the console for the DynaCache fetch message
    View the console for the DynaCache fetch message

Note: You can test the module with different input data for the Country field based on the properties file.


This tutorial described how to configure DynaCache. This involved creating a properties file, creating the business object and service interface, building the caching component, and testing the component.


The authors would like to thank Jeff Kaminski and Balasubramanian Krishnamurthy for their valuable comments and reviews.


Project interchange fileDynaCachePI.zip17KB



developerWorks: Sign in

Required fields are indicated with an asterisk (*).

Need an IBM ID?
Forgot your IBM ID?

Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.


All information submitted is secure.

Dig deeper into Business process management on developerWorks

Zone=Business process management, WebSphere
ArticleTitle=Improving application performance in IBM Business Process Manager V7.5 by using DynaCache