- All Superinterfaces:
public interface ActivePublisher extends Publisher
Instantiate this interface using the appropriate Caplin API method.
ActivePublisherpasses all requests for subjects in the
Namespaceon to its associated
DataProvider. However it only passes a discard request on to the
DataProviderwhen all of the subscribed peers have discarded the subject. For example, consider this sequence of events:
- Peer 1 requests /SUBJECT
- Peer 2 requests /SUBJECT
- Peer 1 discards /SUBJECT
- Peer 2 discards /SUBJECT
In this case the
DataProviderwould receive two requests, one at step 1 and another at step 2. However the
DataProviderwould 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
Peerrequests 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
DataProviderreceives a call to
DataProvider.onRequest(RequestEvent)every time a new peer requests a subject. The
DataProvidermust 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
DataProviderreceives a single call to
DataProvider.onDiscard(DiscardEvent)when the last peer discards the subject. This is the signal to the
DataProviderthat it can stop sending updates, and unsubscribe from streaming data for the subject from the back end system. As explained above, the
DataProviderdoes 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.
All Methods Instance Methods Abstract Methods Modifier and Type Method Description
publishStatusEventToAllSubjects(StatusEvent statusEvent)Publishes to all subscribed peers an event about the change in status of all subjects.
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
statusEvent- The status event to be published.