Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

MDB related query for defining static variable  RSS feed

 
nandkishor rao
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • 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
 
Mahesh Desai
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • 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
 
vu lee
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!