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 decoded messages received by endpoints to services based on the service destination specified in each message. The broker also has a means of pushing messages back through endpoints to clients.


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.
 
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.
 void addServiceValidationListener(String id, ServiceValidationListener listener)
          Add a listener for the describeServices callback.
 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.
 int decrementAttributeIdRefCount(String attributeId)
          Decrements the count of destinations actively using an Application or Session level scoped assembler identified by the passed in attributeId.
 ConfigMap describeServices(Endpoint endpoint)
          Describe services and the channels used by the services for the client.
 Object getAttribute(String name)
          Returns the attribute value bound to the MessageBroker under the provided name.
 Iterator getAttributeNames()
          Returns an Iterator containing the current names that attributes have been bound to the MessageBroker under.
 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 id.
 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.
 void incrementAttributeIdRefCount(String attributeId)
          Increments the count of destinations actively using an Application or Session level scoped assembler identified by the passed in attributeId.
 void removeAttribute(String name)
          Removes the attribute with the given name from the MessageBroker.
 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.
 Server removeServer(String id)
          Stops and removes the Server from the set of shared servers managed by the MessageBroker.
 Service removeService(String id)
          Removes the Service from the list of services known by the MessageBroker.
 void removeServiceValidationListener(String id)
          Remove a listener from the describeServices callback.
 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 setAttribute(String name, Object value)
          Binds an attribute value to the MessageBroker under the provided name.
 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
Method Detail

getMessageBroker

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

Parameters:
id - The id of the message broker to retrieve.
Returns:
The MessageBroker for the supplied id.

getAttributeNames

public Iterator getAttributeNames()
Returns an Iterator containing the current names that attributes have been bound to the MessageBroker under. Use MessageBroker.getAttribute(String) to retrieve an attribute value.

Returns:
An iterator containing the current names of the attributes.

getAttribute

public Object getAttribute(String name)
Returns the attribute value bound to the MessageBroker under the provided name.

Parameters:
name - The attribute name.

setAttribute

public void setAttribute(String name,
                         Object value)
Binds an attribute value to the MessageBroker under the provided name.

Parameters:
name - The attribute name.
value - The attribute value.

removeAttribute

public void removeAttribute(String name)
Removes the attribute with the given name from the MessageBroker.

Parameters:
name - The attribute name.

removeServer

public Server removeServer(String id)
Stops and removes the Server from the set of shared servers managed by the MessageBroker.

Parameters:
id - The id of the Server to remove.
Returns:
Server that has been removed or null if it doesn't exist.

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.

addServiceValidationListener

public void addServiceValidationListener(String id,
                                         ServiceValidationListener listener)
Add a listener for the describeServices callback. The describeServices listener is called before any execution of the describeServices method.

Parameters:
id - Identifier of the listener to add
listener - The listener callback

removeServiceValidationListener

public void removeServiceValidationListener(String id)
Remove a listener from the describeServices callback.

Parameters:
id - Identifier of the listener to remove

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.

Returns:
The list of channel ids.

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 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 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.
Returns:
AcknowledgeMessage with result.

getClassLoader

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

Returns:
ClassLoader the system should use to load user definied classes.

incrementAttributeIdRefCount

public void incrementAttributeIdRefCount(String attributeId)
Increments the count of destinations actively using an Application or Session level scoped assembler identified by the passed in attributeId.

Parameters:
attributeId - Attribute id for the session or application-scoped object.

decrementAttributeIdRefCount

public int decrementAttributeIdRefCount(String attributeId)
Decrements the count of destinations actively using an Application or Session level scoped assembler identified by the passed in attributeId.

Parameters:
attributeId - Attribute id for the session or application-scoped object.


Copyright © 2008 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/blazeds/1/javadoc/flex/messaging/MessageBroker.html