简体   繁体   中英

Is it possible to implement singleton across two different jvm?

Im wondering if anyone there is convinient way how to implement singleton accross two different java virtual machines. We are using JMS to comunicate between these two. Is it even possible?

Don't think about singletons, think about a service. You can establish a service on one JVM and communicate with it via JMS from the other machine.

Everything is possible, but is it worth it? Most likely there is another approach to solve your problem. If you wish to communicate between application using singleton-like object, try JMS, web-services, RMI, shared file, anything ...

But if you really wanna hurt yourself: http://www.terracotta.org .

EJB 3.1 supports singleton EJB 's. I think this is the best way where you can centrally deploy this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM