flex.messaging
Class MessageBroker

java.lang.Object
  extended by flex.management.ManageableComponent
      extended by flex.messaging.MessageBroker
All Implemented Interfaces:
Manageable, FlexComponent, FlexConfigurable

public final class MessageBroker
extends ManageableComponent

The MessageBroker is the hub of message traffic in the Flex system. It has a number of endpoints which send and receive messages over the network, and it has a number of services that are message destinations. The broker routes messages to endpoints based on the content type of those messages, and routes decoded messages to services based on message type. The broker also has a means of calling back into the endpoints in order to push messages back through them. Example: A RemoteObject message arrives over the RTMP endpoint. The endpoint decodes the message and sends it to the Message Broker, and the broker then passes it on to the RemotingService which will perform the RemoteObject invocation.


Field Summary
static String LOG_CATEGORY
          Log category for MessageBroker.
static String LOG_CATEGORY_STARTUP_SERVICE
          Log category that captures startup information for broker's destinations.
static String TYPE
           
 
Method Summary
 void addDefaultChannel(String id)
          Adds the channel id to the list of default channel ids.
 void addFactory(String id, FlexFactory factory)
          Registers a factory with the MessageBroker.
 void addService(Service service)
          Add a message type -to- service mapping to the broker's collection.
 Service createService(String id, String className)
          Creates a Service instance, sets its id, sets it manageable if the MessageBroker that created it is manageable, and sets its MessageBroker to the MessageBroker that created it.
 ConfigMap describeServices(Endpoint endpoint)
          Describe services and the channels used by the services for the client.
 List getChannelIds()
          Returns the list of channel ids known to the MessageBroker.
 ClassLoader getClassLoader()
          This is the class loader used by the system to load user defined classes.
 List getDefaultChannels()
          Returns the default channel ids of the MessageBroker.
 Map getFactories()
          Returns the map of FlexFactory instances.
 FlexFactory getFactory(String id)
          Returns the FlexFactory with the specified id.
 Log getLog()
          Returns the logger of the MessageBroker.
static MessageBroker getMessageBroker(String id)
          Retrieves a message broker with the supplied messageBrokerId.
 flex.messaging.config.SecurityConstraint getSecurityConstraint(String ref)
          Returns the SecurityConstraint with the indicated reference id.
 Service getService(String id)
          Returns the Service with the specified id.
 Map getServices()
          Returns the Map of Service instances.
 boolean removeDefaultChannel(String id)
          Removes the channel id from the list of default channel ids.
 FlexFactory removeFactory(String id)
          Removes the FlexFactory from the list of factories known by the MessageBroker.
 Service removeService(String id)
          Removes the Service from the list of services known by the MessageBroker.
 flex.messaging.messages.AcknowledgeMessage routeMessageToService(Message message, Endpoint endpoint)
          You can call this method in order to send a message from your code into the message routing system.
 void setDefaultChannels(List ids)
          Sets the default channel ids of the MessageBroker.
 
Methods inherited from class flex.management.ManageableComponent
getControl, getId, getParent, initialize, isManaged, isStarted, isValid, setControl, setId, setManaged, setParent, start, stop
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_CATEGORY

public static final String LOG_CATEGORY
Log category for MessageBroker.

See Also:
Constant Field Values

LOG_CATEGORY_STARTUP_SERVICE

public static final String LOG_CATEGORY_STARTUP_SERVICE
Log category that captures startup information for broker's destinations.

See Also:
Constant Field Values

TYPE

public static final String TYPE
See Also:
Constant Field Values
Method Detail

getMessageBroker

public static MessageBroker getMessageBroker(String id)
Retrieves a message broker with the supplied messageBrokerId. This is defined via the servlet init parameter messageBrokerId. If no messageBrokerId is supplied, pass in a null value for the mbid parameter.


getFactory

public FlexFactory getFactory(String id)
Returns the FlexFactory with the specified id.

Parameters:
id - The id of the FlexFactory.
Returns:
The FlexFactory with the specified id or null if no factory with the id exists.

