138
Designing XML Based Applications
private Queue queue;
public SupplierOrderRcvr() throws RemoteException {
queueFactory = ...; // Lookup queue factory
queue = ...; // Lookup queue
...
}
public String receive(Source supplierOrder)
throws InvalidOrderException {
// Preprocess (validate and transform) the incoming document
String document = ...
// Extract the order id from the incoming document
String orderId = ...
// Forward the transformed document to the processing layer
// using JMS
QueueConnection connection
= queueFactory.createQueueConnection();
QueueSession session = connection.createQueueSession(...);
QueueSender queueSender = session.createSender(queue);
TextMessage message = session.createTextMessage();
message.setText(document);
queueSender.send(message);
return orderId;
}
}
Code Example 4.4
Sending an XML Document to a JMS Queue
public class SupplierOrderMDB
implements MessageDrivenBean, MessageListener {
private OrderFulfillmentFacadeLocal poProcessor = null;
public SupplierOrderMDB() {}
public void ejbCreate() {
// Create a purchase order processor
poProcessor = ...
}
New Page 1