This page explains how to set up your environment, and also explains how to use a sample application to test your environemnt.
You will need to follow these steps to get your environment running
For this exercise, we can use Derby and assume that it is highly available. Specifically is, we will use Derby that comes bundled with GlassFish. We need to start the database server on only one of the GlassFish instances. To start the database, open a command prompt, navigate to GF installation directory, change directory to bin, and type asadmin start-database
This will start Derby independent of GlassFish, meaning if GlassFish is stopped or killed, the database server will still be running. All the files related to the Derby are created under the databases folder in your GlassFish installation.
Once you have installed GlassFish on two machines, you will need to configure each one of them. Start one of the GlassFish instances and login to the admin console using http://{host1}:4848.
to create the required connection pools and JDBC resources.
If you are using Oracle, then follow these instructions
.
. Restart GlassFish.
. When installing IEP SE, accept the defaults in you have created the JDBC resources with names as suggested in the instructions. Otherwise, change those values appropriately.
Do the above three steps for the second GlassFish instance. Make sure to specify a different value for the JVM option com.sun.jbi.iepse.instanceName (use instance2 for this example).
Your setup is complete. Follow the steps in the next section to run the sample application.
.
and open the projects TupleBasedAvgCalculator and TupleBasedAvgCalculatorApp in NetBeans. Open the file TupleBasedAvgCalculatorProcess.wsdl. Locate the following line
<soap:address location="http://localhost:${HttpDefaultPort}/service/TupleBasedAvgCalculatorProcess_iep"/>
This is the address to which the events (SOAP messages) will be sent. However, the token ${HttpDefaultPort} will need to be replaced by actual port numbers. Usually the default is 9080.
To make sure that the application is deployed correctly on both the instances, try to access the published WSDLs as follows, by entering in the web browser
http://{host1}:9080/service/TupleBasedAvgCalculatorProcess_iep?wsdl AND
http://{host2}:9080/service/TupleBasedAvgCalculatorProcess_iep?wsdl
Create a new project and import the above two WSDLs in the SOAP UI. Create two Requests, one for each Request. A sample XML message is generated for each Request. Specify an integer value for the element named number in each of the two Requests. Send five messages from each of the two Requests. This means that we are sending events to both the instances. However, the processing would be done only by one instance and consequently, the output will be written to the file by that instance. Open TupleBasedAvgCalculatorProcess.wsdl, and locate the lines
<port name="OutputPort_StreamOutput0" binding="tns:OutputBinding_StreamOutput0">
<file:address fileDirectory="TupleBasedAvgCalculatorProcess_iep"/>
</port>
Here the file path is relative, so the output file will be generated relative to the instance which is doing the processing. Search for a directory under name "TupleBasedAvgCalculatorProcess_iep" under the GlassFish installation directory of both the machines. You should only find it in one of the two GlassFish instances. This means, the IEP SE on that GlassFish instance owns the IEP process. Under the folder, you should see a file named StreamOutput0.txt. Verify that the average is correct.
Note: if you do not see the directory or the file, try sending another message from the SOAP UI.
Now, let us kill the GlassFish instance that owns the process, to see whether the IEP process fails-over to the other live instance. First send three messages from each of the two Requests. Then use your OS's command to kill the GlassFish instance that has the IEP SE that owns the process. Now send another 4 messages to the GlassFish that is still alive. Search for a directory named "TupleBasedAvgCalculatorProcess_iep" under the GlassFish instance that is alive. You should see the file StreamOutput0.txt inside it with the correct average value. The StreamOutput0.txt file under other GlassFish instance should remain unchanged. This means that IEP instance from the alive GlassFish has taken over the ownership of the IEP process. This shows that the IEP High Availability and Failover works!