Beruflich Dokumente
Kultur Dokumente
TABLE OF CONTENTS
Exercise 1: Service Caching with Terracotta ....................................................... 3
Exercise 2: Caching with Big Memory ................................................................ 9
Exercise 3: Handling big XML Documents ......................................................... 14
4BS Solutions
www.4bs-solutions.com
Exercise 1:
Service Caching with Terracotta
Ov er v ie w
In this exercise you test service caching and how it works with the new terracotta cache
Ta sk
1. Enable the package V97TrainingESBSupport using the Integration Server package
management on your VM before starting the first Exercise. Use IS Administration Web UI at
http://localhost:5555
2. Create a new package called V97TrainingESB with a child folder called V97TrainingESB.
3. Within the folder V97TrainingESB, create a folder called caching.In the upcoming steps you
will create a service that is used as cached service candidate
4. In order to test caching, we need a service that we are going to cache. This will be a service
called fak computing n! = 1 * 2 * 3 * * n for a given value of n. To simplify affairs, a java
prototype called javaFak already exists for you. Besides computing the n! function, it also
keeps track how often it was invoked. This counter can be read by invoking the
getAndWipeCalls service, which resets the call counter as well.
5. Create a Flow service called fak as shown below:
4BS Solutions
www.4bs-solutions.com
Note: The input array for preserve in step 2 contains one entry, fak (3 letters, no quotes).
6. Create a test service
Next create a test Flow service called testCaching as shown below. This service invokes fak
with the arguments {1,1}; {1,2,2,1}; {1,2,3,3,2,1} up to {1, 2,, 9, 10, 10, 9, , 2. 1} and tests
the number of invocations after every call. To construct the argument sequences, another
service,called constructArgumentArray is provided.
8. Run the service testCaching without enabling caching in the fak service (Cache results
property set to False). Verify it produces the following result in the server log:
4BS Solutions
www.4bs-solutions.com
Note the number of calls to fak is 2 * N, just as expected. This proves that the results are
not cached.Run the Flow service V97TrainingESBSupport.support.caching:dumpServiceCache
to display the content of the service cache. You will notice that there are no keys stored.
Note that this service is not suitable for caches containing a lot of keys. The service is shown
here:
9. Set Cache Results to True in the fak service and run the service testCaching again:
4BS Solutions
www.4bs-solutions.com
Exercise 2:
Caching with Big Memory
Ov er v ie w
In this exercise you will create a new Cache Manager and Cache that uses BigMemory. You will
then create and test a service that uses this cache.
Ta sk
1. Form 1. To use BigMemory with the Integration Server (and Ehcache) you must have the
appropriate license. To verify a license includes BigMemory, open the IS Administration Web
UI and navigate to Settings > License > License Details:
BigMemory should = yes.
2. Set the amount of memory that you want to allocate to BigMemory. To do this, change
MaxDirectMemorySize to 500M in ${InstallDir}\IntegrationServer\bin\setenv.bat
4BS Solutions
www.4bs-solutions.com
After completing this step, you have a cache called Data managed by a cache manager called
TestCacheManager that can hold 10 MB of data in BigMemory. These are not realistic values
for BigMemory but they get the point across. BigMemory can be used to have off heap storage in
hundreds of GIGAbytes!
Save your changes, and then start the Cache Manager (this will enable the cache).
Now you will write a service to fill the cache with data.
5. To fill the cache, you need to create a few objects on IS. First create the following
document type:
V97TrainingESB.fillCache:cacheData:
Note: randomData is of type Object List with Java wrapper type set to java.lang.Byte
6. Finally, create a Flow service called filler in the fillCache folder to store random data in the
cache as shown below. Set the Repeat on property to SUCCESS
4BS Solutions
www.4bs-solutions.com
Now start the filler service and look how it slowly fills your cache with data. From a command
window, you can use the ${CourseDir}\ListCache.bat procedure to inspect the content of your
cache. Make sure you run env.bat first in ${CourseDir}.
You will notice the service generateRandomData will keep running and running and running
(because of the Repeat on Success). You can cancel it using the IS Administration Web UI (Server
> Statistics > System Threads). Click the yellow checkmark beside the service to cancel it.
4BS Solutions
www.4bs-solutions.com
Exercise 3:
Handling big XML Documents
Ov er v ie w
In this exercise you learn how the Terracotta cache and Big Memory are used to load big XML
Documents.
Ta sk
1. Setup environment
2. Start a command prompt window, execute Env.bat
3. Copy BigXML folder to
${InstallDir}\IntegrationServer\packages\V97TrainingESBSupport\pub\BigXML
4. Try to load a small (800KB) XML document from the server by typing the following command
in the command prompt:
curl -u Administrator:manage
http://localhost:5555/V97TrainingESBSupport/BigXML/rfclistSmall.xml
5. Create Flow service called loadBigXML to load an XML document as shown below:
4BS Solutions
www.4bs-solutions.com
10. Next configure the IS to use Enhanced XML Parsing so that it uses Caching and BigMemory.
In the IS Administration Web UI go to: Settings > Enhanced XML Parsing Edit the settings
using the screenshot below as guidance. Save your changes and then enable Caching and Big
Memory Caching.
11. Now run the service loadBigXMLEx to load your big document. The load process takes about
40-60 seconds, depending on your machine. Look at the Performance information in Task
Manager and then the Peak Usage Statistics in the IS Administration Web UI. The Peak Usage
stats will show you how much Big Memory was used. Note: you will have to refresh the IS
Admin web page to see the updated Peak Usage stats.
4BS Solutions
www.4bs-solutions.com
12. Once you successfully loaded the document, create a Flow service called queryXML to query
your loaded document as shown below:
4BS Solutions
www.4bs-solutions.com