Entourage MQ JavaScript API
Trace: » Rails Listener » Paginator » Downloading Entourage Products » Tree » Entourage MQ JavaScript API

Entourage MQ JavaScript API

This is a complete listing of the public API for Entourage MQ. All functions are defined in the App.mq namespace, but for the sake of convenience, many have been mapped to shortcut functions prefixed with $MQ.

$MQ (App.mq.publish)

The publish (or $MQ) method creates and pushes a message in to the message queue.

$MQ(name_string, data_payload);
$MQ(message);
Parameter Description
name_string A string identifier for the given message.
data_payload An object defining the data payload for a message (Optional).
message An object that defines the entire message. Standard attributes for this object are defined below
Message object properties
  • name: A string that identifies the message
  • scope: A string that defines which listeners and interceptors are able to process the message
  • payload: An object data structure that can contain server-side data, or any data passed on the client side of an application.


$MQL (App.mq.subscribe)

Subscribe to a message using a direct string match or regular expression

$MQL(message_name_or_regexp, function(message){}, args);
Parameter Description
message_name_or_regexp String or RegExp - defines the exact message to listen for, or a regular expression that will match desired messages
function(message) A callback function which handles any matched messages
args An object that defines additional options for the listener. Standard attributes for this object are defined below
Args object properties
  • scope: A string that defines which scope to restrict message traffic to
  • handle: A string to be used to identify this listener later for removal


$().subscribe (jQuery only)

In a jQuery-powered Entourage MQ application, the subscribe method has been added to the jQuery object to allow you to subscribe to a message and execute a function on all returned elements

$("#myselector").subscribe(message_name_or_regexp, function(message,element){}, args);
Parameter Description
message_name_or_regexp String or RegExp - defines the exact message to listen for, or a regular expression that will match desired messages
function(message,element) A callback function which handles any matched messages - this method is passed both the message received and the element matched by the selector
args An object that defines additional options for the listener. Standard attributes for this object are defined below
Args object properties
  • scope: A string that defines a scope to which message traffic will be restricted


$MQI (App.mq.intercept)

Intercept and modify a message before it is processed by message listeners. Return true from the callback function to stop processing the message after execution.

$MQI(message_name_or_regexp, function(message){}, args);
Parameter Description
message_name_or_regexp String or RegExp - defines the exact message to listen for, or a regular expression that will match desired messages
function(message) A callback function which handles any matched messages
args An object that defines additional options for the interceptor. Standard attributes for this object are defined below
Args object properties
  • scope: A string that defines which scope to restrict message traffic to
  • handle: A string to be used to identify this listener later for removal


$MQR (App.mq.register)

Register a remote URL with a request and response message name. To make the URL dynamic, you can use Ruby style string interpolation to substitute data payload parameters into the URL for the call.

$MQR(request, response, url, args);
Parameter Description
request the name of the message that will be sent to call this service
response the name of the message that will be published when this service is complete
url the URL that will be called to retrieve JSON data
args An object that defines additional options for the Ajax call. Standard attributes for this object are defined below
Args object properties
  • method: HTTP method to use in Ajax call (GET, PUT, etc)
  • scope: determines the scope in which this service can be called


App.mq.unsubscribe

Remove a listener from the page using the given handle

App.mq.unsubscribe(handle);
Parameter Description
handle the handle for the listener you wish to remove - the handle for a listener is designated when the listener is created (see $MQL)


App.mq.unintercept

Remove an interceptor from the page using the given handle.

App.mq.unintercept(handle);
Parameter Description
handle the handle for the interceptor you wish to remove - the handle for an interceptor is designated when the interceptor is created (see $MQI)


App.mq.config

App.mq.config is an object which contains configuration parameters for Entourage MQ. These properties can be set via JavaScript.

Property Description
min_scan_interval The minimum amount of time between message queue scans - the default value is 100ms
max_scan_interval The maximum amount of time between message queue scans - the default value is 150ms
step_size This is the value of time in milliseconds which is added or subtracted from the scan interval, depending on queue activity. For example, if the queue is empty on a scan, this amount is added to the interval before the next scan. The default value is 10ms
mq/api.txt · Last modified: 2009/03/09 18:31 by kwhinnery