OSMQ
v2.0.1

osmq.messages
Class MessageHeader

java.lang.Object
  extended byosmq.util.ImmutableImpl
      extended byosmq.messages.MessageHeader
All Implemented Interfaces:
java.lang.Cloneable, Immutable, KeyedData, MessageAttributes, java.io.Serializable

public class MessageHeader
extends ImmutableImpl
implements MessageAttributes, java.lang.Cloneable, java.io.Serializable

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface osmq.messages.MessageAttributes
CONTENT_FORMAT, CORRELATION_ID, DATA_KEY, ORIGINATOR, RECIPIENT, SEND_TIMESTAMP, SENDER_SEQ, TOPIC, TOTAL_ATTRIBUTES, TRANS_ADD, TRANS_DELETE, TRANS_UPDATE, TRANSACTION, TYPE
 
Constructor Summary
MessageHeader()
           
MessageHeader(byte[] value)
           
MessageHeader(DataRecord ds)
           
MessageHeader(java.lang.String s)
           
 
Method Summary
 void clearAll()
           
 java.lang.Object clone()
           
 byte[] getBytes()
           
 long getCorrelationNumber()
          Gets the identifier used to identify a group of transactions as related.
 java.lang.String getCorrelationString()
           
 char getFormat()
          Identifies the body format as either dataset, text or binary.
 java.lang.String getKey()
          Returns the unique identifier for the data contained in the message.
 int getKeyAsInt()
           
 java.lang.String getOriginator()
          Returns the identifier of the message sender (publisher).
 java.lang.String getRecipient()
          Returns the identifier of the message recipient, or null if the message is intended for all subscriber to the message topic.
 long getSequenceNumber()
          Returns the relative sequence number of this message.
 java.lang.String getText()
           
 long getTimeStamp()
          Returns a timestamp indicating when the message was sent.
 java.lang.String getTopic()
          Returns the topic of the message.
 java.lang.String getTransaction()
          Returns the identifier of the event or activity that caused the transaction to be generated.
 char getTransactionAsChar()
          Returns the first character of the event identifer, or a null character if there is no event identifer
 char getType()
          Identifies whether the event type is a NOTIFICATION or REQUEST .
 boolean hasAssignedCorrelationNumber()
          Determines if there is a correlation identifier value.
 boolean hasAssignedKey()
          Determines if there is a key value identifier.
 boolean hasAssignedOriginator()
          Determines whether a position has a value (versus null)
 boolean hasAssignedRecipient()
          Determine if there is a recipient identifier value.
 boolean hasAssignedTopic()
          Determine if there is a topic identifier value.
 void setCorrelationNumber(long n)
           
 void setCorrelationString(java.lang.String s)
           
 void setFormat(char t)
          Sets the attributes that identifies the type of data contained in the message body.
 void setKey(java.lang.String t)
           
 void setKeyAsInt(int n)
           
 void setOriginator(java.lang.String t)
          Sets the identifier of the message sender/originator.
 void setRecipient(java.lang.String s)
          Sets the unique recipient that will receive the message.
 void setSequenceNumber(long n)
          Sets the sequence number for this message.
 void setTimeStamp(long n)
          Sets the time the message was publisherd.
 void setTopic(java.lang.String t)
           
 void setTransaction(java.lang.String t)
           
 void setTransactionAsChar(char c)
           
 void setType(char t)
          Sets the message type.
 
Methods inherited from class osmq.util.ImmutableImpl
isImmutable, setImmutable
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface osmq.util.Immutable
isImmutable, setImmutable
 

Constructor Detail

MessageHeader

public MessageHeader()

MessageHeader

public MessageHeader(DataRecord ds)

MessageHeader

public MessageHeader(java.lang.String s)

MessageHeader

public MessageHeader(byte[] value)
Method Detail

getCorrelationNumber

public long getCorrelationNumber()
Gets the identifier used to identify a group of transactions as related. The relationship is likely a unit-of-work that resulted in tranaction-related topics being generated. This is an optional header attribute.

