public class CachedPublisher extends Object
Provides a mechanism for publishing messages and events; maintains a cache so that new subscribers can be serviced with existing messages automatically.
Messages can be published using publishMessage(com.caplin.datasource.messaging.Message)
Modifier and Type | Method and Description |
---|---|
void |
clearCache()
Clears the cache held by this publisher.
|
com.caplin.datasource.messaging.MessageFactory |
getMessageFactory()
Returns the message factory that can be used to create messages, error
and status events.
|
void |
publishErrorEvent(com.caplin.datasource.SubjectErrorEvent subjectErrorEvent)
Publishes a SubjectErrorEvent to all peers subscribed to the
subject of the event.
|
void |
publishMessage(com.caplin.datasource.messaging.Message message)
Publishes a message to all peers that are subscribed to the subject of
the message.
|
void |
publishStatusEvent(com.caplin.datasource.SubjectStatusEvent subjectStatusEvent)
Publishes a SubjectStatusEvent to all peers subscribed to the
subject of the event.
|
void |
sendNotFound(String subject)
Sends a NotFound and removes any subscription from the cache.
|
void |
sendNotStale(String subject)
Sets the status of a subject to NotStale.
|
void |
sendStale(String subject)
Sets the status of a subject to Stale.
|
void |
sendUnavailable(String subject)
Sends a Unavailable and removes any subscription from the cache.
|
public void publishMessage(com.caplin.datasource.messaging.Message message)
The cache will be updated with the new fields from this message, but will also retain any fields that are present in the previously sent message that are not present in this message.
message
- The message to publish.public void sendNotFound(String subject)
subject
- The subject to send the NotFound for.public void sendUnavailable(String subject)
subject
- The subject to send the Unavailable for.public void sendStale(String subject)
Sets the status of a subject to Stale.
If the subject is not currently marked as Stale, a Stale message will be sent. If the subject is already marked as Stale when this method is called then no message is sent.
subject
- The subject to set the status to Stale for.sendStale(String)
public void sendNotStale(String subject)
Sets the status of a subject to NotStale.
If the subject is not currently marked as NotStale, a NotStale message will be sent. If the subject is already marked as NotStale when this method is called then no message is sent.
subject
- The subject to set the status to NotStale for.sendNotStale(String)
public void publishErrorEvent(com.caplin.datasource.SubjectErrorEvent subjectErrorEvent)
subjectErrorEvent
- The error event to publish.SubjectErrorEvent
public void publishStatusEvent(com.caplin.datasource.SubjectStatusEvent subjectStatusEvent)
subjectStatusEvent
- The status event to publish.SubjectStatusEvent
public com.caplin.datasource.messaging.MessageFactory getMessageFactory()
public void clearCache()
Copyright © 2018 Caplin Systems.