Solved

Implementation steps for cluster wide singleton - weblogic 9.2 / 10

Posted on 2009-05-17
5
2,352 Views
Last Modified: 2013-12-10
I would like to have the steps to implement a cluster wide singleton in Weblogic. My singleton class is the connection pool which has to be available through out the cluster.
0
Comment
Question by:lsivasailam
  • 3
5 Comments
 
LVL 10

Accepted Solution

by:
rajesh_bala earned 63 total points
ID: 24409788
Why do you need singleton for connection pool. Is it mandatory to have your class as singleton?.

Though it might be possible to tie your class in JNDi to achieve singleton behaviour, weblogic might not recommend it.

Another option is to try terracota which provides this feature. But first of all, double check if you really need singleton for connection pool alone.


~Rajesh.B
0
 
LVL 1

Assisted Solution

by:ctoan
ctoan earned 62 total points
ID: 24488179
You can very easily create a custom singleton service in weblogic server. Here are the steps :

1) Make sure your class extends weblogic.cluster.singleton.SingletonService

http://e-docs.bea.com/wls/docs100/javadocs/weblogic/cluster/singleton/SingletonService.html

Example:

I have an interface
public interface SingletonTestService extends SingletonService, Remote {

}

I also have an impl class

public class SingletonTestServiceImpl implements SingletonTestService {

2) Compile and run rmic on it ( I also jar it)

Example:

  <target name="compile" >
            <javac srcdir="${src}"
               destdir="${build}"
                   classpath="${my.classpath}"
               deprecation="${deprecation}"
               debug="${debug}"
               optimize="${optimize}"
               source="1.6" />
   </target>  
   
   <target name="rmi" description="" >      
      <rmic debug="true" destdir="${build}"
              eos="false" clusterable="false" dgcPolicy="managed"
              classname="com.mycompany.foo.SingletonTestServiceImpl"/>      
   </target>  

   <target name="jar" description="jars the singleton service" >      
            <jar jarfile="${dist}/singletonservice.jar"
                  basedir="${build}" includes="com/**"/>
   </target>

3) Make sure it is in the classpath for every cluster member. You can ensure this by dropping the jar in the DOMAIN/lib directory

4) Configure the Singleton Service using weblogic server admin console or WLST

For admin console : login > cluster > singleton service

0
 
LVL 1

Expert Comment

by:ctoan
ID: 24488225
Please note you can implement the activate() method to perform setup operations needed for your service to function. This is guaranteed to execute on any one of the servers when your service activates. Also, there is a corresponding deactivate method.

http://e-docs.bea.com/wls/docs100/javadocs/weblogic/cluster/singleton/SingletonService.html 

If you shutdown / kill the server on which the custom service is activated, you will see that it automatically activates on a different server in the cluster.

However, you may have to setup leasing (if you have not already done it) for this functionality to work
http://e-docs.bea.com/wls/docs103/cluster/migration.html#wp1047105
0
 
LVL 1

Expert Comment

by:ctoan
ID: 24488330
Checkout the official documentation at http://e-docs.bea.com/wls/docs103/cluster/service_migration.html#wp1051458

Section :Implementing the Singleton Service Interface
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
junit test for void methods using mockito 4 253
constuctor calling other constructor 2 76
twoTwo  challenge 35 103
Math Question 1 94
Dependencies in Software Design In software development, the idea of dependencies (http://en.wikipedia.org/wiki/Coupling_%28computer_programming%29) is an issue of some importance. This article seeks to explain what dependencies are and where they …
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question