Package dk.netarkivet.common.distribute
Class NetarkivetMessage
- java.lang.Object
-
- dk.netarkivet.common.distribute.NetarkivetMessage
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ArchiveMessage
,BatchTerminationMessage
,HarvesterMessage
,MonitorMessage
public abstract class NetarkivetMessage extends Object implements Serializable
Common base class for all messages exchanged in the NetarchiveSuite.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
NetarkivetMessage(ChannelID to, ChannelID replyTo)
Creates a new NetarkivetMessage.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getErrMsg()
Retrieve error message.String
getID()
Retrieve message id.String
getReplyOfId()
Retrieve replyOfId.ChannelID
getReplyTo()
Retrieve specified reply channel.ChannelID
getTo()
Retrieve initial destination.boolean
hasBeenSent()
Check, if a given message has been sent yet.boolean
isOk()
Did an error occur when processing the message.void
setNotOk(String err)
Set or append error message.void
setNotOk(Throwable e)
Set error message based on an exception.String
toString()
Returns a string containing:: To ReplyTo [:error message].
-
-
-
Field Detail
-
replyOfId
protected String replyOfId
-
-
Constructor Detail
-
NetarkivetMessage
protected NetarkivetMessage(ChannelID to, ChannelID replyTo)
Creates a new NetarkivetMessage.- Parameters:
to
- the initial receiver of the messagereplyTo
- the initial sender of the message- Throws:
ArgumentNotValid
- if to==replyTo, the replyTo parameter is a topic instead of a queue, or there is a null parameter.
-
-
Method Detail
-
isOk
public boolean isOk()
Did an error occur when processing the message.- Returns:
- true if no error occurred, otherwise false
-
setNotOk
public void setNotOk(String err)
Set or append error message. Sets isOk field to false.- Parameters:
err
- error message
-
setNotOk
public void setNotOk(Throwable e)
Set error message based on an exception.- Parameters:
e
- An exception thrown during processing.
-
getErrMsg
public String getErrMsg() throws PermissionDenied
Retrieve error message.- Returns:
- error message
- Throws:
PermissionDenied
- if the message is not an error message
-
getID
public String getID()
Retrieve message id. Note that message ID is not set until message is sent, and this method must not be called before then.- Returns:
- message id
- Throws:
PermissionDenied
- If the message has not yet been sent.
-
getReplyOfId
public String getReplyOfId()
Retrieve replyOfId. This is set by subclasses of NetarkivetMessage, to indicate that this is a reply of some other message. If the subclass doesn't set replyOfId, this method behaves like getId.- Returns:
- replyOfId
-
getTo
public ChannelID getTo()
Retrieve initial destination.- Returns:
- initial destination
-
getReplyTo
public ChannelID getReplyTo()
Retrieve specified reply channel.- Returns:
- initial origin
-
toString
public String toString()
Returns a string containing:: To ReplyTo [:error message].
-
hasBeenSent
public boolean hasBeenSent()
Check, if a given message has been sent yet. If the message has a null id, it hasn't been sent yet.- Returns:
- true, if message has been sent yet, false otherwise.
-
-