getFactories

public Map getFactories()
Returns the map of FlexFactory instances.

Returns:
The map of FlexFactory instances.

addFactory

public void addFactory(String id,
                       FlexFactory factory)
Registers a factory with the MessageBroker.

Parameters:
id - The id of the factory.
factory - FlexFactory instance.

removeFactory

public FlexFactory removeFactory(String id)
Removes the FlexFactory from the list of factories known by the MessageBroker.

Parameters:
id - The id of the FlexFactory.
Returns:
FlexFactory that has been removed.

getService

public Service getService(String id)
Returns the Service with the specified id.

Parameters:
id - The id of the Service/
Returns:
The Service with the specified id or null if no Service with the id exists.

getServices

public Map getServices()
Returns the Map of Service instances.

Returns:
The Map of Service instances.

describeServices

public ConfigMap describeServices(Endpoint endpoint)
Describe services and the channels used by the services for the client.

Parameters:
endpoint - Endpoint used to filter the destinations of the service.
Returns:
ConfigMap of server properties.

createService

public Service createService(String id,
                             String className)
Creates a Service instance, sets its id, sets it manageable if the MessageBroker that created it is manageable, and sets its MessageBroker to the MessageBroker that created it.

Parameters:
id - The id of the Service.
className - The class name of the Service.
Returns:
The Service instanced created.

addService

public void addService(Service service)
Add a message type -to- service mapping to the broker's collection. When the broker attempts to route a message to a service, it finds the first service capable of handling the message type. Note that Service cannot be null, it cannot have a null id, and it cannot have the same id or type of a Service already registered with the MessageBroker. Service needs to be started if the MessageBroker is already running.

Parameters:
service - The service instance used to handle the messages

removeService

public Service removeService(String id)
Removes the Service from the list of services known by the MessageBroker.

Parameters:
id - The id of the Service.
Returns:
Previous Service associated with the id.

getLog

public Log getLog()
Returns the logger of the MessageBroker.

Returns:
Logger of the MessageBroker.

getChannelIds

public List getChannelIds()
Returns the list of channel ids known to the MessageBroker.


getDefaultChannels

public List getDefaultChannels()
Returns the default channel ids of the MessageBroker. If a service specifies its own list of channels it overrides these defaults.

Returns:
Default channel ids of the MessageBroker.

addDefaultChannel

public void addDefaultChannel(String id)
Adds the channel id to the list of default channel ids.

Parameters:
id - The id of the channel to add to the list of default channel ids.

setDefaultChannels

public void setDefaultChannels(List ids)
Sets the default channel ids of the MessageBroker.

Parameters:
ids - Default channel ids of the MessageBroker.

removeDefaultChannel

public boolean removeDefaultChannel(String id)
Removes the channel id from the list of default channel ids.

Parameters:
id - The id of the channel to remove from the list of default channel ids.
Returns:
true if the list contained the channel id.

getSecurityConstraint

public flex.messaging.config.SecurityConstraint getSecurityConstraint(String ref)
Returns the SecurityConstraint with the indicated reference id.

Parameters:
ref - The reference of the SecurityConstraint
Returns:
The SecurityConstraint with the indicated reference id.

routeMessageToService

public flex.messaging.messages.AcknowledgeMessage routeMessageToService(Message message,
                                                                        Endpoint endpoint)
You can call this method in order to send a message from your code into the message routing system. The message is routed to a service that is defined to handle messages of this type. Once the service is identified, the destination property of the message is used to find a destination configured for that service. The adapter defined for that destination is used to handle the message.

Parameters:
message - The message to be routed to a service
endpoint - This can identify the endpoint that is sending the message but it is currently not used so you may pass in null.

getClassLoader

public ClassLoader getClassLoader()
This is the class loader used by the system to load user defined classes.



Copyright © 2007 Adobe Systems Inc. All Rights Reserved.

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/lcdsjavadoc/flex/messaging/MessageBroker.html