Solved

Implementation steps for cluster wide singleton - weblogic 9.2 / 10

Posted on 2009-05-17
5
2,326 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Not able to update Java 5 200
error when i compile 5 480
menu bar in visual basic 2013 1 490
Https with tomcat. A myth. 5 92
The Fluent Interface Design Pattern You can use the Fluent Interface (http://en.wikipedia.org/wiki/Fluent_interface) design pattern to make your PHP code easier to read and maintain.  "Fluent Interface" is an object-oriented design pattern that r…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now