Archived

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

Templates with session activation

Hello,

I have looked at the session activation example and have tried to templatise it. The original is as follows:
<icegrid>

  <application name="Session">

    <node name="localhost">
      <server id="SessionServer" exe="./server" activation="session">
	<adapter name="Hello" endpoints="tcp">
	  <allocatable identity="hello" property="Identity"/>
	</adapter>
      </server>
    </node>

  </application>

</icegrid>

I amended it by following the IceGrid simple example "application_with_template.xml" to give the following:
<icegrid>

  <application name="Session">

    <server-template id="SessionServer">
      <parameter name="index"/>
      <server id="SimpleServer-${index}" exe="./server" activation="session">
        <adapter name="Hello" endpoints="tcp">
          <allocatable identity="hello-${index}" type="::Demo::Hello"/>
        </adapter>
      </server>
    </server-template>

    <node name="localhost">
      <server-instance template="SessionServer" index="1"/>      
    </node>

  </application>

</icegrid>

I start up an icegridnode as in the sessionActivation example and run icegridadmin to apply the above configuration.

When I start the client from sessionActivation it throws an exception "object not registered with registry". I presume it is looking for allocatable object "hello" instead of "hello-${index}". However, I still want the code to look for "hello". Do you know how I can achieve this or have I mis-configured the application?

Thanks,
Keith

Comments

  • benoit
    benoit Rennes, France
    Hi,

    You should change:
    <allocatable identity="hello-${index}" type="::Demo::Hello"/>
    

    To:
    <allocatable identity="hello" type="::Demo::Hello"/>
    

    If you want to register the hello allocatable object instead of hello-${index}. It's not clear to me why you would want to do this however. By using a fixed identity for this object, you won't be able to deploy multiple servers (since only one server instance can register a given well-known object) so using a template here won't be really useful.

    If you need additional clarifications on this, could you detail a little more what you are trying to achieve?

    Cheers,
    Benoit.
  • Hi Benoit,

    My aim is to have multiple servers all providing the Hello proxy for multiple clients to be able to use. Ultimately, I may have several icegridnodes each running numerous instances of the SessionServer. I need them each to be allocatable, but if I use "hello-${index}" as their identity, how does the client find a single server that exposes the "hello" proxy? Essentially, I don't want the client to need hard-coding to a particular id, i.e. "hello-1" in order to allocate an object.

    Let me know if you require more information.

    Thanks,
    Keith
  • benoit
    benoit Rennes, France
    Hi,

    Instead of allocating the object by id, your clients should allocate the object by type, see the demo/IceGrid/allocate demo for an example (deployed using with application-multiple.xml).

    This way, your client don't need to know the identity of the object. Instead, the IceGrid::Session allocateByType method returns one of the available object.

    Cheers,
    Benoit.
  • Hi Benoit,

    Thanks for the advice.

    It's working as I need now.

    Keith