O'Reilly logo

J2EE™ Applications and BEA™ WebLogic Server™ by Sandra L. Emerson, Rob Woollen, Michael Girdley

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

New Customer Example

Let's now take a look at an example that combines message-driven EJBs with stateless session and entity beans. This example demonstrates the process of entering new customer records into a database. The customer information is sent to a JMS queue named newCustomers. A message-driven EJB listens on this queue, unpacks the message, and calls a stateless session bean to enter the new customer record.

public class NewCustomerReceiverBean
  implements MessageDrivenBean, MessageListener
{
  private static final int BAD_MESSAGE_TYPE = 1;
  private static final int CUSTOMER_ALREADY_EXISTS = 2;

  private MessageDrivenContext ctx;

  private NewCustomer newCustomer;

The setMessageDrivenContext creates a reference to the NewCustomer stateless ...

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