try {
System.out.println("ReservationProcessor::onMessage() called..");
MapMessage reservationMsg = (MapMessage)message;
Integer customerPk = (Integer)
reservationMsg.getObject("CustomerID");
Integer cruisePk = (Integer)
reservationMsg.getObject("CruiseID");
Integer cabinPk = (Integer)
reservationMsg.getObject("CabinID");
double price = reservationMsg.getDouble("Price");
String creditCardNum = reservationMsg.getString("CreditCardNum");
Date creditCardExpDate = new Date( reservationMsg.getLong("CreditCardExpDate") );
String creditCardType = reservationMsg.getString("CreditCardType");
CreditCardDO card = new CreditCardDO(creditCardNum,creditCardExpDate,creditCardType);
System.out.println("Customer ID = "+customerPk+", Cruise ID = "+cruisePk+", Cabin ID = "+cabinPk+", Price = "+price);
CustomerRemote customer = getCustomer(customerPk);
CruiseLocal cruise = getCruise(cruisePk);
CabinLocal cabin = getCabin(cabinPk);
ReservationHomeLocal resHome = (ReservationHomeLocal)
jndiContext.lookup("java:comp/env/ejb/ReservationHomeLocal");
ReservationLocal reservation =
resHome.create(customer, cruise, cabin, price, new java.sql.Date(System.currentTimeMillis()));
Object ref = jndiContext.lookup("java:comp/env/ejb/ProcessPaymentHomeRemote");
ProcessPaymentHomeRemote ppHome = (ProcessPaymentHomeRemote)
PortableRemoteObject.narrow(ref, ProcessPaymentHomeRemote.class);
ProcessPaymentRemote process = ppHome.create();
process.byCredit(customer, card, price);
TicketDO ticket = new TicketDO(customer,cruise,cabin,price);
System.out.println("Created Ticket and Delivering ticket");
deliverTicket(reservationMsg, ticket);
} catch(Exception e) {
e.printStackTrace();
throw new EJBException(e);
}