Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

MDB Question re: WEB tier vs. EJB tier

 
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a 2 part question re: J2EE app architecture and Message Driven Beans.
In our app, we separate the web and ejb tiers.
1. I understand this is not uncommon so I am wondering how a message driven bean is able to notify the web tier when onMessage fires (since the ejb tier does not reference the web tier�only vice versa).
Since an MDB is essentially local, is it OK to have it reside in the web tier?
2. If this is the case and I am using WAS 4.02 with Extended Messaging Support where do I load the session bean with the onMessage method?
Thanks
Max Tomlinson
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Max Tomlinson:
I have a 2 part question re: J2EE app architecture and Message Driven Beans.
In our app, we separate the web and ejb tiers.
1. I understand this is not uncommon so I am wondering how a message driven bean is able to notify the web tier when onMessage fires (since the ejb tier does not reference the web tier�only vice versa).
Since an MDB is essentially local, is it OK to have it reside in the web tier?
2. If this is the case and I am using WAS 4.02 with Extended Messaging Support where do I load the session bean with the onMessage method?
Thanks
Max Tomlinson



I think you have a basic misunderstanding here Max. An MDB is an EJB -- it MUST reside on the EJB tier. It cannot reside anywhere else. And it's not common for MDBs to notify the web tier about anything -- it usually goes the other way around (a Servlet places a message on a queue or Topic). Why would the Servlet tier care about a message receipt anyway? How would it respond?
Kyle
 
Max Tomlinson
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the response Kyle-
The reason I wanted notification from the MDB to the web tier is that I am implementing the �propagate cache update pattern� using JMS. When one server updates items that are cached, a JMS message is sent to the JMS refresh queue. When the onMessage event fires, I wanted to notify the web tier so that the web model containers (cache) in the other servers can be refreshed and kept in sync.
What I am doing now is writing a simple JMS Listener which is instantiated in the web tier on startup, rather than using a MDB.
thanks,
Max
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, as my post to the other topic explained, that ain't gonna work. You'll need to keep your cache in the EJB container and use an MDB instead.
Kyle
 
Max Tomlinson
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't realize server cache for this pattern means cache needs to reside in the EJB tier. In our case, it's kept in the servlet container. Moving it might not be do-able at this point.
What I did do was write a thread class which is spawned on web server starup which reads the queue every minute to check for refreshes. Not very elegant but it seems to work. I'm testing it on WSAD5 (it's a WAS 4 app) and I get the following msgs:
1. PrivExAction W J2CA0114W:W J2CA0114W: No container-managed authentication alias found.
2. ConnectionMan W J2CA0075W: An active transaction should be present while processing method allocateMCWrapper.
I'm wondering if this is the way to go. I could use a simple http msg to send refresh msgs to various servers.
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have similar situtation. I need to write a MDB to "post" the servlets which resides the same application server or different application server. What is the best alternative to do it?
reply
    Bookmark Topic Watch Topic
  • New Topic