• Post Reply Bookmark Topic Watch Topic
  • New Topic

Multiple clients in RMI  RSS feed

 
Phillip Koebbe
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the server side of RMI, there is this:



And on the client:



If multiple clients connect to the server, are they each getting a unique reference to myObject, or are they all pointing to the same one?

I ask this because I'm beginning to think that I may not have designed my server correctly. In my case, myObject is doing all of my work, which is communicating with QuickBooks. The QB communication process, however, does not handle multiple simultaneous requests from the same client (my server), so if all of my server's clients are using the same server, then each one will have to get in line as requests are sent to QB. If that is the case, I need to create another object and have myObject return this new object to each client. If I am thinking correctly, this should allow each client to access QB independent of the others.

I hope I've asked this clear enough.

Peace,
Phillip
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is only one server object - each client accesses it in a separate thread. I'm not sure that creating separate server objects is the correct way to go about this - from previous questions I remember that you're accessing QuickBooks through JNI - if you create multiple objects that "talk" to the JNI, you're just moving the multiple simultaneous requests down into the level of the JNI - and if QuickBooks isn't made for this, it isn't going to work at that level either. What you're going to need to do is make use of the "synchronized" moderator to make sure only one thread at a time is allowed into the JNI level QuickBooks code. This is obviously going to slow stuff down, since only one thread can go through the synchronized code at a time, but if that's a requirement for the API you're working with, that's what you've got to do...
 
Phillip Koebbe
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response, Nate.

I was toying with my theory, and it was right apart from the QB access. I changed the object that is put in the registry to return another object that does all of the work. Through some tests, I was able to have multiple clients all having their own individual objects to do "the work". Which is what I was originally after.

The problems started when I tried to actually do the work against QB. A DLL gets loaded by the "RequestProcessor", and when multiple clients tried to do work at the same time, the JVM on the server crashed, and I'm guessing it was because of the DLL.

I resolved my situation by doing just what you recommended. I put some blocking code in the worker bee that allows only one client to work with QB at a time. I've done some minimal testing and it seems to work correctly.

Thanks for your help...again.

Peace,
Phillip
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!