Archived

This forum has been archived. Please start a new discussion on GitHub.

How to know the identity name of the server on IceGrid

Inside the server code, how can I get the server identity?

Exemple: I have 2 servers called "server-${index}" on the template, how can I know if my code is running from "server-1" or "server-2"?

Other thing, I can discover which server or client called the RPC or I need to send with the data Im sending?

Comments

  • benoit
    benoit Rennes, France
    Hi,

    You can check for the Ice.Admin.ServerId property in the server or set a property within the server descriptor as show in server descriptor element documentation.

    You can obtain connection information on the client or server sending using the Ice::Connection::getInfo() method (you can obtain the connection either through the servant Ice::Current parameter or the proxy ice_getConnection method). If you need other information such as the server identifier, you will need to pass it with the request parameters.

    Cheers,
    Benoit.
  • thank you. but there is a way to know which server called a the method on other server?

    Like if a server-1 call another method on server-2, In the server-2 code I can get which server name or id called the method? Or I need to transmit in the message from server-1?

    using current on server-2 I could only get information about the server-2 not the server-1 that invoked the method.
  • benoit
    benoit Rennes, France
    Hi,

    Ice doesn't provide this information so this is something you will have to provide with the request. You can either provide it explicitly as an extra request parameter or use the request context. See Requests Contexts for more information on contexts.

    Cheers,
    Benoit.
  • benoit wrote: »
    Hi,

    Ice doesn't provide this information so this is something you will have to provide with the request. You can either provide it explicitly as an extra request parameter or use the request context. See Requests Contexts for more information on contexts.

    Cheers,
    Benoit.

    thank you, you helped a lot