O'Reilly logo

Enterprise JavaBeans 3.1, 6th Edition by Bill Burke, Andrew Lee Rubinger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix J. Timer Service: Credit Card Processor Example

Description

As we’ve seen with message-driven beans, a client request is not the only way to start a business taskflow. In addition to listening on incoming messages like MDB, events can be fired based on some timed criteria. EJB handles this via the Timer Service.

EJB 3.1 has seen significant advancements to the bean provider’s view of the Timer Service with a completely revamped natural-language syntax. This example models a credit card processing operation, which at the beginning of every hour will process all queued transactions. Scheduling the job is done both programmatically via the javax.ejb.TimerService API, as well as declaratively via the @Timeout and @Schedule annotations.

Source Listing

Following is a full listing of all source code used in this runnable example.

Implementation Resources

CreditCardTransaction.java

package org.jboss.ejb3.examples.ch19.timer.api; import java.math.BigDecimal; /** * Value object representing a single credit card transaction. * Immutable. * * @author <a href="mailto:andrew.rubinger@jboss.org">ALR</a> * @version $Revision: $ */ public class CreditCardTransaction { //--------------------------------------------------------------------------|| // Instance Members --------------------------------------------------------|| ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required