• 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

Send a message from EJB to Servlet without JMS.

 
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 a legacy servlet which I have a EJB (A) need to send a message to it to process. It seems that I can write a local EJB (B) acting as proxy of EJB A. Then I define a static queue that EJB B and servlet can send and receive the message. Since EJB B and servlet are in the same JVM, it seems work. Can anyone tell me what I would have missed?
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you invoking a servlet with a queue? That makes no sense. Why not use an HttpURLConnection from your EJB?
Kyle
 
shell Johnson
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If EJB B and servlet are in the same JVM. (Servlet has been promoted to application visibility), then a static simple List class can be used fifo queue between EJB B and servlet. Using HttpURLConnection going through TCP/IP localhost overkills it, don't you think so?
 
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
No, I don't. You're restricting your application to only work with the Web container and EJB container are co-deployed, and what's more, classloader differences may not make your approach work in all cases (e.g. the Web Container and EJB container load from different classloaders, which might give you TWO copies of any static variable).
Stick to the spec. Use either JMS or an HttpURLConnection. Or even better, refactor the Servlet into a utility class and a separate servlet that handles the HTTP side and then call the utility class directly.
Kyle
 
shell Johnson
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kyle, Thank you. Refactoring is not possible at this moment. We have several servlets toss messages around. HttpURLConnection requires to open a doorway from existing servlet or create another new servlet. JMS needs additional port configuration. None of this are cheap. Basically, you may have better suggestion. We have a customer written implement class (using listner and call back model. e.g async. request and response). We used to put it into our classpath, load it to our JVM and run with our application (one single big WAR with application visibility). Recently, we need to expand its funcation and realize we have security problem. The customer written implement class can use our resources! We need to put it into separate container. The scenarion I describe earlier is to put into EJB container and run it as different application. Do you have any other idea?
 
You may have just won ten million dollars! Or, maybe a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic