Archive for the 'Java' Category
RIA Prototype Client Using BlazeDS Messaging and JMS - J2EE Server
In a previous posting I gave an overview of the dashboard prototype that I created to investigate BlazeDS messaging with Flex clients. This posting focuses specifically on the J2EE application server component. I encourage you to read the prototype overview section of my initial post if you have not done so already to glean an understanding of what this server component does in the prototype.
Server Architecture
The EJB3 server architecture is quite basic and consists of one interface, one enterprise Java Bean (EJB), and one plain old Java object (POJO) value object. ITimer is a local interface that is implemented by the stateless DataGeneratorBean EJB. The DataGeneratorBean takes advantage of EJB timer service in order to generate events at the frequency specified by the client. You can start and stop message generation by calling the startTimer() or stopTimer() methods of the DataGeneratorBean EJB (these are the methods called by the client to start and stop message generation). It should be noted that by default EJB timers are persistent. That is if the timer is running when you shut the application server down it will start up automatically when you start the application server and again.
The MetricsVO value object is used to encapsulate the metrics data. A corresponding MetricsVO object is defined within the Flex client and the [RemoteClass(alias='info.jimboone.MetricsVO')] meta tag is added to the Flex definition object to assist BlazeDS in translating the Java object to/from the ActionScript object . You can view all of the Java EJB source files here.
BlazeDS Configuration
Integration of the J2EE server with BlazeDS occurs in the web.xml file. All that is required here is the definition of the MessageBrokerServlet servlet and a listener that keeps track of the HTTP Flex sessions (HttpFlexSession). This is fairly straightforward and very well documented within the BlazeDS Developers Guide (you can also view the web.xml files in the turnkey applications examples). The complete web.xml file is shown below: