Interface Publisher
-
- All Known Subinterfaces:
ActivePublisher
,BroadcastPublisher
,CompatibilityPublisher
,TransformerPublisher
public interface Publisher
An instance of
Publisher
publishes messages to remote DataSource peers on behalf of aDataProvider
. It also provides access to aMessageFactory
that creates the messages to be published.DataSource for Java includes several implementations of
Publisher
that you can use in your DataSource application: seeBroadcastPublisher
,ActivePublisher
andCompatibilityPublisher
. To use one of thesePublisher
s, call the appropriate "create publisher" method on the API:These three child interfaces declare no methods further to those declared in
Publisher
and currently only serve to tag eachPublisher
type. However, it is possible that future versions of DataSource for Java may add publisher-type specific methods to these interfaces if deemed appropriate or useful.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description MessageFactory
getMessageFactory()
Gets theMessageFactory
used to create the messages that are published via thisPublisher
.void
publishInitialMessage(Message message)
Publishes the initial image of the data for a subject to peers that have just requested (subscribed to) that subject.void
publishMappingMessage(MappingMessage mappingMessage)
Publishes a message that instructs the peer that it should request a different subject and map the updates across.void
publishSubjectErrorEvent(SubjectErrorEvent subjectErrorEvent)
Publishes to all peers subscribed to a subject an event detailing an error in the subscription for that subject.void
publishSubjectStatusEvent(SubjectStatusEvent subjectStatusEvent)
Publishes to all subscribed peers an event about the change in status of a subject.void
publishToSubscribedPeers(Message message)
Publishes a message to subscribed peers (that is, the peers that have already received an initial image).
-
-
-
Method Detail
-
getMessageFactory
MessageFactory getMessageFactory()
Gets theMessageFactory
used to create the messages that are published via thisPublisher
.- Returns:
- The message factory.
-
publishInitialMessage
void publishInitialMessage(Message message)
Publishes the initial image of the data for a subject to peers that have just requested (subscribed to) that subject. After publishing a message, do not reuse the message (e.g. change fields, republish) as this can cause issues.- Parameters:
message
- The message.
-
publishToSubscribedPeers
void publishToSubscribedPeers(Message message)
Publishes a message to subscribed peers (that is, the peers that have already received an initial image). After publishing a message, do not reuse the message (e.g. change the content, republish) as this can cause issues.- Parameters:
message
- The message to be published. This may be an image or an update.
-
publishMappingMessage
void publishMappingMessage(MappingMessage mappingMessage)
Publishes a message that instructs the peer that it should request a different subject and map the updates across. After publishing a message, do not reuse the message (e.g. change the content, republish) as this can cause issues.- Parameters:
mappingMessage
- The message.
-
publishSubjectErrorEvent
void publishSubjectErrorEvent(SubjectErrorEvent subjectErrorEvent)
Publishes to all peers subscribed to a subject an event detailing an error in the subscription for that subject. Typically aDataProvider
will use this to notify the remote peers that the data they are subscribed to is no longer available. After publishing a message, do not reuse the message (e.g. change the content, republish) as this can cause issues.- Parameters:
subjectErrorEvent
- The error event to be published.
-
publishSubjectStatusEvent
void publishSubjectStatusEvent(SubjectStatusEvent subjectStatusEvent)
Publishes to all subscribed peers an event about the change in status of a subject. After publishing a message, do not reuse the message (e.g. change the content, republish) as this can cause issues.- Parameters:
subjectStatusEvent
- The subject status event to be published.
-
-