Tahir,
I replied for the same in wmusers. Yet here the scenario is more clear that you want only single invoke for each call to JSP and I assume that they are not from same user in the same session. So, to have Connection Pool is the best.
You can implement connection pool in your java class (servlet). The number of connections to be kept alive will depend on the JSP page hit rate and time taken for the invoke() to return.
To implement the connection pool, I suggest to have a servlet which will have init() and destroy() methods to initialise and drop connections. You will need two synchronized methods in this. Detailed below.
- In the init(), create as many connections needed and keep them in a HashMap(pool) with running numbers as key.
- Have flag(int) to hold the index of next available connection.
- Context synchronizedGetContext():
Returns a Context of available.
Before returning increment flag (Flag+1).
- boolean synchronizedReturnContext(Context cxt):
Put this context at Flag-1.
should be incremented in a synchronized method, to avoid two different requests manipulating the flag at a time.
4. YourMethod() containing invoke() need not be synchronized.
5.
#Integration-Server-and-ESB#webMethods