Search code examples
connectionvmwarevmware-sdk

Pass vijava ServiceInstance via rabbitmq or another task queue


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?


Solution

  • 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