Skip to content

Instantly share code, notes, and snippets.

@imageaid
Created December 14, 2010 15:58
Show Gist options
  • Save imageaid/740616 to your computer and use it in GitHub Desktop.
Save imageaid/740616 to your computer and use it in GitHub Desktop.
A CFML script that, when the form is submitted, calls the Java objects to send a message
<cfscript>
if(lcase(trim(cgi.request_method)) == 'post'){
broadcastAnnouncement();
}
</cfscript>
<cfoutput>
<html>
<head>
<title>General Announcements</title>
</head>
<body>
<div>
Press 'Go' to send a general announcement to the Flex client.
</div>
<form action="#cgi.script_name#" method="post">
<input type="submit" value="Go" />
</form>
</body>
</html>
</cfoutput>
<cffunction name="broadcastAnnouncement" access="public" returntype="void" output="No">
<cfscript>
var msg = createObject("java","com.pojo.messages.MessageBody").init();
var messageService = createObject("java","com.gateways.adapters.JMSPublisher");
// setup the message object
// POJO for Message Object -- this one is much simpler, as it's a general announcement to all Flex clients
msg.setMessage("Hello from Railo!! Or Java. Or ACF. Or OpenBD. Or whatever the hell ...");
msg.setMessageType("Site-wide Announcement");
msg.setMessageUsername("");
msg.setMessageMemberID("");
// fire up the messaging service and send the message. We send an empty string as the third argument as there is no selector on these messages.
// Most importantly, we pass in the POJO (msg) and indicate to which topic we're publishing
messageService.publishMessage(msg,"announcements","");
</cfscript>
</cffunction>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment