• 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

Weblogic cluster question

 
Ranch Hand
Posts: 647
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
trupti nigam
Ranch Hand
Posts: 647
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 647
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic