Very simple Flex (FB3) application which subscribes to a ColdFusion 9
DataServicesMessaging Event Gateway using the CF9 "embedded" BlazeDS.
Issue: When the Flex application starts, the mx:Consumer component
returns the following faultSting "Duplicate subscription. Another client
has already subscribed with the clientId,
'803B65B1-312C-989A-F55A-4C3973AAEDD6'."
If I reload the page in the browser the error does not occur and the
application works as expected.
I have a ColdFusion page that sends a message to the CF Event Gateway.
The gateway is working because the "out" count increases each time I
send a message and, once I reload the Flex page, the messages from the
CF page show up on the Flex page.
Here is the code for the cfm page that sends a message to the CF
gateway:
<!--- If form submitted, send message --->
<cfif IsDefined("FORM.message")>
<cfset msg=StructNew()>
<cfset msg.body="#FORM.message#">
<cfset msg.destination="ColdFusionGateway">
<cfset ret=SendGatewayMessage("Flex2CF", msg)>
<cfif ret>
Message sent.
<cfelse>
Message failed.
</cfif>
<br />
</cfif>
<!--- Form --->
<cfform name="form1" action="#CGI.SCRIPT_NAME#">
Message:
<cfinput type="text" name="message">
<br />
<cfinput type="submit" name="sbmt" value="Send">
</cfform>
</script>
Here is the Flex application code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical" creationComplete="initApp()">
<mx:Script>
<![CDATA[
import mx.messaging.messages.IMessage;
import mx.messaging.events.MessageEvent;
import mx.messaging.Consumer;
import mx.controls.Alert;
private function initApp():void{
cons.subscribe();
}
private function messageHandler(event:MessageEvent):void{
cfmsg.text = event.message.body.toString();
}
]]>
</mx:Script>
<mx:Consumer id="cons" destination="ColdFusionGateway"
message="messageHandler(event)"
fault="Alert.show(event.faultString)"/>
<mx:Label id="cfmsg" width="100" />
<mx:Label text="Connected={cons.connected}
Subscribed={cons.subscribed}" />
</mx:Application>
My messaging-config.xml file is the original one that was installed with
CF9.
This is running locally using the built-in CF webserver
(http://localhost:8500).
Any help/ideas would be greatly appreciated.