Hi Peter and others,

Thank you for the instructions, I got it working! :)

I have still one question: how will I get the received
message passed to my web application (message is
received by Catalina)? (is there a way to add that
listener to my web application or does it have to be
defined in the server.xml? if so, should I use JMX in
the Listener class to get the handle of my web
application or is there another way?)

Here are the details of my implementation (two Tomcat
5.11 servers on two machines (Windows XP)):

a) added test.xml to conf/Catalina/localhost
<Context docBase="${catalina.home}/webapps/test"      
   privileged="true">
</Context>

b) implemented class "MyMessage implements
ClusterMessage"

c) created a servlet, and in doGet method I do the
following:
        mBeanServer = Registry.getRegistry(null,
null).getMBeanServer();
        ObjectName cluster = new
ObjectName("Catalina:type=Cluster,host=localhost");
        mBeanServer.invoke(cluster, "send", new
Object[] {new MyMessage()}, new String[]
{"org.apache.catalina.cluster.ClusterMessage"});

d) created a class "MyMessageListener extends
ClusterListener"

e) conf/server.xml 
 -enabled clustering (just by removing the comment
tags)
 -added to cluster element:
     <ClusterListener  className="MyMessageListener"/>

f) created clustertest.jar (contains MyMessage and
MyMessageListener) and copied that to server/lib
directory).

g) created test.war, and copied that to webapps
directory.

Thanks,
Eino
--- Peter Rossbach <[EMAIL PROTECTED]> wrote:

> Hey Bradley,
> 
> a)   mark application as priviliged=true
> b)   define and implement your own ClusterMessage
> c)   via MbeansServer you got the
> Catalina:type=Cluster,host=localhost 
> mbean and send your
> operation ( send(ClusterMessage)).
> d)   Register a ClusterListener.
>           with 5.5.11 you can configure this
> directly inside Cluster 
> element.
>           with 5.5.9 you must implement you own host
> listener to 
> register a ClusterListener.
> 
> I am motivate to implement a simple sample and add
> this to the tomcat docs..
> 
> Peter
> 
> Bradley McLain schrieb:
> 
> >this is a good question.  i'll be facing the same
> issue soon.  for
> >session-based information, your answer is fine, but
> what about other
> >types of info, say at the app-level?  in one of my
> apps, for example, I
> >can change some config data using a web request,
> but what if i want to
> >ensure it is replicated to the other nodes in the
> cluster?
> >
> >On Fri, 2005-09-16 at 17:53 +0200, Lionel Farbos
> wrote:
> >  
> >
> >>Hi,
> >>
> >>Why do you want your application to send a
> notification ?
> >>If you configure Session Replication in each of
> your Tomcat servers, 
> >>every time there will be a change in your HTTP
> session, the others AS in the cluster will be
> notified and synchronized automatically.
> >>You have nothing to do...
> >>
> >>On Fri, 16 Sep 2005 15:18:58 +0100 (BST)
> >>Eino Lilius <[EMAIL PROTECTED]> wrote:
> >>
> >>    
> >>
> >>>Hi,
> >>>
> >>>I have successfully installed a Tomcat cluster :)
> 
> >>>I need to notify other nodes in the cluster when
> a
> >>>state is changed in my web application. My
> problem is
> >>>that I don't know how to send those
> notifications. 
> >>>
> >>>I've found one reply to similar question: "You
> can
> >>>register your own Cluster Message Listener and
> with 
> >>>SimpleTcpCluster.send(ClusterMessage) you can
> send
> >>>your message to all cluster nodes."
> >>>
> >>>How is that done in practice? Does someone have
> an
> >>>example how to get the reference to that
> >>>SimpleTcpCluster instance? 
> >>>
> >>>Any help is appreciated :)
> >>>
> >>>Thanks,
> >>>Eino
> >>>
> >>>
> >>>           
>
>>>___________________________________________________________
> 
> >>>How much free photo storage do you get? Store
> your holiday 
> >>>snaps for FREE with Yahoo! Photos
> http://uk.photos.yahoo.com
> >>>
>
>>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> >>>For additional commands, e-mail:
> [EMAIL PROTECTED]
> >>>
> >>>
> >>>      
> >>>
>
>>---------------------------------------------------------------------
> >>To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> >>For additional commands, e-mail:
> [EMAIL PROTECTED]
> >>
> >>
> >>    
> >>
> >
> >
>
>---------------------------------------------------------------------
> >To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> >For additional commands, e-mail:
> [EMAIL PROTECTED]
> >
> >
> >
> >
> >  
> >
> 
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 




                
___________________________________________________________ 
How much free photo storage do you get? Store your holiday 
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to