createDestination(destname, channelId)
Last updated March 20, 2010
Version: 1 | Requires: ColdFusion 9 | Library: UtilityLib
Description:
In case you want to physically separate communication between certain groups of users, best way to do that is to create new destination and to direct messages on it. One way to do that is to define destination in messaging-config.xml or dynamically at runtime using this function.
It takes 2 arguments:
- destname - Destination name
- channelId - Channel ID. Channel is either defined in services-config.xml or you may use createChannel method to do it at runtime
Return Values:
Returns a destination object.
Example:
Parameters:
| Name | Description | Required |
|---|---|---|
| destname | Destination name. | Yes |
| channelId | Channel ID. | Yes |
Full UDF Source:
<cfscript>
/**
* Creates BlazeDS destination at runtime
*
* @param destname Destination name. (Required)
* @param channelId Channel ID. (Required)
* @return Returns a destination object.
* @author Marko Simic (marko.simic@gmail.com)
* @version 1, March 20, 2010
*/
function createDestination(destname, channelId){
var local = structNew();
local.brokerClass = createObject('java','flex.messaging.MessageBroker');
local.broker = local.brokerClass.getMessageBroker( javacast('null','') );
local.service = local.broker.getService('message-service');
local.destinations = local.service.getDestinations();
//check if destination already exists. If it does just return it
if (structKeyExists(local.destinations,arguments.destname)){ //check if destination already exist
return local.destinations[arguments.destname];
}
// Creates a ServiceAdapter instance and sets its id, sets if destination is manageable
local.destination = local.service.createDestination(arguments.destname);
local.destination.createAdapter('cfgateway');
local.configMap = createObject('java','flex.messaging.config.ConfigMap').init();
local.configMap.addProperty('gatewayid',application.CFEventGatewayId);
local.ss = createObject("java","flex.messaging.config.ServerSettings");
local.ss.setAllowSubtopics(true);
local.ss.setSubtopicSeparator('.');
local.ss.setDurable(false);
local.destination.setServerSettings(ss);
local.adapter = local.destination.getAdapter();
//Initializes the adapter with the properties.
local.adapter.initialize('cfgateway',configMap);
local.destination.addChannel(arguments.channelId);
//Starts the destination if its associated Service is started and if the destination is not already running.
local.destination.start();
return local.destination;
}
</cfscript>
Search CFLib.org
Latest Additions
Tayo Akinmade added
arrayTrim
11 day(s) ago
Will Belden added
longTime
17 day(s) ago
James Sleeman added
quickSort
27 day(s) ago
Ben Forta added
GetHostAddress
30 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)