I started several weeks ago to see what we can do with Grails and its Enterprise side, and because where I'm working right now it's needed to do some messaging from the back-end to the clients (Flex clients); well, I did some modifications to the flex/grails plug-in (developed by Marcel Overdijk) in order to be able to send messages from grails to Flex (consumer).

Assuming that we already have our domain, controllers and maybe some views, the only thing we need to do is install the flex plug-in, do some small modifications to the source (flex plug-in), create a helper class (to send the messages), create a service (this will defined our destination), add the messaging service tag to the flex configuration (services-config.xml) and test it on your Flex application. For these steps I'm using Grails IDE on Eclipse.

So here are the steps:

1) Install the Flex plug-in: (Using the Grails IDE on eclipse, you can bring up the grails command prompt with Ctrl+Alt+G for Windows or Cmd+Alt+G for Mac).

grails > install-plugin flex

2) Modify the Flex plug-in source code: The files to modify will be GrailsBootstrapService.java and FlexUtils.java

GrailsBootstrapService.java, the bootstrap service will help to create dynamically the destination(s).

<!-- Application level default channels. Application level default channels are necessary when a dynamic destination is being used by a service component and no ChannelSet has been defined for the service component. In that case, application level default channels will be used to contact the destination. --> <default-channels> <channel ref="grails-amf"/> </default-channels> </services>