Solved

MDB JMS Question

Posted on 2013-05-17
1
424 Views
Last Modified: 2013-05-27
I was reading on MDB JMS as below and have questions as below

Message driven beans are the light weight components used for communication via messages (e.g., email or IM messages). In message driven beans, the messaging service is in asynchronous mode because the user is not intended to get the instant result.
>>what is meaning of leight weight components??


Message-driven beans can implement any messaging type. Most commonly, they implement the Java Message Service (JMS) technology.
>>what other messaging types MDBs can implement apart from JMS??



Message-driven beans have the following characteristics:

•A message-driven bean's instances retain no data or conversational state for a specific client i.e. they are stateless.
>>how they can be stateless. How to store the state if i want to?


•A single message-driven bean can process messages from multiple clients.
>>Does entity beans also process messages from multiple clients?


•They are invoked asynchronously.
>>They are invoked or listened asynchronously? I am not clear on this invoking part??


•They can be transaction-aware.
>>how to make MDB transaction aware?

•They do not represent directly shared data in the database, but they can access and update this data.
>>I am not clear on this point as well?



•A message-driven bean has only a bean class i.e. unlike a session bean, the clients don't access message-driven beans through interfaces.
>>what it means by only bean class but no interfaces??

•They don't have the remote or local interfaces that define client access.
>>what it means by only bean class but no interfaces??


In Message driven beans (MDB), the client components don't locate message-driven beans and invoke methods directly. Instead, The JMS clients send messages to message queues managed by the JMS server (e.g., an email inbox can be a message queue) for which the javax.jms.MessageListener interface is implemented.
>>how email Inbox is related to MDB or JMS



The message queue is monitored by a special kind of EJB(s) - Message Driven Beans (MDBs) That processes the incoming messages and perform the services requested by the message. The MDBs are the end-point for JMS service request messages.
>>what is meaning of end points, cannot they be start points??



You assign a message-driven bean?s destination during deployment by using Application Server resources.
>>what does MDB destination point to??


he class must be defined as public and must contain a public constructor with no arguments. It must not define the finalize method.
>>I am not clear on above point. Please advise

A message is delivered to a message-driven bean within a transaction context, so all operations within the onMessage method are part of a single transaction. If message processing is rolled back, the message will be redelivered.
>>I am not clear on above point. Please advise



Any links sample code resources, ideas highly appreciated. Thanks in advance
0
Comment
Question by:gudii9
1 Comment
 
LVL 35

Accepted Solution

by:
girionis earned 500 total points
ID: 39180845
>>what is meaning of leight weight components??

Probably that they don't have a remote/home interface.

>>what other messaging types MDBs can implement apart from JMS??

JMS is a way for sending and receiving messages. You can implement your own way (as long as you conform to the JCA api) and use MDBs.

>>how they can be stateless. How to store the state if i want to?

You cannot, MDBs are meant to be stateless.

>>Does entity beans also process messages from multiple clients?

They are different. Entity beans are used for database interaction.

>>They are invoked or listened asynchronously? I am not clear on this invoking part??

They messages are delivered asynchronously. The MDBs listen for messages all the time.

>>how to make MDB transaction aware?

Same way as the rest of EJBs. You either declare the transactions or do it manually.

•They do not represent directly shared data in the database, but they can access and update this data.
>>I am not clear on this point as well?


From an MDB you can open a connection to the database and do usual database interactions.

>>what it means by only bean class but no interfaces??

They don't have a remote/local interface, so you cannot make a look up an MDB instance. MDB instances are just listening for messages.

>>how email Inbox is related to MDB or JMS

It is not. I guess the author probably means that you can use an e-mail inbox to read e-mails and send them to a queue.

>>what is meaning of end points, cannot they be start points??

It means it's the end of the flow, thus the end-point. Once you send the message to the queue and it's read by the MDB this is the end of the message.

>>what does MDB destination point to??

This is where you send the messages to (a queue or a topic).

he class must be defined as public and must contain a public constructor with no arguments. It must not define the finalize method.
>>I am not clear on above point. Please advise


http://howtodoinjava.com/2012/10/31/why-not-to-use-finalize-method-in-java/

A message is delivered to a message-driven bean within a transaction context, so all operations within the onMessage method are part of a single transaction. If message processing is rolled back, the message will be redelivered.
>>I am not clear on above point. Please advise


A transaction must be started *before* message dequeuing, thus before the call on the onMessage method. So the dequeuing of the message and the processing of the message run in the same transaction context (if your MDB needs to call other EJBS that need to participate in the transaction the container passes the transaction context to these EJBs). So if an error occurs and the transaction is rolled back it's like the message has never left the queue, and it will be redelivered.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
IT Company 5 69
maven java path setting 5 50
topping2 challenge 13 63
mockito example issue 8 38
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now