public interface Message
A Message
represents a DataSource message containing an update to an existing
subject or a complete image of it.
Message
is the base interface for all messages generated by DataSource regardless of
the message type. Therefore the base interface provides no functionality for altering the content
of the message and one of the following derived interfaces should be used to add data to a
Message
:
RecordType1Message
RecordType2Message
RecordType3Message
GenericMessage
ContainerMessage
PermissionMessage
NewsMessage
StoryMessage
PageMessage
You do not have to implement this interface yourself. Implementations of Message
can
be created by calling the relevant creation method on
MessageFactory
; for example,
MessageFactory.createRecordType1Message(String)
or
MessageFactory.createContainerMessage(String)
.
The following example sends a Type 1 record image to all subscribed peers.
import com.caplin.datasource.messaging.record.RecordType1Message;
import com.caplin.datasource.publisher.Publisher;
public class SendingARecordImage
{
void sendRecordImage(Publisher publisher, String subject)
{
RecordType1Message message = publisher.getMessageFactory().createRecordType1Message(subject);
// Indicate that this is an image.
message.setImage(true);
// Add a Bid and Ask field to the message.
message.setField("Bid", "22.0");
message.setField("Ask", "22.1");
// Send the message to the subscribed peers.
publisher.publishToSubscribedPeers(message);
}
}
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getSubject()
Gets the subject of this message.
|
boolean |
isImage()
Gets a boolean value indicating whether this
Message represents an image or an
update. |
void |
setImage(boolean image)
Sets a boolean value indicating whether this
Message represents an image of the
data or an update to it. |
boolean isImage()
Message
represents an image or an
update. By default, this method returns false
indicating that the
Message
is an update and not an image. To change a message to be an
image, call setImage(boolean)
passing in the value true
.true
if this message is an image of the object, false
if it
is an update to the existing state of the object.void setImage(boolean image)
Message
represents an image of the
data or an update to it. By default, a newly created Message
is deemed to be an
update and not an image.image
- When set to true
, the receiver will clear all previous data for that
subject before adding the sent data. When set to false
, the receiver
adds the sent data to previous data sent to that subject.java.lang.String getSubject()
Please send bug reports and comments to Caplin support