1 / 16

Message Driven Beans

Message Driven Beans. Celsina Bignoli bignolic@smccd.net. Issues with RMI-IIOP. Performance Client must wait for server response Reliability If server crashes, client cannot perform its operation Support for multiple senders/receivers

yael
Download Presentation

Message Driven Beans

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Message Driven Beans Celsina Bignoli bignolic@smccd.net

  2. Issues with RMI-IIOP • Performance • Client must wait for server response • Reliability • If server crashes, client cannot perform its operation • Support for multiple senders/receivers • RMI-IIOP support single client communicating to single server at any point in time

  3. RMI-IIOP vs. Messaging • RMI • Messaging Application Application Application Application Application Application Application Message Middleware Application • receives messages from one or more • message producers • broadcasts these messages • to one or more message consumers

  4. Enterprise Messaging Systems • a.k.a. : Message-oriented Middleware • facilitate the exchange of messages between software applications over a network. • Products • IBM's MQSeries • BEA's WebLogicJMS service • Sun Microsystems' Sun ONE Message Queue • Sonic's SonicMQ

  5. Java Message Service (JMS) • provides vendor-independent access to enterprise messaging systems • consists of • API defining how to write code for receiving and sending messages • Service Provider Interface (SPI) to plug in JMS provider which knows how to talk to a specific MOM implementation

  6. Definitions • JMS clients: applications that use JMS • JMS provider: the messaging system that handles routing and delivery of messages • JMS application: business system composed of many JMS clients and, generally, one JMS provider. • producer: JMS client that sends a message • Consumer:JMS client that receives a message. • A single JMS client can be both a producer and a consumer.

  7. JMS Messaging Domains • Publish/subscribe (pub/sub) Producer1 Consumer1 Topic Producer2 Consumer2 • Point-to-point (PTP) Producer1 Queue Consumer1 Producer2

  8. JMS Messaging Domains (2) • Publish/Subscribe • Many message producers communicate to many message consumers • Subscriber register interest into a particular event topic • Publishers create events for a topic • Publishers do not know who the consumers are, the MOM system maintains the subscriber list • Point-to-point • Single consumer for each message • Messages are sent to a queue • Queue can have multiple consumers but each message is consumed only once

  9. JMS System JMS Driver Client Runtime 2: Create connection JMS Connection Factory JMS Server Queue 1 JMS Connection 3: Create session Queue 2 Topic 1 Serialized Message Comm. 5: Create consumer or producer Client JMS Session 1:Retrieve Connection Factory 4: Lookup JMS Destination JNDI JMS Producer Or JMS Consumer 6: Send or receive message

  10. JMS System

  11. Message-driven Beans • Special EJB component invoked by the container upon arrival of a message at the destination or end point serviced by the message-driven bean • Completely decoupled from clients • A client cannot access a message-driven bean through any component interface • Client interact with a message-driven bean only through messages

  12. Message-driven Beans Characteristics • does NOT have a home interface, local home interface, remote interface or local interface • Have weakly typed business methods • Listener methods might not have any return value • Might not send exceptions back to clients • Are stateless

  13. Message-driven Beans Semantics • Class that implements the following interfaces: javax.jms.MessageListener javax.ejb.MessageDrivenBean • Must provide ejbCreate() method that takes no arguments and return void

  14. Message-driven Beans Semantics(2) public interface javax.jms.MessageListener{ public void onMessage(Message message); } public interface javax.ejb.MessageDrivenBean extends javax.ejb.EnterpriseBean { public void ejbRemove() throws EJBException; public void setMessageDrivenContext (MessageDrivenContext ctx) throws EJBException; }

  15. Message-driven bean Life Cycle does not exist 1: newInstance() 2: setMessageDrivenContextContext() 3: ejbCreate() ejbRemove() pooled onMessage()

  16. Message-driven Beans caveats • Message Ordering • There is no guarantee that messages are delivered and processed in order • Missed ejbRemove() calls • This method ends up being used rarely, since message-driven been are usually only destroyed either at shutdown or when the EJB component is un-deployed

More Related