File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Message Driven Beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Message Driven Beans" Watch "Message Driven Beans" New topic
Author

Message Driven Beans

Tony romer
Ranch Hand

Joined: Jul 21, 2008
Posts: 32
Dear folks,
I am reading EJB 3 In Action book and got a bit confused about JMS Chapter.

Let's say,

Company A1 has application APP1 which is Message Producer. It sends this message as a topic to an MQ which exists in Company A2 network.

Company A3 is a subscriber of this topic.

Now where is my MDB, i am confused about EJB 3 In Action codes,

Can I summarize as follows,
MDB lives in an EJB container.
MDB pulls messages from MQ.
MDB lives on same side of client who is subscriber.

As far as I see from the book it looks like (there is another EJB Container where MQ lives) and MDB lives here and pushes messages to Company3.

Could you share your thoughts because i am having difficulties to see clear big picture on this topic?

Thanks

Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268
you are like me confused person, but I think it would be helpful....

Now where is my MDB

and answer is
Company A3 is a subscriber of this topic

Subscriber (a consumer) is eating the message & processing it, so Subscriber is MDB and it is at Company A3

Can I summarize as follows,
MDB lives in an EJB container.
MDB pulls messages from MQ.
MDB lives on same side of client who is subscriber


I think all these assumptions are true.
Tony romer
Ranch Hand

Joined: Jul 21, 2008
Posts: 32
Thank you.
But one more thing here, all my subscribers need EJB Container and EJB supported Application Server.

I was thinking this JMS system (as a subscriber) can even be used in my grandfather's PC at home.

Think about this example,
I have a client application that shows up online weather information from all cities in UK. All clients are subscribed to this topic. Even for this simple system do I need to install EJB container for all client's machines? OR do you have a better solution with JMS API?

I am sorry guys I am just entering to EJB world and as you can see I know almost nothing.
Forgive my rookieness
Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268
I was thinking this JMS system (as a subscriber) can even be used in my grandfather's PC at home.


MDB Vs. JMS

same book (EJB3 In Action) will share following points
- MDB are pooled & can process multiple messages (multi-threaded).
- JMS consume messages as SingleTheadModel (process single message at a time)
What if no. of expected messages are in bulk

- MDB can use CMT & other container services
- With JMS you would need to write code (if you use MDB, you can concentrate on Business need)
What if development time is less

- MDB (in EJB3), using annontation you can inject needed resources using single statement (I want X resource)
- JMS you need to do lookUp or create instances your-self
Easy to code

behind the scene, MDB is using JMS...
and if your need is an house-hold application & huge time, you can go for JMS....


Think about this example,
I have a client application that shows up online weather information from all cities in UK. All clients are subscribed to this topic. Even for this simple system do I need to install EJB container for all client's machines? OR do you have a better solution with JMS API?


I am new to JMS too & have limited knowledge. I think it all depends what we need to do with the consumed message (architecture issue).


Ralph Jaus
Ranch Hand

Joined: Apr 27, 2008
Posts: 342
Hi Tony,

all a subscribers needs, is access to the topic (and a JMS implementation). You don't need an ejb container or application server for this purpose. If the topic is durable not even the subscriber's system is required to be runing when the weather information is send.


SCJP 5 (98%) - SCBCD 5 (98%)
Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268
Ralph,

Can you please comment on what I said? I need to confirm if my assumptions are correct or not?

thanks.
Tony romer
Ranch Hand

Joined: Jul 21, 2008
Posts: 32
Hi Ralph,
If I will have the MDB in subscriber side, why do not I need an EJB container there also?


Hi Deephika,
I am thinking MDB as a part of JMS, they are like apples and oranges and not comparable I think? Can you please comment where am I wrong?

Thank you very much
Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268
I am thinking MDB as a part of JMS

No.

JMS is independent technology (to learn about JMS you do not need to touch MDB)
Like Ralph mentioned that if you are implementing (using) JMS for consuming message, JMS does not need application server/ container like MDB needs

MDB is different technology to consume message (or to act based on consumed messages)
(MDB under the hood uses JMS API but you do not need to know everything about JMS to develop MDB)

If I will have the MDB in subscriber side, why do not I need an EJB container there also

If subscriber (client) is MDB, client will need EJB container.

I was thinking this JMS system (as a subscriber) can even be used in my grandfather's PC at home

but here you said using JMS API for consumtion, so you do not need EJB container (you are not using EJB, you do not need EJB container).
Ralph Jaus
Ranch Hand

Joined: Apr 27, 2008
Posts: 342
Hi Tony,

If I will have the MDB in subscriber side, why do not I need an EJB container there also?

Deepika already answered it.

Hi Deepika,

if "JMS" in "MDB Vs. JMS" means something like "JavaSE JMS-application" then I agree on most of what you have said. Two remarks:
- MDB are pooled & can process multiple messages (multi-threaded).
- JMS consume messages as SingleTheadModel (process single message at a time)

It should be possible to write a multi-threaded application with each thread receiving messages (similar to an ejb container).
behind the scene, MDB is using JMS...

It's correct that an EJB 3 compliant container must support JMS. But the concept of MDB is more general: A MDB has a message listener interface that defines the messaging type used by the bean. JMS is only a special messaging type here (and corresponds to the message listener interface javax.jms.MessageListener).
Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268
thanks a lot....

It's correct that an EJB 3 compliant container must support JMS. But the concept of MDB is more general: A MDB has a message listener interface that defines the messaging type used by the bean. JMS is only a special messaging type here (and corresponds to the message listener interface javax.jms.MessageListener).


If destination is not JMS oriented MOM, and is MSMQ (which does not support JMS) then MDB would need to implement Connector Interface and method(s), am I correct?
And in this case do we need to implement interface javax.jms.MessageListener & onMessage method?

Ralph Jaus
Ranch Hand

Joined: Apr 27, 2008
Posts: 342
The Java Connector Architecture (JCA) is used to connect to the MOM. There's a resource adapter where it can be registerd, which message listener method (e.g. onMessage for JMS) has to be called by the container if a message arrives in the associated destination. But I don't know the technical details on how JCA works.
And in this case do we need to implement interface javax.jms.MessageListener & onMessage method?

No. Assume the message listener interface is "MyMessageListener" and the method "myOnMessage". In this case the MDB would implement MyMessageListener interface.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Message Driven Beans
 
Similar Threads
Question On JMS
MDB Problem on WebSphere 5.0
Pending Messages
Tranaction problem in CMT based MDB 3.0
Need help with MDB