Interface MessageFactory
A message factory is used to create DataSource messages that can be published to other DataSources.
You do not have to implement this interface yourself. An implementation is provided, and can be
retrieved from any Publisher
by calling the
Publisher.getMessageFactory()
method.
-
Method Summary
Modifier and TypeMethodDescriptioncreateContainerMessage
(String subject) Creates a message that defines a container.createGenericMessage
(String subject) Creates an empty Generic message to which structured data can be added.createJsonImageMessage
(String subject, String json) Deprecated.createJsonPatchMessage
(String subject, String json) Deprecated.createMappingMessage
(String subject, String mapping) Creates a MappingMessage for mapping subjects.createNewsMessage
(String subject, String headline, String storyReference, String newsDateTime) Creates a News message for the given subject.createPageMessage
(String subject, int maxColumns, int maxRows) Creates a Page message for the given subject.createPermissionMessage
(String subject, String key) Creates a Permission message for the given subject.createRecordType1Message
(String subject) Creates a Record message to which Type 1 structured data can be added.createRecordType2Message
(String subject, String type2IndexField, String type2IndexValue) Creates a Record message to which Type 2 structured data can be added.createRecordType3Message
(String subject) Creates a Record message to which Type 3 structured data can be added.createStatusEvent
(SubjectStatus status, String message) Creates a status event.createStoryMessage
(String subject, String text) Creates a Story message for the given subject.createSubjectErrorEvent
(String subject, SubjectError error, SubjectError.Flags... flags) Creates a subject error event.createSubjectStatusEvent
(String subject, SubjectStatus status, String message) Creates a subject status event.createWrapperMessage
(String subject) Creates a Wrapper message for the given subject.
-
Method Details
-
createRecordType1Message
Creates a Record message to which Type 1 structured data can be added. After publishing a message, do not reuse the message (e.g. change the content, republish) as this can cause issues.
The returned message contains no data. To populate the message with data, use the appropriate methods of
RecordType1Message
.- Parameters:
subject
- The subject of the Record.- Returns:
- A new Type 1 Record message.
-
createRecordType2Message
RecordType2Message createRecordType2Message(String subject, String type2IndexField, String type2IndexValue) Creates a Record message to which Type 2 structured data can be added. After publishing a message, do not reuse the message (e.g. change the content, republish) as this can cause issues.
The returned message contains no data. To populate the message with data, use the appropriate methods of
RecordType2Message
.- Parameters:
subject
- The subject of the Record.type2IndexField
- Field name of the type2 index.type2IndexValue
- The value of the type2 index.- Returns:
- A new Type 2 Record message.
-
createRecordType3Message
Creates a Record message to which Type 3 structured data can be added. After publishing a message, do not reuse the message (e.g. change the content, republish) as this can cause issues.
The returned message contains no data. To populate the message with data, use the appropriate methods of
RecordType3Message
.- Parameters:
subject
- The subject of the Record.- Returns:
- A new Type 3 Record message.
-
createGenericMessage
Creates an empty Generic message to which structured data can be added. After publishing a message, do not reuse the message (e.g. change the content, republish) as this can cause issues.
Generic messages can be used without specifying field mappings in a separate adapter configuration file. This may be useful when receiving updates from a provider which supplies a variable or unknown number of fields. After publishing a message, do not reuse the message (e.g. change the content, republish) as this can cause issues. The returned message contains no data. To populate the message with data, use the appropriate methods of
GenericMessage
.- Parameters:
subject
- The subject of the Record.- Returns:
- A new Generic Type message.
-
createMappingMessage
Creates a MappingMessage for mapping subjects. After publishing a message, do not reuse the message (e.g. change the content, republish) as this can cause issues.
The returned message contains the mapped subject.
- Parameters:
subject
- The subject of the message.mapping
- The mapped subject of the message- Returns:
- A new MappingMessage.
-
createContainerMessage
Creates a message that defines a container. The name of the container is the given subject. After publishing a message, do not reuse the message (e.g. change the content, republish) as this can cause issues.
- Parameters:
subject
- The subject defining the name of the container.- Returns:
- A message defining the container.
-
createNewsMessage
NewsMessage createNewsMessage(String subject, String headline, String storyReference, String newsDateTime) Creates a News message for the given subject. After publishing a message, do not reuse the message (e.g. change the content, republish) as this can cause issues.
The method parameters allow you to set the basic content of the message: its subject, headline, story reference, and date+time. To add keywords or terms describing the news headline, call the
NewsMessage.getTags()
method on the newly created message (seeNewsMessage
). To set permissions for theNewsMessage
, callNewsMessage.setPermission(String)
.- Parameters:
subject
- The subject identifying the news message.headline
- The news headline.storyReference
- The reference to the news story associated with the headline.newsDateTime
- The date and time of the news headline.- Returns:
- A new News message.
-
createPageMessage
Creates a Page message for the given subject. After publishing a message, do not reuse the message (e.g. change the content, republish) as this can cause issues.
The returned message contains no data. To populate the message with data, use the appropriate methods of
PageMessage
.- Parameters:
subject
- The subject of the page message.maxColumns
- The maximum horizontal size of the page in columns of text characters.maxRows
- The maximum vertical size of the page in rows of text.- Returns:
- A new Page Message.
-
createPermissionMessage
Creates a Permission message for the given subject. After publishing a message, do not reuse the message (e.g. change the content, republish) as this can cause issues.
The returned message contains no data. To populate the message with data, use the appropriate methods of
PermissionMessage
.- Parameters:
subject
- The subject of the Permission message.key
- The permission key.- Returns:
- A new Permission message.
-
createStoryMessage
Creates a Story message for the given subject. After publishing a message, do not reuse the message (e.g. change the content, republish) as this can cause issues.- Parameters:
subject
- The subject of the story.text
- The story text.- Returns:
- A new Story message.
-
createWrapperMessage
Creates a Wrapper message for the given subject. After publishing a message, do not reuse the message (e.g. change the content, republish) as this can cause issues.- Parameters:
subject
- The subject of the story.- Returns:
- A new Wrapper message.
-
createJsonImageMessage
Deprecated.Creates a JSON message for the given subject.- Parameters:
subject
- The subject of the message.json
- The json obj.- Returns:
- A new JSON message.
-
createJsonPatchMessage
Deprecated.Creates a JSON diff for the given subject.- Parameters:
subject
- The subject of the message.json
- The json obj diff.- Returns:
- A new JSON message.
-
createSubjectErrorEvent
SubjectErrorEvent createSubjectErrorEvent(String subject, SubjectError error, SubjectError.Flags... flags) Creates a subject error event.- Parameters:
subject
- The subject to which the error relates.error
- The error.flags
- Additional flags to be set on the nodata- Returns:
- A subject error event.
-
createSubjectStatusEvent
Creates a subject status event.- Parameters:
subject
- The subject to which the status relates.status
- The status.message
- A free form textual message indicating the reason for the status message being raised.- Returns:
- A subject status event.
-
createStatusEvent
Creates a status event.- Parameters:
status
- The status.message
- A free form textual message indicating the reason for the status message being raised.- Returns:
- A status event.
-