I used this Business process and Java Task to simulate an Out Of Memory situation on IBM Sterling B2B Integrator.
The Business Process will call a little Java program that will keep on allocating large chunks of memory until the heap is exhausted.
It will be fun to watch the memory growth graphically on your favourite monitoring tool.
Only use for testing! as OOM cannot be recovered and you will need to restart the application.
Business process code:
Java Task source: javataskOOM.java:
import java.io.InputStream;
import java.io.OutputStream;
import com.sterlingcommerce.woodstock.workflow.Document;
import java.util.*;
List l = new ArrayList();
for(int j=0; j<10000000; j++)
for (int i=0; i<10000000; i++){
final String mytext =(" Microservices are increasingly used in the development world
as developers work to create larger, more complex applications that are better
developed and managed as a combination of smaller services that work cohesively
together for larger, application-wide functionality. Tools such as Service Fabric
are rising to meet the need to think about and build apps using a piece-by-piece
methodology that is, frankly, less mind-boggling than considering the whole of the
application at once. Today, we’ll take a look at microservices, the benefits of
using this capability, and a few code examples.");
l.add(mytext+mytext+mytext+i+j);
Thread t = new Thread(){
public void run(){
for(int k=0; k<100; k++){
List another = new ArrayList();
another.add(mytext+k);
}
}
};
t.start();
// To slow down the OOM un comment the line below:
//Thread.sleep(1);
}
return "OK";
Configure a java task called javatask1 in the Sterling B2B Integrator UI under Deployment/Services/Configuration:
Run the Business Process and wait for your OOM!:
Further reading:
How to write an IBM Sterling B2B Integrator Java Task Service
What can you do with the Java Task Service How the Java Task Service Works -
Leave a Reply