| |
|
| java.lang.Object sampleappli.StockHandlerBean
StockHandlerBean | public class StockHandlerBean implements MessageDrivenBean,MessageListener(Code) | | StockHandlerBean is a Message driven bean which is listening to a topic It
receives MapMessages that contains a customer identification, a product
identification and a quantity for the product When the StockHandlerBean
receives a message it builds a message corresponding to an Order and sends it
to a Queue destination then it updates the Stock database.
|
Method Summary | |
public void | ejbCreate() The Message driven bean must define an ejbCreate methods with no args. | public void | ejbRemove() A container invokes this method before it ends the life of the
message-driven object. | public void | onMessage(Message message) | public void | setMessageDrivenContext(MessageDrivenContext ctx) Set the associated context. |
queueConnection | QueueConnection queueConnection(Code) | | |
queueConnectionFactory | QueueConnectionFactory queueConnectionFactory(Code) | | |
StockHandlerBean | public StockHandlerBean()(Code) | | Default constructor
|
ejbCreate | public void ejbCreate()(Code) | | The Message driven bean must define an ejbCreate methods with no args.
|
ejbRemove | public void ejbRemove()(Code) | | A container invokes this method before it ends the life of the
message-driven object. This happens when a container decides to terminate
the message-driven object. This method is called with no transaction
context.
throws: EJBException - Thrown by the method to indicate a failure caused bya system-level error. |
onMessage | public void onMessage(Message message)(Code) | | onMessage method Map Messages are receive with the following format:
"CustomerId" String "ProductId" String "Quantity" int the Message driven
bean will construct a string for an Order that will be sent to the Queue
Orders and decrease the stock quantity for the product identified by
ProductId this method run in the scope of a transaction that the
container started immediately before dispatching the onMessage method the
sending message to the Order queue and the updating of the Stock table is
made in the same global transaction this transaction may be rolled back
if the stock quantity became negative
|
setMessageDrivenContext | public void setMessageDrivenContext(MessageDrivenContext ctx)(Code) | | Set the associated context. The container call this method after the
instance creation. The enterprise Bean instance should store the
reference to the context object in an instance variable. This method is
called with no transaction context.
Parameters: MessageDrivenContext - A MessageDrivenContext interface for theinstance. throws: EJBException - Thrown by the method to indicate a failure caused bya system-level error. |
|
|
|