I'm trying to create a system where a master will create a connection to vcenter and passes the serviceinstance object to a bunch of performance collectors that can then do their work and exit. My question is what would be the best method to share the SI object? I was thinking of using a messaging queue for the purpose, but I'm not really keen on serializing objects. Is there any other more efficient way?
Asked
Active
Viewed 142 times
1 Answers
1
That SI is only going to work on that vCenter which created the SI. If thats is not going to be a problem for you then simply place the session id on the bus for your workers to pick up then they should be able to create a new SI using the session id.
The first time you connect:
ServiceInstance serviceInstance = new ServiceInstance(new URL("https://vcenter/sdk"),user, passwd, true);
String sessionId = serviceInstance.getServerConnection().getSessionStr();
Next place that sessionId on the bus. Have your worker pick it up and do:
ServiceInstance si2 = new ServiceInstance(new URL("https://vcenter/sdk"), sessionId, true);
The default timeout for that session is like 30 mins IIRC..
Also a little self plugging I would suggest a move from vijava to yavijava. Its a fork I maintain which has added lots of nifty features, and Im even currently adding 6.0 support. https://github.com/yavijava/yavijava

Michael Rice
- 7,974
- 1
- 15
- 18
-
Thanks Michael. I wasn't aware that the sessionId could be used like this between calls. This is exactly what I needed. We are, infact, using yavijava. I wrote vijava thinking most people still know the library by that name. More power to you Michael and I look forward to continue using yavijava – darkstar May 02 '15 at 11:29