Archived

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

Publishing different data types in the same topic (IceStorm)

Hello.

I was wondering if this is possible. To be more specific, consider the (simplified) definition of the following module:
module MOD1
{
    interface sendByte {
         void report(byte fooByte);
	};
    interface sendShort {
         void report(short fooShort);
	};
}

Is is possible to publish both in the same topic? The subscriber would then simply implement both interfaces, and when the publisher publishes bytes or shorts using the corresponding method, IceStorm would take care of calling the appropriate method in the subscriber side.

What about this one?
module MOD1
{
    interface sendData {
         void reportByte(byte fooByte);
         void reportShort(short fooShort);
	};
}

Can both data types be published in the same topic?

The need behind this is that we need to publish data (regularly) and events (seldom) belonging to the same system, and logically they could be published in the same topic.

I found a post with similar question, but it might be a bit old. I'd like to have fresh information.
http://www.zeroc.com/forums/help-center/4865-icestorm.html
So is it possible? Has it been done? Is it possible but discouraged? I don't see the concern on the maintainability of the code that Bernard mentions in the previous post. Comments and explanations appreciated.

BR
Jose

Comments

  • mes
    mes California
    Hi,

    We strongly recommend a 1-to-1 relationship between a topic and an interface. Attempting to use a topic to publish events on multiple interfaces is just asking for trouble.

    First, with respect to subscribers, it isn't really possible for a servant to implement multiple interfaces. As a result, each subscriber can only support one interface.

    Second, keep in mind that IceStorm may (depending on the subscriber's delivery mode) publish its events using oneway invocations, therefore it would have no idea whether an invocation succeeds or fails. If you are publishing events on multiple interfaces through a single topic, it is very likely that some of the subscribers will receive unknown events. These events would normally be silently discarded.

    However, using your first example, the situation becomes even more complex. Both interfaces declare a "report" operation that takes different types of parameters. This means the subscribers will all successfully recognize the "report" invocation, but unmarshaling of the request parameters might fail depending on which type of interface the subscriber supports.

    On the other hand, your second example would work just fine. IceStorm "events" are nothing more than regular Ice invocations that IceStorm forwards to the topic's subscribers. Your publishers can invoke any of the operations supported by the interface associated with that topic. Just remember that it is an administrative responsibility to ensure that the publishers and subscribers of a topic agree on the Slice interface in use; IceStorm does not perform any validation here.

    Regards,
    Mark