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 ...

Get J2EE™ Applications and BEA™ WebLogic Server™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.