Package com.attivio.sdk.esb
Class AbstractPlatformMessage
- java.lang.Object
-
- com.attivio.sdk.esb.AbstractPlatformMessage
-
- All Implemented Interfaces:
PlatformMessage
,java.io.Serializable
,java.lang.Cloneable
- Direct Known Subclasses:
AbstractIndexMessage
,AdminMessage
,AuthenticationRequest
,AuthenticationResponse
,CgiRequest
,ExceptionResponse
,MultiRegionContentMessage
,ProcessingResultMessage
,PropertiesMessage
,QueryRequest
,QueryResponse
,QueryTrack
,StreamResponse
,StringMessage
public abstract class AbstractPlatformMessage extends java.lang.Object implements PlatformMessage
Base class that handles many of the implementation-level details of an PlatformMessage.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface com.attivio.sdk.esb.PlatformMessage
DEFAULT_MAX_LOG_LENGTH, MESSAGE_DROPPED, MESSAGE_SEND_TIME_PROP, PROP_MAX_LOG_LENGTH
-
-
Constructor Summary
Constructors Constructor Description AbstractPlatformMessage()
Creates a message with no client IDAbstractPlatformMessage(java.util.UUID cid)
Creates a message based on a client ID.AbstractPlatformMessage(java.util.UUID cid, WorkflowQueue workflows)
Creates a message based on a client ID and a workflow queue.AbstractPlatformMessage(java.util.UUID cid, java.lang.String... workflows)
Creates a message based on a client ID.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMessageHistory(MessageHistory msg)
Adds a piece of message history.void
addMessageHistory(java.util.List<MessageHistory> historyList)
Adds a list of history.AbstractPlatformMessage
clone()
Clones the object and resets message ID to -1.boolean
equals(java.lang.Object other)
java.util.UUID
getClientId()
Gets the client to which this message belongs (may have originated with the client or be a response to the client).long
getEstimatedSize()
java.util.List<MessageHistory>
getMessageHistory()
Gets this message's history.MessageId
getMessageId()
Gets the message id associated with the message.MessageMetadata
getMetadata()
Gets the message metadata from this message.java.lang.Object
getProperty(java.lang.String key)
Gets an arbitrary property for the message.boolean
getProperty(java.lang.String key, boolean defaultValue)
Gets a boolean property with a default value if not set.int
getProperty(java.lang.String key, int defaultValue)
Gets an int property with a default value if not set.long
getProperty(java.lang.String key, long defaultValue)
Gets a long property with a default value if not set.java.lang.Object
getProperty(java.lang.String key, java.lang.Object defaultValue)
Gets an object property with a default value if not set.java.lang.String
getProperty(java.lang.String key, java.lang.String defaultValue)
Gets a string property with a default value if not set.WorkflowQueue
getWorkflowQueue()
Gets the workflow queue.WorkflowQueue
getWorkflowQueue(boolean createIfNull)
Optionally creates a new empty queue if null.int
hashCode()
boolean
hasProperty(java.lang.String key)
Used to determine if a message has a property namedkey
set or not.boolean
isRedelivered()
Returns true if the message (or its originating message) is re-delivered Redelivery is generally due to a failure and subsequent recovery in a fault tolerant system.void
removeProperty(java.lang.String key)
Removes a property from the message.WorkflowQueue
removeWorkflowQueue()
Remove the workflow queue for this message.void
setClientId(java.util.UUID clientId)
Sets the client to which this message belongs.void
setMessageId(MessageId msgId)
Sets the message id associated with the message.void
setProperty(java.lang.String key, java.lang.Object value)
Sets an arbitrary property for the message.void
setRedelivered(boolean redelivered)
Sets the re-delivered flag.void
setWorkflowQueue(WorkflowQueue workflowQueue)
Sets the workflow queue.void
setWorkflowQueue(java.lang.String... workflows)
Sets the workflow queue.java.lang.String
toMessageString()
Gets a string-based representation of the message containing string data only.java.lang.String
toString()
protected java.lang.StringBuilder
toString(java.lang.StringBuilder buffer)
Append the string form of this request tobuffer
.protected static void
toString(java.lang.StringBuilder buffer, java.lang.String label, boolean value, boolean defaultValue)
Helper method for constructing toString for PlatformMessages.protected static void
toString(java.lang.StringBuilder buffer, java.lang.String label, int value)
Helper method for constructing toString for PlatformMessages.protected static void
toString(java.lang.StringBuilder buffer, java.lang.String label, int value, int defaultValue)
Helper method for constructing toString for PlatformMessages.protected static void
toString(java.lang.StringBuilder buffer, java.lang.String label, long value)
Helper method for constructing toString for PlatformMessages.protected static void
toString(java.lang.StringBuilder buffer, java.lang.String label, long value, long defaultValue)
Helper method for constructing toString for PlatformMessages.protected static <V> void
toString(java.lang.StringBuilder buffer, java.lang.String label, V value)
Helper method for constructing toString for PlatformMessages.protected static <V> void
toString(java.lang.StringBuilder buffer, java.lang.String label, V[] value)
Helper method for constructing toString for PlatformMessages.protected static <V> void
toString(java.lang.StringBuilder buffer, java.lang.String label, V value, V defaultValue)
Helper method for constructing toString for PlatformMessages.
-
-
-
Constructor Detail
-
AbstractPlatformMessage
public AbstractPlatformMessage()
Creates a message with no client ID
-
AbstractPlatformMessage
public AbstractPlatformMessage(java.util.UUID cid)
Creates a message based on a client ID.- Parameters:
cid
- the client ID
-
AbstractPlatformMessage
public AbstractPlatformMessage(java.util.UUID cid, java.lang.String... workflows)
Creates a message based on a client ID.- Parameters:
cid
- the client IDworkflows
- the array of workflows
-
AbstractPlatformMessage
public AbstractPlatformMessage(java.util.UUID cid, WorkflowQueue workflows)
Creates a message based on a client ID and a workflow queue.- Parameters:
cid
- the client IDworkflows
- the workflow queue
-
-
Method Detail
-
removeProperty
public void removeProperty(java.lang.String key)
Removes a property from the message.- Specified by:
removeProperty
in interfacePlatformMessage
-
getProperty
public java.lang.Object getProperty(java.lang.String key)
Gets an arbitrary property for the message. Some transformations of messages may result in the value being converted to a String.- Specified by:
getProperty
in interfacePlatformMessage
- Parameters:
key
- the key- Returns:
- property value
-
getProperty
public java.lang.Object getProperty(java.lang.String key, java.lang.Object defaultValue)
Gets an object property with a default value if not set.- Parameters:
key
-defaultValue
-- Returns:
- the property value or
defaultValue
if not set.
-
getProperty
public java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
Gets a string property with a default value if not set.- Parameters:
key
-defaultValue
-- Returns:
- the property value or
defaultValue
if not set.
-
getProperty
public int getProperty(java.lang.String key, int defaultValue)
Gets an int property with a default value if not set.- Parameters:
key
-defaultValue
-- Returns:
- the property value or
defaultValue
if not set.
-
getProperty
public long getProperty(java.lang.String key, long defaultValue)
Gets a long property with a default value if not set.- Parameters:
key
-defaultValue
-- Returns:
- the property value or
defaultValue
if not set.
-
getProperty
public boolean getProperty(java.lang.String key, boolean defaultValue)
Gets a boolean property with a default value if not set.- Parameters:
key
-defaultValue
-- Returns:
- the property value or
defaultValue
if not set.
-
setProperty
public void setProperty(java.lang.String key, java.lang.Object value)
Sets an arbitrary property for the message. Some transformations of messages may result in the value being converted to a String.- Specified by:
setProperty
in interfacePlatformMessage
- Parameters:
key
- the keyvalue
- the value
-
hasProperty
public boolean hasProperty(java.lang.String key)
Used to determine if a message has a property namedkey
set or not.- Parameters:
key
-- Returns:
- true if the message has the property
key
-
getClientId
public java.util.UUID getClientId()
Gets the client to which this message belongs (may have originated with the client or be a response to the client).- Specified by:
getClientId
in interfacePlatformMessage
- Returns:
- the client ID
-
setClientId
public void setClientId(java.util.UUID clientId)
Sets the client to which this message belongs.- Specified by:
setClientId
in interfacePlatformMessage
- Parameters:
clientId
- the client ID
-
getMessageId
public MessageId getMessageId()
Gets the message id associated with the message. message ids are used for internal ordering guarantees and may change as the message propagates through the system.- Specified by:
getMessageId
in interfacePlatformMessage
- Returns:
- the message ID
-
setMessageId
public void setMessageId(MessageId msgId)
Sets the message id associated with the message.- Specified by:
setMessageId
in interfacePlatformMessage
- Parameters:
msgId
- the message ID
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toMessageString
public java.lang.String toMessageString()
Gets a string-based representation of the message containing string data only.- Specified by:
toMessageString
in interfacePlatformMessage
- Returns:
- the message string
-
toString
protected java.lang.StringBuilder toString(java.lang.StringBuilder buffer)
Append the string form of this request tobuffer
.
-
getMetadata
public MessageMetadata getMetadata()
Gets the message metadata from this message.- Specified by:
getMetadata
in interfacePlatformMessage
- Returns:
- the message metadata
-
getMessageHistory
public java.util.List<MessageHistory> getMessageHistory()
Gets this message's history.- Specified by:
getMessageHistory
in interfacePlatformMessage
- Returns:
- the message history
-
addMessageHistory
public void addMessageHistory(MessageHistory msg)
Adds a piece of message history.- Specified by:
addMessageHistory
in interfacePlatformMessage
- Parameters:
msg
- the message to add
-
addMessageHistory
public void addMessageHistory(java.util.List<MessageHistory> historyList)
Adds a list of history.- Specified by:
addMessageHistory
in interfacePlatformMessage
- Parameters:
historyList
-
-
getWorkflowQueue
public WorkflowQueue getWorkflowQueue()
Gets the workflow queue. Modifying the returned value will change the workflow destinations for the message.- Specified by:
getWorkflowQueue
in interfacePlatformMessage
- Returns:
- the workflow queue, may be null.
-
getWorkflowQueue
public WorkflowQueue getWorkflowQueue(boolean createIfNull)
Optionally creates a new empty queue if null. Modifying the returned value will change the workflow destinations for the message.- Specified by:
getWorkflowQueue
in interfacePlatformMessage
- Parameters:
createIfNull
- if true and the queue is not set, creates a new empty queue- Returns:
- the workflow queue
-
removeWorkflowQueue
public WorkflowQueue removeWorkflowQueue()
Remove the workflow queue for this message.- Returns:
- the WorkflowQueue that was previously set on this message.
-
setWorkflowQueue
public void setWorkflowQueue(WorkflowQueue workflowQueue)
Sets the workflow queue.wfQueue
will be cloned.- Specified by:
setWorkflowQueue
in interfacePlatformMessage
- Parameters:
workflowQueue
- the workflow queue
-
setWorkflowQueue
public void setWorkflowQueue(java.lang.String... workflows)
Sets the workflow queue.wfQueue
will be cloned.- Specified by:
setWorkflowQueue
in interfacePlatformMessage
- Parameters:
workflows
- the list of workflows
-
isRedelivered
public boolean isRedelivered()
Returns true if the message (or its originating message) is re-delivered Redelivery is generally due to a failure and subsequent recovery in a fault tolerant system.- Specified by:
isRedelivered
in interfacePlatformMessage
- Returns:
- true if the message is re-delivered
-
setRedelivered
public void setRedelivered(boolean redelivered)
Sets the re-delivered flag.- Specified by:
setRedelivered
in interfacePlatformMessage
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
clone
public AbstractPlatformMessage clone()
Clones the object and resets message ID to -1. Clones a message. The message ID is not cloned.- Specified by:
clone
in interfacePlatformMessage
- Overrides:
clone
in classjava.lang.Object
- Returns:
- the cloned index message
-
toString
protected static final void toString(java.lang.StringBuilder buffer, java.lang.String label, boolean value, boolean defaultValue)
Helper method for constructing toString for PlatformMessages.
-
toString
protected static final void toString(java.lang.StringBuilder buffer, java.lang.String label, int value)
Helper method for constructing toString for PlatformMessages.
-
toString
protected static final void toString(java.lang.StringBuilder buffer, java.lang.String label, int value, int defaultValue)
Helper method for constructing toString for PlatformMessages.
-
toString
protected static final void toString(java.lang.StringBuilder buffer, java.lang.String label, long value)
Helper method for constructing toString for PlatformMessages.
-
toString
protected static final void toString(java.lang.StringBuilder buffer, java.lang.String label, long value, long defaultValue)
Helper method for constructing toString for PlatformMessages.
-
toString
protected static final <V> void toString(java.lang.StringBuilder buffer, java.lang.String label, V value)
Helper method for constructing toString for PlatformMessages.
-
toString
protected static final <V> void toString(java.lang.StringBuilder buffer, java.lang.String label, V value, V defaultValue)
Helper method for constructing toString for PlatformMessages.
-
toString
protected static final <V> void toString(java.lang.StringBuilder buffer, java.lang.String label, V[] value)
Helper method for constructing toString for PlatformMessages.
-
getEstimatedSize
public long getEstimatedSize()
- Specified by:
getEstimatedSize
in interfacePlatformMessage
-
-