BEA Logo BEA WebLogic Server Release 6.1

  BEA Home  |  Events  |  Solutions  |  Partners  |  Products  |  Services  |  Download  |  Developer Center  |  WebSUPPORT

 

  |  

  WebLogic Server Doc Home   |     WebLogic jCOM Reference Guide   |   Previous Topic   |   Next Topic   |   Contents   |   View as PDF

Threading

 

 


From Java to COM

WebLogic jCOM has been designed to handle multiple simultaneous requests to COM objects from Java.

The WebLogic jCOM runtime DCOM engine will allow multiple simultaneous requests to the same COM object, as well as to different COM objects, and since WebLogic jCOM talks DCOM, and DCOM is layered over DCE RPC, WebLogic jCOM will split large method invocations into multiple RPC PDUs, and reassemble responses that have been split up.

Whether the remote COM object correctly handles multiple simultaneous requests is entirely dependant on its threading model and implementation.

 


From COM to Java

WebLogic jCOM maintains a pool of threads for handling requests from COM objects. By default, WebLogic jCOM allows a maximum of twenty threads for handling such requests, however you may change the maximum by setting the JCOM_MAX_REQUEST_HANDLERS property to the number you want, as in:

java -DJCOM_MAX_REQUEST_HANDLERS=50 YourMainProgram

WebLogic jCOM creates such threads as and when they are required. That is to say, it does not immediately create twenty threads on start up. It creates the first thread when the first remote request comes in. If a second request comes in, and the first thread is busy servicing a request, then WebLogic jCOM will create a second thread to handle the second request, and so on, up to the maximum of twenty (by default).

If you are interested in seeing WebLogic jCOM's thread allocation mechanism in action, you can run WebLogic jCOM with internal logging enabled (set the JCOM_LOG_LEVEL property to 3, the maximum). The following Visual BASIC code makes a callback to a Java object (p1 is a Java object):

Public Sub method1(ByVal p1 As Object)
p1.aMethod
End Sub

This is an excerpt from the log, showing what happens. The IDispatch::GetIDsOfNames is handled internally by WebLogic jCOM, using reflection.

13:05:20+: ObjectExporter0 received an unfragmented request with 
call ID 1
13:05:20+: Maximum number of request handler threads is set to 20
13:05:20+: There are 0 request handler threads, of which 0 are 
currently busy.
13:05:20+: Creating a new request handler thread.
13:05:20 : IDispatch::GetIDsOfNames request on ExcepDemo@1f230b for 
AMETHOD. Returning memid 9
13:05:20+: ObjectExporter0 sending 44 bytes
13:05:20+: ObjectExporter0 read 192 bytes
13:05:20+: ObjectExporter0 received an unfragmented request with 
call ID 2
13:05:20+: There are 1 request handler threads, of which 0 are 
currently busy.
13:05:20 : IDispatch::Invoke request received for public void 
ExcepDemo.aMethod() on ExcepDemo@1f230b

If you wish to prevent the same method in your Java object from being invoked more than once at the same time by COM objects, then simply use the standard Java synchronized keyword, which will cause methods invocations to block if another object is already invoking the method.

 

back to top previous page next page