Specified by:
getCorrelationNumber in interface MessageAttributes
Returns:
An int containing the correlation identifier.

setCorrelationNumber

public void setCorrelationNumber(long n)
Specified by:
setCorrelationNumber in interface MessageAttributes

getCorrelationString

public java.lang.String getCorrelationString()
Specified by:
getCorrelationString in interface MessageAttributes

setCorrelationString

public void setCorrelationString(java.lang.String s)
Specified by:
setCorrelationString in interface MessageAttributes

getTopic

public java.lang.String getTopic()
Returns the topic of the message.

Specified by:
getTopic in interface MessageAttributes
Returns:
A string containing the topic. The topic defines the message contents for a subscriber (number of elements and the data type of each element).

setTopic

public void setTopic(java.lang.String t)
Specified by:
setTopic in interface MessageAttributes

getKey

public java.lang.String getKey()
Returns the unique identifier for the data contained in the message. (This "key" is relative to the the topic.)

Specified by:
getKey in interface MessageAttributes
Returns:
A string containing the unique identifier.

setKey

public void setKey(java.lang.String t)
Specified by:
setKey in interface MessageAttributes

setKeyAsInt

public void setKeyAsInt(int n)
Specified by:
setKeyAsInt in interface MessageAttributes

getKeyAsInt

public int getKeyAsInt()
Specified by:
getKeyAsInt in interface MessageAttributes

getTransaction

public java.lang.String getTransaction()
Returns the identifier of the event or activity that caused the transaction to be generated. This is a value that is based on the topic.

Standard events used for down-stream subscribers that maintain databases are DataSetMessage.EVENT_ADD, DataSetMessage.EVENT_DELETE and DataSetMessage.and EVENT_UPDATE.

Specified by:
getTransaction in interface MessageAttributes
Returns:
A string containing the transaction event.

getTransactionAsChar

public char getTransactionAsChar()
Returns the first character of the event identifer, or a null character if there is no event identifer

Specified by:
getTransactionAsChar in interface MessageAttributes
Returns:
A char containing the transaction event.

setTransaction

public void setTransaction(java.lang.String t)
Specified by:
setTransaction in interface MessageAttributes

setTransactionAsChar

public void setTransactionAsChar(char c)
Specified by:
setTransactionAsChar in interface MessageAttributes

getOriginator

public java.lang.String getOriginator()
Returns the identifier of the message sender (publisher). The sender identifies a unique client process (instance).

Specified by:
getOriginator in interface MessageAttributes
Returns:
A string containing the message sender.

setOriginator

public void setOriginator(java.lang.String t)
Sets the identifier of the message sender/originator. Setting the originator should be performed when a message is published, and this value defaults to the client identifier used to attach to the message server.

NOTE This method should not be called by an application, since the value will be overridden by the message publisher adapter.

Specified by:
setOriginator in interface MessageAttributes

getType

public char getType()
Identifies whether the event type is a NOTIFICATION or REQUEST .

Specified by:
getType in interface MessageAttributes
Returns:
A char containing either the value TYPE_NOTIFICATION or TYPE_REQUEST.
See Also:
MessageAttributes.setType(char)

setType

public void setType(char t)
Sets the message type. The message type is the category of event that caused a message to be generated. Standard types include TYPE_NOTIFICATION and TYPE_REQUEST.

TYPE_NOTIFICATION messages are published by OLTP systems after it commits a transaction. (Batch applications can also publisher TYPE_NOTIFICATION messages.)

TYPE_REQUEST messages are point-to-point routed client requests for service. (Point-to-point messages are sent to a single recipient, and have the recipient identified in the message header, verus publish-subscribe messages that have no recipeint and are published to all subscribers to the message topic.)

Specified by:
setType in interface MessageAttributes
See Also:
setRecipient(String t)

getRecipient

public java.lang.String getRecipient()
Returns the identifier of the message recipient, or null if the message is intended for all subscriber to the message topic.

