/** * Create blazeds destination at runtime. Follow SVN link to java source files for more details. * @name hint="Destination name" */ function createDestination(destname,channelId){ var local = structNew(); //svn: http://opensource.adobe.com/svn/opensource/blazeds/trunk/modules/core/src/flex/messaging/MessageBroker.java 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]; } //svn: http://opensource.adobe.com/svn/opensource/blazeds/trunk/modules/core/src/flex/messaging/Destination.java local.destination = local.service.createDestination(arguments.destname); // Creates a ServiceAdapter instance and sets its id, sets if destination is manageable local.destination.createAdapter('cfgateway'); //svn: http://opensource.adobe.com/svn/opensource/blazeds/trunk/modules/common/src/flex/messaging/config/ConfigMap.java local.configMap = createObject('java','flex.messaging.config.ConfigMap').init(); local.configMap.addProperty('gatewayid',application.CFEventGatewayId); //svn: http://opensource.adobe.com/svn/opensource/blazeds/trunk/modules/core/src/flex/messaging/config/ServerSettings.java 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; }Note that I placed svn links to BlazeDS java source files. While I was working on this and especially endpoint creation, insight to these files was invaluable to me. Each method is nicely documented, so it is very easy to understand.
More on this subject:
- Adobe BlazeDS Developer Guide: Configuring components with a remote object
- Joao Fernandes' blog had some very nice posts regarding this subject, but old site is dead, and don't address to new one
- Aaron West blog: Search for "BlazeDS"
- Stephen Moretti blog: AJAX Longpolling with ColdFusion and BlazeDS - Connecting and Messaging
- How to setup BlazeDS on ColdFusion 8
2 comments:
I might be missing something, but I think you want to replace arguments.roomname with arguments.destname.
You are absolutely right. Fixed. Thank you.
Post a Comment