Archived

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

IceStorm subscription with Initial snapshot

Hi,

I am using IceStorm to implement pub/sub pattern. One of the requirement is that the subscriber will receive the latest message image as the initial snapshot before receiving subsequent updates. This will make sure the client will not be blank if the update is not frequent (or the publisher has no more updates).

I try to implement this following the "Publishing to a Specific Subscriber" in Ice documentation. Several questions raised during my development. Here is the slice:
["cpp:type:helloworld::MarketSummary"] sequence<byte> MarketSummary;

    interface MarketObserver {
        void update(MarketSummary s);
    };

    sequence<int> TopicNames;
    sequence<MarketObserver*> MarketObservers;

    interface MarketSummaryProvider {
        void subscribeSingle(TopicNames topicName, MarketObserver* monitor);
        void subscribe(TopicNames topicName, MarketObservers monitors);
        void subscribeAll(MarketObserver* monitor);
        void unsubscribe(TopicNames topicName, MarketObserver* monitor);
    };

The Publisher(Server) implements MarketSummaryProvider::subscribe* methods which call Topic.subscribeAndGetPublisher to subscribe and send initial snapshot to subscriber. Publisher has a thread which will send message to Topic publisher for normal updates.
On the other hand the Subscriber(Client) implements MarketObserver, add to objectAdapter and then pass to Publisher(Server) by invoking the MarketSummaryProvider::subscribe*.

Here is my questions:
1. Is the initial snapshot and normal update guarantee of update sequence? Would it be possible the Subscriber(Client) receive a normal update(up2date) before receiving the initial snapshot(outdated).

2. If there has no such guarantee of update sequence, what would be the best practice to handle? Should I add a last sequence number to all of the ICE message use in this ?

3. In the Subscriber(Client), i need to create ObjectAdapter to 'host' the MarketObserver. Do I need to have unique ObjectAdapter name across different instance of client processes?

I am not sure is the initial snapshot a general problem to others but it is quite general to me for implementing finance applications. It would be good to have a best practice for this problem, or even better IceStorm can support initial snapshot in native.

Thx
Raymond

Comments

  • benoit
    benoit Rennes, France
    raycray wrote: »
    Hi,

    Here is my questions:
    1. Is the initial snapshot and normal update guarantee of update sequence? Would it be possible the Subscriber(Client) receive a normal update(up2date) before receiving the initial snapshot(outdated).

    If you are using two-way invocations to publish and forward your updates then yes the requests should arrive in the same order as the order used for the publishing.

    If you use oneway invocations, you will need to be careful and ensure that the oneway invocations can't be dispatched out of order (either by IceStorm or by your subscriber). See this FAQ for more information on the reasons why a oneway request can arrive out of order.
    2. If there has no such guarantee of update sequence, what would be the best practice to handle? Should I add a last sequence number to all of the ICE message use in this ?

    Unless you use oneway invocations or if it's impractical in your publisher to guarantee the ordering of the publish calls, you shouldn't need to use sequence numbers. If you do need sequence numbers however, one option to avoid adding this sequence number to all your data types would be to encode the number in the request Ice::Context.
    3. In the Subscriber(Client), i need to create ObjectAdapter to 'host' the MarketObserver. Do I need to have unique ObjectAdapter name across different instance of client processes?

    No, object adapter names don't need to be unique across the deployment of your application. Object adapter names are scoped by the Ice communicator and used as the prefix of object adapter configuration properties.
    I am not sure is the initial snapshot a general problem to others but it is quite general to me for implementing finance applications. It would be good to have a best practice for this problem, or even better IceStorm can support initial snapshot in native.

    Thanks for the feedback. We are actually considering implementing an improved messaging system which would among other things provide a solution for this.

    With IceStorm, this is currently the only way to provide the initial state of the publisher. In case you didn't already check it out, you can take a look at the C++ demo/IceStorm/counter demo from your Ice distribution for an example demonstrating how to send the initial state.

    Cheers,
    Benoit.