Archived

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

Ice and stateless servers

Hi,

i'm new to Ice and come from a J2EE background, with a distant CORBA knowledge.

I've checked the documentation, but found nothing comparable to a Java Stateless Sessionbean (SSB).

Is there an easy way to build a Ice server that
o uses a pool of (stateless) objects
o guarantees that during a call, the object is used by exactly one client
o grows/shrinks the pool dynamicly
o blocks incoming connections until a pool object is available?

Thanks for any answers,

Jürgen

Comments

  • This isn't hard to implement.
    1. Allocate a bunch of servants and put them in a free list.
    2. Write a servant locator that, for each incoming call, takes a servant from the free list, puts the servant into a in-use list, and returns that servant; if the free list is empty, block in the locate() call until a servant gets back into the free list; in the deactivate call, remove the servant from the in-use list and put it back on the free list.
    All this takes only about 15-20 lines of code. If you are looking for inspiration, read the section on evictors in the doc and look at the code in demo/book/evictor. (An evictor is similar but a bit more complex than what you want to do.

    Cheers,

    Michi.
  • Thanks a lot for the quick answer, i'll look at it!