Interface ActivePublisher

  • All Superinterfaces:
    Publisher
    All Known Subinterfaces:
    TransformerPublisher

    public interface ActivePublisher
    extends Publisher

    This implementation of Publisher publishes updates that are for subjects within its associated Namespace, to all peers that have subscribed to those subjects.

     

    Instantiate this interface using the appropriate Caplin API method.

     

    ActivePublisher passes all requests for subjects in the Namespace on to its associated DataProvider. However it only passes a discard request on to the DataProvider when all of the subscribed peers have discarded the subject. For example, consider this sequence of events:

     

    1. Peer 1 requests /SUBJECT
    2. Peer 2 requests /SUBJECT
    3. Peer 1 discards /SUBJECT
    4. Peer 2 discards /SUBJECT

     

    In this case the DataProvider would receive two requests, one at step 1 and another at step 2. However the DataProvider would only receive one discard, which would be at step 4. The purpose of this logic is to simplify the job of the DataProvider. It still needs to send out a new image whenever a new Peer requests a subject. However, when it receives a single discard for the subject, it can immediately stop sending out updates, since the discard indicates that there are now no peers subscribed to that subject.

     

    In detail, the ActivePublisher's DataProvider receives a call to DataProvider.onRequest(RequestEvent) every time a new peer requests a subject. The DataProvider must respond by calling Publisher.publishInitialMessage(Message) to ensure that each requesting (subscribing) peer receives an initial image. Each call to Publisher.publishInitialMessage(Message) sends the image to all peers that have requested the subject since the previous call to Publisher.publishInitialMessage(Message).

     

    The DataProvider receives a single call to DataProvider.onDiscard(DiscardEvent) when the last peer discards the subject. This is the signal to the DataProvider that it can stop sending updates, and unsubscribe from streaming data for the subject from the back end system. As explained above, the DataProvider does not receive a call to DataProvider.onDiscard(DiscardEvent) every time a peer discards the subject, it just receives one call when the last peer discards the subject.

    • Method Detail

      • publishStatusEventToAllSubjects

        void publishStatusEventToAllSubjects​(StatusEvent statusEvent)
        Publishes to all subscribed peers an event about the change in status of all subjects. This method can be used to change the status of requested subjects when the status of the DataProvider changes.
        Parameters:
        statusEvent - The status event to be published.