1 / 23

Message Driven Beans Using JMS

Message Driven Beans Using JMS. Swapnil Shrivastava. Challenges with RMI-IIOP. Performance – must wait while the server performs processing Reliability – When RMI-IIOP calls the server, it has to be running Support for multiple senders and receivers not possible. Messaging.

radha
Download Presentation

Message Driven Beans Using JMS

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 Using JMS Swapnil Shrivastava

  2. Challenges with RMI-IIOP • Performance – must wait while the server performs processing • Reliability – When RMI-IIOP calls the server, it has to be running • Support for multiple senders and receivers not possible. (c)CDAC(Formerly NCST)

  3. Messaging • Receive messages from one or more message producers and broadcast it to one or more message consumers. • Support asynchronous programming. Message Oriented Middleware Application Application (c)CDAC(Formerly NCST)

  4. Message Oriented Middleware • Software infrastructure that supports messaging. • Example • Sonic MQ • IBM MQSeries • BEA Tuxedo/Q • Microsoft MSMQ (c)CDAC(Formerly NCST)

  5. Challenges addressed • Performance – A messaging client does not need to block when performing a request. • Reliability – If your MOM supports guaranteed delivery , you can send a message and know for sure it will reach the destination, even if the consumer is not available. • Support for multiple senders and receivers possible.. (c)CDAC(Formerly NCST)

  6. Messaging Domains • It is the style of messaging which is chosen to send messages. • Types : • Publish/Subscribe (Pub/Sub) Domain. • Point-to-Point (PTP) Domain. (c)CDAC(Formerly NCST)

  7. Publish/Subscribe • Many message producers talking to many message consumers. • It is an implementation of distributed event driven processing model. • Publisher send messages to topic in JMS. • Consumers who are interested in message subscribe to message topic. • Topic are persistent stores located at JMS destination. (c)CDAC(Formerly NCST)

  8. Publish/Subscribe deliver Producer1 publishes Topic Consumer 1 subscribe deliver Producer 2 Consumer 2 publishes subscribe (c)CDAC(Formerly NCST)

  9. Point-to-Point • Single consumer for each message. • Multiple producers can send messages to the queue but each message is delivered to single consumer. • Messages are sent to queue from which they are distributed to consumers in FIFO order. • Queue are persistent stores located at JMS destination. (c)CDAC(Formerly NCST)

  10. Point-to-Point acknowledges Queue sends Producer Consumer consumes (c)CDAC(Formerly NCST)

  11. JMS • JMS is a messaging standard. • Allows applications to create,send ,receive and read messages. • JMS consists of • JMS API : to write code to send and receive messages. • JMS SPI : where we plug in JMS drivers. • Low level topology issues are abstracted from the developer. (c)CDAC(Formerly NCST)

  12. JMS Programming Model • Locate JMS driver. • Create a JMS connection. • Create a JMS Session. • Locate a JMS destination. • Create a JMS producer or a JMS consumer. • Send or receive your message. (c)CDAC(Formerly NCST)

  13. JMS Architecture Message Producer Sends to Queue or Topic creates Session Message creates creates creates Connection Factory Connection creates Message Consumer Gets from Queue or Topic (c)CDAC(Formerly NCST)

  14. JMS-EJB Integration • To allow EJB components to benefit from value propositions of messaging such as • Non blocking clients • N-ary communication • EJB 2.0 introduced Message Driven Beans for JMS-EJB Integration. (c)CDAC(Formerly NCST)

  15. Message Driven Beans • MDB is a special EJB component that can receive JMS messages. • MDB consumes messages from queues or topics that are sent by any valid JMS client. • JMS API is used to send messages to MDB. (c)CDAC(Formerly NCST)

  16. Message Driven Beans EJB Server Message Driven Bean Pool Send/ publishes Client JMS Destination Message Driven Bean Instance (c)CDAC(Formerly NCST)

  17. MDB Characteristics • Doesn’t have home interface, remote interface,local interface and local home interface. • Have one loosely typed business method. • Do not have any return values. • Cannot send exceptions back to the client. • They are stateless. • Can be durable or non durable subscribers. (c)CDAC(Formerly NCST)

  18. Message Driven Bean Interface public interface javax.jms.MessageListener { public void onMessage(Message message); } public interface javax.ejb.MessageDrivenBean extends EnterpriseBean { public void ejbRemove()throws EJBException; public void setMessageDrivenContext(MessageDrivenContext ctx) throws EJBException; } (c)CDAC(Formerly NCST)

  19. MDB Ingredients • Message Driven Beans implements both MessageDrivenBean and MessageListener interface. • Consistes of: • MessageDrivenBean class. • Deployment Descriptor. • Vendor Specific Files. (c)CDAC(Formerly NCST)

  20. Example (c)CDAC(Formerly NCST)

  21. MDB Object Model <<interface>> java.io.Serializable <<interface>> javax.jms.MessageListener Comes with Java2 platform <<interface>> javax.ejb.EnterpriseBean <<interface>> javax.ejb.MessageDrivenBean Comes with EJB Distribution Bean Implement Class Written by developer (c)CDAC(Formerly NCST)

  22. Message Driven Bean Life Cycle Does Not Exist 1: newInstance() 2: setMessageDrivenContext() 3: ejbCreate() ejbRemove() Pooled onMessage() (c)CDAC(Formerly NCST)

  23. References • Mastering Enterprise Java Beans • J2EE 1.4 Tutorials • Professional Java Server Programming, J2EE Edition (c)CDAC(Formerly NCST)

More Related