Specified by:
getRecipient in interface MessageAttributes
Returns:
A string containing the recipient identifier.

setRecipient

public void setRecipient(java.lang.String s)
Sets the unique recipient that will receive the message. If a recipient value is set, only that recipient will receive the message. (Point-to-point messaging). Setting the recipient should be reserved for clients requesting a service (type of TYPE_REQUEST) and for OLTP systems that receive a request that is being rejected. In the latter case, the OLTP system would send a point-to-point rejection message to the originator of the request.

Specified by:
setRecipient in interface MessageAttributes

getFormat

public char getFormat()
Description copied from interface: MessageAttributes
Identifies the body format as either dataset, text or binary. Valid values include

FORMAT_UNKNOWN ('U')

FORMAT_TEXT ('T')

FORMAT_DATASET ('D')

FORMAT_BINARY ('B')

Specified by:
getFormat in interface MessageAttributes

setFormat

public void setFormat(char t)
Description copied from interface: MessageAttributes
Sets the attributes that identifies the type of data contained in the message body.

Valid values include

FORMAT_UNKNOWN ('U')

FORMAT_TEXT ('T')

FORMAT_DATASET ('D')

FORMAT_BINARY ('B')

DataSetMessages default to a format of FORMAT_DATASET.

Specified by:
setFormat in interface MessageAttributes

getTimeStamp

public long getTimeStamp()
Returns a timestamp indicating when the message was sent.

Specified by:
getTimeStamp in interface MessageAttributes
Returns:
A long containing the time in milli-seconds.

setTimeStamp

public void setTimeStamp(long n)
Sets the time the message was publisherd. This function is called by the message publisher after client submits the message for delivery.

NOTE This value should be set by the underlying client middleware, and not the application.

Specified by:
setTimeStamp in interface MessageAttributes
Parameters:
n - the time as a long.

getSequenceNumber

public long getSequenceNumber()
Returns the relative sequence number of this message. When a message is sent by a client, it denotes the relative sending sequence. When a message is received, it denotes the relative sequence of all messages fetched by the recipient, regardless of the sender.

Specified by:
getSequenceNumber in interface MessageAttributes
Returns:
A long identifying the message sequence.

setSequenceNumber

public void setSequenceNumber(long n)
Sets the sequence number for this message.

NOTE This value should be set by the underlying client middleware, and not the application.

Specified by:
setSequenceNumber in interface MessageAttributes

hasAssignedRecipient

public boolean hasAssignedRecipient()
Determine if there is a recipient identifier value.

Specified by:
hasAssignedRecipient in interface MessageAttributes
Returns:
true if there is a non-null recipient identifier.

hasAssignedTopic

public boolean hasAssignedTopic()
Determine if there is a topic identifier value.

Specified by:
hasAssignedTopic in interface MessageAttributes
Returns:
true if there is a non-null topic identifier.

hasAssignedKey

public boolean hasAssignedKey()
Description copied from interface: MessageAttributes
Determines if there is a key value identifier.

Specified by:
hasAssignedKey in interface MessageAttributes
Returns:
true if there is a non-null key identifier.

hasAssignedCorrelationNumber

public boolean hasAssignedCorrelationNumber()
Description copied from interface: MessageAttributes
Determines if there is a correlation identifier value.

Specified by:
hasAssignedCorrelationNumber in interface MessageAttributes
Returns:
true if there is a non-null numeric correlation identifier.

hasAssignedOriginator

public boolean hasAssignedOriginator()
Description copied from interface: MessageAttributes
Determines whether a position has a value (versus null)

Specified by:
hasAssignedOriginator in interface MessageAttributes
Returns:
true of there is a non-null value at position p, else false

getBytes

public byte[] getBytes()

getText

public java.lang.String getText()

clearAll

public void clearAll()

clone

public java.lang.Object clone()
Specified by:
clone in interface MessageAttributes

(c) 2000 - 2003 MQue Systems
All Rights Reserved