aspose file tools*
The moose likes BEA/Weblogic and the fly likes Weblogic cluster question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Weblogic cluster question" Watch "Weblogic cluster question" New topic
Author

Weblogic cluster question

trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 613
Hi,

In an application if there is a Singleton class, and the application is deployed in weblogic cluster then how many instances of the Singleton class will be there in a cluster?

I think per weblogic instance there will be one instance of the Singleton class. Is this correct? Can someone please clear my doubt?

Thanks,
Trupti
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Yes, there should be a singleton per server instance. However, the problem may lie in synchronizing the state of all the singletons in the cluster.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 613
How to take care of this situation? My Singleton Class's getObject method is Synchronised. Will it solve the problem in Cluster?

Originally posted by Roger Chung-Wee:
Yes, there should be a singleton per server instance. However, the problem may lie in synchronizing the state of all the singletons in the cluster.


Thanks,
Trupti
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
Originally posted by trupti nigam:
My Singleton Class's getObject method is Synchronised. Will it solve the problem in Cluster?


If I am not wrong, each server will have its own copy of singleton class, hence by macking getObject method Synchronised, you problem will not be solved.


My blood is tested +ve for Java.
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
It can be worse than one instance of a singleton per server, it can be one per classloader.

Google on singleton j2ee and/or cluster and find some suggested solutions and problems.

Here's one article:

Sun Developer Network Article "When is a Singleton not a Singleton?"
trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 613
Thanks Carol, that was a very informative link.
For the future references of other memebrs I am going to cut and paste the info I was looking for and found on BEA site.

In a cluster of a WLS :
Singleton services´┐ŻA singleton service is active on exactly one server in the cluster at a time and processes requests from multiple clients. A singleton service is generally backed by private, persistent data, which it caches in memory. It may also maintain transient state in memory, which is either regenerated or lost in the event of failure. Upon failure, a singleton service must be restarted on the same server or migrated to a new server.

I think I got the answer.
Thanks all who contributed.

Trupti
Shailesh Mangal
Greenhorn

Joined: Apr 09, 2006
Posts: 2
there are tonnes of options to implement J2EE singleton( for access shared Data). Can anybody share thier experience on following.
1. Pinned RMI Server (deployed on single server in the cluster)
2. Single instance on Entity Bean
3. Corba Service
4. Static Value in Servlet (container replicate the value if changed)

My preference would be to go with EJB, would like to know if someone has already tried something similar or had any issues with it?
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
All depends, what is the Singleton being used for? My general stance on singletons is... don't do it.
[ April 09, 2006: Message edited by: Chris Mathews ]
Erik Bengtson
Ranch Hand

Joined: Dec 06, 2003
Posts: 90
Singleton services applies to "services" provided by the app server while singleton object instances is down to the application level.

A singleton instance is tied to the classloader. When you deploy your application you will have usually, depending on how you have configured the classloaders, one singleton instance per "application and app server"

Singleton services in BEA WLS are services that have only one instance in the cluster. Examples are JMS and JTA systems, and these systems usually have persistent state stored in the file systems or databases.
Zdenek Mach
Greenhorn

Joined: Nov 29, 2007
Posts: 3
Hi,

have you any experience with implementation of singleton service? I tried to make my message-driven-bean as singleton service using weblogic.cluster.singleton.SingletonService interface and weblogic-application.xml file but it doesn't work. MDB is always deployed and active at all nodes of cluster.

Thanks
Zdenek
Zdenek Mach
Greenhorn

Joined: Nov 29, 2007
Posts: 3
I have partial solution now:

For proper work of SingletonService, the servers (cluster nodes) must be run using node manager. Then SingletonService as pure java class works - methods activate and deactivate are called as expected.

However it seems, that MDB cannot be a SingletonService.

Zdenek
Neelam Hankare
Greenhorn

Joined: Jun 12, 2011
Posts: 3
Hi all,
I have tried implementing singleton servcie in MDB,but dint work as expected..Without MDB , implementation of Singleton service is wokring fine..but wanted to achieve transactionality..
More detail:
1. Singleton servcie will picked up the message from foriegn jms queue using onMessage().
2. It will send the message to some other service (like proxy service).
3. If some error occurs ,it should rollback the entire transaction as well as put the message to original queue..
4. Rollbacked message will get again picked up by singleton service without loosing sequencing.

In short, Message wont get loss until successful delivery.

Please suggest some few approach to achieve rollback operation...


Thanks,
Neelam.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Weblogic cluster question