• 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

MDB related query for defining static variable

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can we define a public static variable in MDB?
My application works with Servlet and MDB.
Basically Servlet sends a message to my MDB and updates the database(even if message is not sent). When MDB doesn't receives any messages from Servlet within a timeFrame it updates the DB with some other values and at the same time I want to tell my servlet somehow that from my MDB that it has updated the DB. I was thinking to use a public static Arraylist in my MDB so that the Servlet can check this list and will come to know that MDB has updated the DB. The another way is to use HTTPClient from my MDB and sedn it as a request parameter but i don't want to use it.

Thanks
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We can use static variables only if they are defined as a final. Otherwise it will break in cluster environment.

Thanks,
Mahesh

--------------
SCJP 1.4 |SCWCD 1.4 | SCBCD 1.3 | SCEA Part I - In Progress
 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

When MDB doesn't receives any messages from Servlet within a timeFrame it updates the DB with some other values and at the same time I want to tell my servlet somehow that from my MDB that it has updated the DB.



How would your MDB update db when it did not receive a request from a servlet? Did you use timer to invoke the MDB?

I was thinking to use a public static Arraylist in my MDB so that the Servlet can check this list and will come to know that MDB has updated the DB.



Servlet to MDB is an async call. By the time the servlet received the MDB response, your DB could have changed several times.
reply
    Bookmark Topic Watch Topic
  • New Topic