Solved

Implementation steps for cluster wide singleton - weblogic 9.2 / 10

Posted on 2009-05-17
5
2,383 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
xyzMiddle java challenge 33 106
Looking for some programs to resell or buy source codes 1 79
application cannot connect to database server for query 13 125
base64 decode encode 12 189
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…
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 …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

733 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