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 associatedNamespace
, 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 theNamespace
on to its associatedDataProvider
. However it only passes a discard request on to theDataProvider
when 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
DataProvider
would receive two requests, one at step 1 and another at step 2. However theDataProvider
would only receive one discard, which would be at step 4. The purpose of this logic is to simplify the job of theDataProvider
. It still needs to send out a new image whenever a newPeer
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
'sDataProvider
receives a call toDataProvider.onRequest(RequestEvent)
every time a new peer requests a subject. TheDataProvider
must respond by callingPublisher.publishInitialMessage(Message)
to ensure that each requesting (subscribing) peer receives an initial image. Each call toPublisher.publishInitialMessage(Message)
sends the image to all peers that have requested the subject since the previous call toPublisher.publishInitialMessage(Message)
.The
DataProvider
receives a single call toDataProvider.onDiscard(DiscardEvent)
when the last peer discards the subject. This is the signal to theDataProvider
that it can stop sending updates, and unsubscribe from streaming data for the subject from the back end system. As explained above, theDataProvider
does not receive a call toDataProvider.onDiscard(DiscardEvent)
every time a peer discards the subject, it just receives one call when the last peer discards the subject.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
publishStatusEventToAllSubjects(StatusEvent statusEvent)
Publishes to all subscribed peers an event about the change in status of all subjects.-
Methods inherited from interface com.caplin.datasource.publisher.Publisher
getMessageFactory, publishInitialMessage, publishMappingMessage, publishSubjectErrorEvent, publishSubjectStatusEvent, publishToSubscribedPeers
-
-
-
-
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 theDataProvider
changes.- Parameters:
statusEvent
- The status event to be published.
-
-