| Package | mx.messaging |
| Class | public class MessageAgent |
| Inheritance | MessageAgent EventDispatcher Object |
| Implements | IMXMLObject |
| Subclasses | Consumer, Producer |
Note: For advanced use only. Use this class for creating custom message agents like the existing Producer and Consumer classes.
MXML Syntax
Hide MXML Syntax
All message agent classes, including the Producer and Consumer classes, extend MessageAgent and inherit the following tag attributes:
<mx:tagname
Properties channelSet="No default." clientId="No default." connected="false" destination="No default." requestTimeout="-1" subtopic="No default." Events acknowledge="No default." channelConnect="No default." channelDisconnect="No default." channelFault="No default." fault="No default." propertyChange="No default." />
| Property | Defined by | ||
|---|---|---|---|
| channelSet : ChannelSet
Provides access to the ChannelSet used by the MessageAgent.
| MessageAgent | ||
| clientId : String
[read-only]
Provides access to the client id for the MessageAgent.
| MessageAgent | ||
| connected : Boolean
[read-only]
Indicates whether this MessageAgent is currently connected to its
destination via its ChannelSet.
| MessageAgent | ||
![]() | constructor : Object
A reference to the class object or constructor function for a given object instance.
| Object | |
| destination : String
Provides access to the destination for the MessageAgent.
| MessageAgent | ||
![]() | prototype : Object
[static]
A reference to the prototype object of a class or function object.
| Object | |
| requestTimeout : int
Provides access to the request timeout in seconds for sent messages.
| MessageAgent | ||
| subtopic : String
Provides access to the subtopic for the remote destination that the MessageAgent uses.
| MessageAgent | ||
| Method | Defined by | ||
|---|---|---|---|
|
Constructor.
| MessageAgent | ||
|
Invoked by a MessageResponder upon receiving a result for a sent
message.
| MessageAgent | ||
![]() |
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener
receives notification of an event.
| EventDispatcher | |
|
Handles a CONNECT ChannelEvent.
| MessageAgent | ||
|
Handles a DISCONNECT ChannelEvent.
| MessageAgent | ||
|
Handles a ChannelFaultEvent.
| MessageAgent | ||
|
Disconnects the MessageAgent's network connection.
| MessageAgent | ||
![]() |
Dispatches an event into the event flow.
| EventDispatcher | |
|
Invoked by a MessageResponder upon receiving a fault for a sent message.
| MessageAgent | ||
![]() |
Checks whether the EventDispatcher object has any listeners registered for a specific type
of event.
| EventDispatcher | |
![]() |
Indicates whether an object has a specified property defined.
| Object | |
|
Called after the implementing object has been created
and all properties specified on the tag have been assigned.
| MessageAgent | ||
![]() |
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter.
| Object | |
|
Logs the MessageAgent out from its remote destination.
| MessageAgent | ||
![]() |
Indicates whether the specified property exists and is enumerable.
| Object | |
![]() |
Removes a listener from the EventDispatcher object.
| EventDispatcher | |
|
Sets the credentials that the MessageAgent uses to authenticate to
destinations.
| MessageAgent | ||
![]() |
Sets the availability of a dynamic property for loop operations.
| Object | |
|
Sets the remote credentials that will be passed through to the remote destination
for authenticating to secondary systems.
| MessageAgent | ||
![]() |
Returns the string representation of the specified object.
| Object | |
![]() |
Returns the primitive value of the specified object.
| Object | |
![]() |
Checks whether an event listener is registered with this EventDispatcher object or any of
its ancestors for the specified event type.
| EventDispatcher | |
| Method | Defined by | ||
|---|---|---|---|
|
Used to automatically initialize the
channelSet property for the
MessageAgent before it connects for the first time. | MessageAgent | ||
|
Sends a Message from the MessageAgent to its destination using the
agent's ChannelSet.
| MessageAgent | ||
| Event | Summary | Defined by | ||
|---|---|---|---|---|
| Dispatched when an acknowledge message is received for a sent message. | MessageAgent | |||
| Dispatched when the underlying Channel the MessageAgent is using connects. | MessageAgent | |||
| Dispatched when the underlying Channel the MessageAgent is using disconnects. | MessageAgent | |||
| Dispatched when the underlying Channel the MessageAgent is using faults. | MessageAgent | |||
| Dispatched when a message fault occurs. | MessageAgent | |||
Dispatched when the connected property of the MessageAgent changes. | MessageAgent | |||
| channelSet | property |
channelSet:ChannelSet [read-write]Provides access to the ChannelSet used by the MessageAgent. The ChannelSet can be manually constructed and assigned, or it will be dynamically initialized to use the configured Channels for the destination for this MessageAgent.
Implementation public function get channelSet():ChannelSet
public function set channelSet(value:ChannelSet):void
| clientId | property |
clientId:String [read-only]Provides access to the client id for the MessageAgent. Agents are assigned their client id by the remote destination.
Implementation public function get clientId():String
| connected | property |
connected:Boolean [read-only]
Indicates whether this MessageAgent is currently connected to its
destination via its ChannelSet. The propertyChange event is dispatched when
this property changes.
This property can be used as the source for data binding.
Implementation public function get connected():Boolean
| destination | property |
destination:String [read-write]Provides access to the destination for the MessageAgent. Changing the destination will disconnect the MessageAgent if it is currently connected.
This property can be used as the source for data binding.
Implementation public function get destination():String
public function set destination(value:String):void
InvalidDestinationError — If the destination is null or
zero-length.
|
| requestTimeout | property |
requestTimeout:int [read-write]Provides access to the request timeout in seconds for sent messages. If an acknowledgement, response or fault is not received from the remote destination before the timeout is reached the message is faulted. A value less than or equal to zero prevents request timeout.
Implementation public function get requestTimeout():int
public function set requestTimeout(value:int):void
| subtopic | property |
subtopic:String [read-write]Provides access to the subtopic for the remote destination that the MessageAgent uses.
This property can be used as the source for data binding.
Implementation public function get subtopic():String
public function set subtopic(value:String):void
| MessageAgent | () | constructor |
public function MessageAgent()Constructor.
| acknowledge | () | method |
public function acknowledge(ackMsg:AcknowledgeMessage, msg:IMessage):void
Invoked by a MessageResponder upon receiving a result for a sent
message. Subclasses may override this method if they need to perform
custom acknowledgement processing, but must invoke
super.acknowledge() as well. This method dispatches a
MessageAckEvent.
ackMsg:AcknowledgeMessage — The AcknowledgMessage returned.
|
|
msg:IMessage — The original sent message.
|
| channelConnectHandler | () | method |
public function channelConnectHandler(event:ChannelEvent):void
Handles a CONNECT ChannelEvent. Subclasses that need to perform custom
processing should override this method, and invoke
super.channelConnectHandler().
event:ChannelEvent — The ChannelEvent.
|
| channelDisconnectHandler | () | method |
public function channelDisconnectHandler(event:ChannelEvent):void
Handles a DISCONNECT ChannelEvent. Subclasses that need to perform
custom processing should override this method, and invoke
super.channelDisconnectHandler().
event:ChannelEvent — The ChannelEvent.
|
| channelFaultHandler | () | method |
public function channelFaultHandler(event:ChannelFaultEvent):void
Handles a ChannelFaultEvent. Subclasses that need to perform custom
processing should override this method, and invoke
super.channelFaultHandler().
event:ChannelFaultEvent — ChannelFaultEvent
|
| disconnect | () | method |
public function disconnect():voidDisconnects the MessageAgent's network connection. This method does not wait for outstanding network operations to complete.
| fault | () | method |
public function fault(errMsg:ErrorMessage, msg:IMessage):void
Invoked by a MessageResponder upon receiving a fault for a sent message.
Subclasses may override this method if they need to perform custom fault
processing, but must invoke super.fault() as well. This
method dispatchs a MessageFaultEvent.
errMsg:ErrorMessage — The ErrorMessage.
|
|
msg:IMessage — The original sent message that caused this fault.
|
| initChannelSet | () | method |
protected function initChannelSet(message:IMessage):void
Used to automatically initialize the channelSet property for the
MessageAgent before it connects for the first time.
Subtypes may override to perform custom initialization.
message:IMessage — The message that needs to be sent.
|
| initialized | () | method |
public function initialized(document:Object, id:String):voidCalled after the implementing object has been created and all properties specified on the tag have been assigned.
Parametersdocument:Object — MXML document that created this object.
|
|
id:String — id used by the document to refer to this object.
If the object is a deep property on the document, id is null.
|
| internalSend | () | method |
protected final function internalSend(message:IMessage):voidSends a Message from the MessageAgent to its destination using the agent's ChannelSet. MessageAgent subclasses must use this method to send their messages.
Parametersmessage:IMessage — The message to send.
|
InvalidDestinationError — If no destination is set.
|
| logout | () | method |
public function logout():void
Logs the MessageAgent out from its remote destination.
Logging out of a destination applies to everything connected using the same ChannelSet
as specified in the server configuration. For example, if several DataService components
are connected over an RTMP channel and logout() is invoked on one of them,
all other client components that are connected using the same ChannelSet are also logged out.
| setCredentials | () | method |
public function setCredentials(username:String, password:String):voidSets the credentials that the MessageAgent uses to authenticate to destinations. The credentials are applied to all services connected over the same ChannelSet.
Parametersusername:String — The username.
|
|
password:String — The password.
|
| setRemoteCredentials | () | method |
public function setRemoteCredentials(username:String, password:String):voidSets the remote credentials that will be passed through to the remote destination for authenticating to secondary systems.
Parametersusername:String — The username.
|
|
password:String — The password.
|
| acknowledge | event |
mx.messaging.events.MessageAckEvent
mx.messaging.events.MessageAckEvent.ACKNOWLEDGE
Dispatched when an acknowledge message is received for a sent message.
The ACKNOWLEDGE event type; dispatched upon receipt of an acknowledgement.
The value of this constant is "acknowledge".
The properties of the event object have the following values:
| Property | Value |
|---|---|
acknowledgeMessage | Utility property to get the message property from MessageEvent as an AcknowledgeMessage. |
bubbles | false |
cancelable | false |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget. |
correlate | The original Message correlated with this acknowledgement. |
message | The Message associated with this event. |
target | The Object that dispatched the event;
it is not always the Object listening for the event.
Use the currentTarget property to always access the
Object listening for the event. |
| channelConnect | event |
mx.messaging.events.ChannelEvent
mx.messaging.events.ChannelEvent.CONNECT
Dispatched when the underlying Channel the MessageAgent is using connects.
The CONNECT event type; indicates that the Channel connected to its endpoint.
The value of this constant is "channelConnect".
The properties of the event object have the following values:
| Property | Value |
|---|---|
bubbles | false |
cancelable | false |
channel | The channel that generated this event. |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget. |
target | The Object that dispatched the event;
it is not always the Object listening for the event.
Use the currentTarget property to always access the
Object listening for the event. |
reconnecting | Indicates whether the channel that generated this event is reconnecting. |
rejected | Indicates whether the channel that generated this event was rejected. This would be true in the event that the channel has been disconnected due to inactivity and should not attempt to failover or connect on an alternate channel. |
| channelDisconnect | event |
mx.messaging.events.ChannelEvent
mx.messaging.events.ChannelEvent.DISCONNECT
Dispatched when the underlying Channel the MessageAgent is using disconnects.
The DISCONNECT event type; indicates that the Channel disconnected from its endpoint.
The value of this constant is "channelDisconnect".
The properties of the event object have the following values:
| Property | Value |
|---|---|
bubbles | false |
cancelable | false |
channel | The channel that generated this event. |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget. |
target | The Object that dispatched the event;
it is not always the Object listening for the event.
Use the currentTarget property to always access the
Object listening for the event. |
reconnecting | Indicates whether the channel that generated this event is reconnecting. |
rejected | Indicates whether the channel that generated this event was rejected. This would be true in the event that the channel has been disconnected due to inactivity and should not attempt to failover or connect on an alternate channel. |
| channelFault | event |
mx.messaging.events.ChannelFaultEvent
mx.messaging.events.ChannelFaultEvent.FAULT
Dispatched when the underlying Channel the MessageAgent is using faults.
The FAULT event type; indicates that the Channel faulted.
The value of this constant is "channelFault".
The properties of the event object have the following values:
| Property | Value |
|---|---|
bubbles | false |
cancelable | false |
channel | The Channel that generated this event. |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget. |
faultCode | Provides destination-specific details of the failure. |
faultDetail | Provides access to the destination-specific reason for the failure. |
faultString | Provides access to the underlying reason for the failure if the channel did not raise the failure itself. |
reconnecting | Indicates whether the channel that generated this event is reconnecting. |
rootCause | Provides access to the underlying reason for the failure if the channel did not raise the failure itself. |
target | The Object that dispatched the event;
it is not always the Object listening for the event.
Use the currentTarget property to always access the
Object listening for the event. |
| fault | event |
mx.messaging.events.MessageFaultEvent
mx.messaging.events.MessageFaultEvent.FAULT
Dispatched when a message fault occurs.
The FAULT event type; dispatched for a message fault.
The value of this constant is "fault".
The properties of the event object have the following values:
| Property | Value |
|---|---|
bubbles | false |
cancelable | false |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget. |
faultCode | Provides destination-specific details of the failure. |
faultDetail | Provides access to the destination-specific reason for the failure. |
faultString | Provides access to the underlying reason for the failure if the channel did not raise the failure itself. |
message | The ErrorMessage for this event. |
rootCause | Provides access to the underlying reason for the failure, if one exists. |
target | The Object that dispatched the event;
it is not always the Object listening for the event.
Use the currentTarget property to always access the
Object listening for the event. |
| propertyChange | event |
mx.events.PropertyChangeEvent
mx.events.PropertyChangeEvent.PROPERTY_CHANGE
Dispatched when the connected property of the MessageAgent changes.
Also dispatched when the subscribed of a Consumer changes.
The PropertyChangeEvent.PROPERTY_CHANGE constant defines the value of the
type property of the event object for a PropertyChange event.
The properties of the event object have the following values:
| Property | Value |
|---|---|
bubbles | Determined by the constructor; defaults to false. |
cancelable | Determined by the constructor; defaults to false. |
kind | The kind of change; PropertyChangeEventKind.UPDATE or PropertyChangeEventKind.DELETE. |
oldValue | The original property value. |
newValue | The new property value, if any. |
property | The property that changed |
source | The object that contains the property that changed. |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget. |
target | The Object that dispatched the event;
it is not always the Object listening for the event.
Use the currentTarget property to always access the
Object listening for the event. |
See also
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flex/2/langref/mx/messaging/MessageAgent.html