Archived

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

icestorm and multiple subscriptions

I am implementing a monitoring server that subscribe to all topics from a given type of servants, but I cannot find a 'clean' way to do it.

all servants are similar and publish using the same interface on their own topic
interface LogMonitor {
void log(string info);
};

My problem is that to subscribe to a topic you need to register a servant implementing the interface. Thus either I subscribe the same servant to all topics and I need to find a way to know which topic called my interface (Is this possible ? ) or I need to create a new servant for each topic I want to listen to...this sound quite heavy... Any idea ?

I spend the day searching but I could not find out a satisfying solution..

Olivier

Comments

  • I would not be overly concerned about registering a separate servant for each topic. Servants are not that heavy-weight objects, and it should not matter how many you have (unless there are many thousands at least).

    If you are really concerned about the cost of separate servants, you can use a single servant for multiple topics by registering the same servant multiple times in the ASM under different object identities. Use the topic name as part of the object identity. Then, when an event is received, the servant can use the Current object to look at the object identity to extract the topic.

    Another option would be to use a servant locator to implement a default servant. That way, instead of using the ASM with multiple entries for the same servant, you simply put the topic name into the object identity and just have the default servant handle all the incoming events. Again, the Current object for each incoming event then gives you access to the object identity, which contains the topic name.

    Cheers,

    Michi.