Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why MDB is "loosely coupled" than Asynchronous Bean ?

 
Kaxhif Khan
Ranch Hand
Posts: 50
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

It is said in "EJB 3 in Action (2nd Edition) by "Debu Panda et.al" that if you want loosely couple and reliable functionality choose message driven bean instead of asynchronous bean. The reason for the tight coupling of asynchronous bean is given as "the client has direct reference" to asynchounous bean.

In general MDB looks more tightly coupled to me than Asynch Bean as if JNDI name of connection factory is changed we have to update both client and MDB whereas Asyn Bean doesn't look like tightly coupled.


Why is it that Asynchronous bean is considered tightly coupled ?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I Haven't used an Async Bean, but my understanding is that you need to have the implementation. Whereas with an MDB, you only need to have the remote interface(s) rather than the implementation class. This means if there is a change in implementation, an MDB's client wouldn't need to be updated, but an async bean's would.
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3817
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:I Haven't used an Async Bean, but my understanding is that you need to have the implementation. Whereas with an MDB, you only need to have the remote interface(s) rather than the implementation class. This means if there is a change in implementation, an MDB's client wouldn't need to be updated, but an async bean's would.

Although a bean class is not required to implement any interface if it is accessed only locally, you don't need implementation class for any bean in general (from the client perspective). You need just the interface. In case of async bean, the client is still tied to the interface.

For MDB, there is no interface. The client just needs the destination (queue or topic) address. This allows you replace your MDB without any impact on the client code. Hence, more loosely coupled than async bean.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh! I read MDB as remote EJB. (I don't know why). Ignore my post.

 
Kaxhif Khan
Ranch Hand
Posts: 50
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne Boyarsky and Paul Anilprem
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic