Java Reference
In-Depth Information
There are different strategies for sending the final response to the user who
requested the report. The asynchronous reports in eInsure generally fetched records
from the RDBMS based on certain criteria, applied formatting (such as date and cur-
rency), and saved this data as files of various formats, including Microsoft Word, PDF,
Microsoft Excel, and so on. When the report file generation was complete, the users were
informed about it by e-mail.
Message-Driven POJO
With Spring, it is possible to support asynchronous message listeners even without any
application server or JMS provider. In fact, it is possible to turn any POJO class into a
message listener—a so-called message-driven POJO (MDP)—without any EJB container
support. The MDPs are registered in Spring message listener containers. The message lis-
tener containers receive messages from a JMS queue and invoke the registered MDPs.
Listing 5-27 shows the MDP. It is independent of any framework-specific interfaces
or abstract classes. Since the message listener is a mere POJO, it is not possible for
Spring to determine which method to invoke when a message arrives in the queue. The
MessageListenerAdapter handles this.
Listing 5-27. ReportMessageListener.java
public class ReportMessageListener {
private void processReport(Map reportParams){
//generate reports
}
}
The message listener container is started when the Spring application container is
initialized and started. You will also need to register the message listener. This can be
done with the configuration, as shown in Listing 5-28.
Listing 5-28. insurance-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=" http://www.springframework.org/schema/beans"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
"
>
<!—the other beans -->
 
 
Search WWH ::




Custom Search