Monday, March 8, 2010

Spring EYE on JAVA EE - 9

With the product ordering functionalities in place, let’s get back to the report functionalities purposely left behind. Report request, differentiates itself from other functionalities, for its characteristic slowness. Message Oriented Midware, MOM, provide asynchronized approach is ideal for this kind of request. In addition, MOM broker provide reliability in case of system failure, which is a huge plus for report. Therefore, I will deploy report services via message exchange through MOM broker.


In this project, the open source ActiveMQ broker will be embedded in the app server. In Spring configuration file broker’s configuration is added. Message driven bean, ReportMessageWorker.java, which sebsequently call the report execution, is created and linked to the certain queue in the configuration.


ReportMessageWorker.java




Add the following configuration inspringDemoContext.xml to embed ActiveMQ




Unit test takes advantage of the JmsTemplate provided by Spring for converting and sending message.


ReportJMSTest.java




Similar approaches used in the controller to submit report request.



Now finish up the report functionalities. One thing worth point out is the display of report in Excel format. Since Spring allows directly access to HttpServletRequest/Response object, this can be achieved by direct writing to the response.


ReportController.java




Previous    Next

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home