public interface Message
MessageBus
.
Message instances are normally created with the help of MessageBuilder
, but individual Message
implementations may also be created directly if desired.
Modifier and Type | Method and Description |
---|---|
Message |
addAllParts(Map<String,Object> parts)
Copies in a set of message parts from the provided map.
|
Message |
addAllProvidedParts(Map<String,ResourceProvider<?>> provided)
Copies in a set of provided message parts from the provided maps
|
void |
addResources(Map<String,?> resources)
Adds the Map of resources to the message.
|
Message |
command(Enum<?> type)
Set the command type for this message.
|
Message |
command(String type)
Sets the command type for this message.
|
void |
commit()
Commits the message in its current structure.
|
Message |
copy(Enum<?> part,
Message m)
Copies a part of this message to another message.
|
Message |
copy(String part,
Message m)
Copies a part of this message to another message.
|
Message |
copyResource(String key,
Message m)
Copies a transient resource to this message from the specified message.
|
Message |
errorsCall(ErrorCallback callback)
Sets the error callback for this message.
|
<T> T |
get(Class<T> type,
Enum<?> part)
Gets the specified message part in the specified type.
|
<T> T |
get(Class<T> type,
String part)
Gets the specified message part in the specified type.
|
String |
getCommandType()
Returns the command type for this message as a String.
|
ErrorCallback<Message> |
getErrorCallback()
Gets the error callback for this message.
|
Map<String,Object> |
getParts()
Returns a Map of all the specified parts.
|
Map<String,ResourceProvider<?>> |
getProvidedParts()
Returns a Map of all provided parts.
|
<T> T |
getResource(Class<T> type,
String key)
Obtains a transient resource based on the specified key.
|
String |
getSubject()
Returns the message's subject.
|
<T> T |
getValue(Class<T> type) |
boolean |
hasPart(Enum<?> part)
Checks if message contains the specified part.
|
boolean |
hasPart(String part)
Checks if message contains the specified part.
|
boolean |
hasResource(String key)
Returns true if the specified transient resource is present.
|
boolean |
isCommited()
Returns true if the message has been committed.
|
boolean |
isFlagSet(RoutingFlag flag)
Checks if the provided flag is set for this message.
|
void |
remove(Enum<?> part)
Removes specified part from the message.
|
void |
remove(String part)
Removes specified part from the message.
|
void |
sendNowWith(MessageBus viaThis)
Transmits this message to the specified
MessageBus instance. |
void |
sendNowWith(RequestDispatcher viaThis)
Transmits this message using the specified
RequestDispatcher . |
Message |
set(Enum<?> part,
Object value)
Sets a Message part to the specified value.
|
Message |
set(String part,
Object value)
Sets a Message part to the specified value.
|
Message |
setFlag(RoutingFlag flag)
Sets the provided flag for this message.
|
Message |
setParts(Map<String,Object> parts)
Sets the message to contain the specified parts.
|
Message |
setProvidedPart(Enum<?> part,
ResourceProvider<?> provider)
Adds or replaces a message part whose value is recomputed every time the message is sent.
|
Message |
setProvidedPart(String part,
ResourceProvider<?> provider)
Adds or replaces a message part whose value is recomputed every time the message is sent.
|
Message |
setResource(String key,
Object res)
Sets a transient resource.
|
Message |
toSubject(String subject)
Sets the subject of this message, which is the intended recipient, and returns the message.
|
void |
unsetFlag(RoutingFlag flag)
Unsets the provided flag for this message.
|
Message toSubject(String subject)
subject
- the intended recipient of the message.String getSubject()
Message command(String type)
type
- String representation of a command type.Message command(Enum<?> type)
type
- Enum representation of a command type.String getCommandType()
Message set(String part, Object value)
part
- The String name of the message part.value
- The value to set the part to.Message set(Enum<?> part, Object value)
part
- The Enum representation of the message part.value
- the value to set the part to.Message setProvidedPart(String part, ResourceProvider<?> provider)
part
- The name of the message part.provider
- a callback that provides the value of the message part on demand. Will be called every time this message
is sent.Message setProvidedPart(Enum<?> part, ResourceProvider<?> provider)
part
- The Enum representation of the message part.provider
- a callback that provides the value of the message part on demand. Will be called every time this message
is sent.boolean hasPart(String part)
part
- String part to check for.part
.boolean hasPart(Enum<?> part)
part
- Enum part to check for.part
.void remove(String part)
part
- the part to remove.void remove(Enum<?> part)
part
- the part to remove.Message copy(String part, Message m)
part
- the part of this message to copy.m
- the message to copy the part to. Must not be null.Message copy(Enum<?> part, Message m)
part
- the part of this message to copy.m
- the message to copy the part to. Must not be null.Message setParts(Map<String,Object> parts)
Implementations may or may not create a defensive copy of the given map. Check their documentation to be sure.
parts
- Parts to be used in the message. Must not be null.Message addAllParts(Map<String,Object> parts)
parts
- Parts to be added to the message. Must not be null.Message addAllProvidedParts(Map<String,ResourceProvider<?>> provided)
provided
- provided parts to be added to the messageMap<String,Object> getParts()
Map<String,ResourceProvider<?>> getProvidedParts()
void addResources(Map<String,?> resources)
resources
- Map of resourceMessage setResource(String key, Object res)
key
- Name of resource.res
- Instance of resource.<T> T getResource(Class<T> type, String key)
type
- type of resource.key
- the name of the resourceboolean hasResource(String key)
key
- Name of resource.Message copyResource(String key, Message m)
key
- Name of resource.m
- Message to copy from.Message errorsCall(ErrorCallback callback)
callback
- error callback.ErrorCallback<Message> getErrorCallback()
<T> T getValue(Class<T> type)
<T> T get(Class<T> type, String part)
T
- Type to be returned.type
- Type to be returned.part
- Message part.<T> T get(Class<T> type, Enum<?> part)
T
- Type to be returned.type
- Type to be returned.part
- Message part.Message setFlag(RoutingFlag flag)
flag
- message routing flagvoid unsetFlag(RoutingFlag flag)
flag
- message routing flagboolean isFlagSet(RoutingFlag flag)
flag
- message routing flag.void commit()
boolean isCommited()
void sendNowWith(MessageBus viaThis)
MessageBus
instance.viaThis
- MessageBus instance to send message tovoid sendNowWith(RequestDispatcher viaThis)
RequestDispatcher
.viaThis
- RequestDispatcher instance to send message toCopyright © 2013-2015 JBoss, a division of Red Hat. All Rights Reserved.