• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Message Driven Beans

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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).


 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Deepika Joshi
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic