[jboss-user] [Clustering/JBoss] - FYI : Communication between services in clustered environmen
ekobir
do-not-reply at jboss.com
Wed May 20 11:28:28 EDT 2009
Hi All
I just want to share some tricky points which I encountered while developing communications between services in clustered environment.
There might be options out there but following 2 options are definitely available for you to use.
1) JMX Notifications
* Provide cluster wide notifications
You can send notification to only local listeners, only remote listeners or both.
Only thing you need to do is to implement NotificationListener interface and register your service for notification in the startService method.
addNotificationListener(NotificationListener, NotificationFilter, Object handBack);
2) Remote Procedure Call by using HAPartition. (If your service extends from HAServiceMBeanSupport, you will have access to underlying ClusterPartition instance)
Remote method call might be more helpful if you want to call a specific method on a specific node in the cluster. Underlying HAPartition provides you following methods as of JBoss 5. Please refer to API for details.
callAsyncMethodOnNode
callAsyncMethodOnCluster
callMethonOnCluster
callMethonOnNode
callMethonOnCoordinatorNode
Important:
In order to make your service a RPC handler, you need to register it by calling
registerRPCHandler(String service_name, Object rpcHandler) on HAPartition.
If you are using jmx notifications as well RPCs, make sure service name you used to register your service as a RPC handler is different than actual service name.
The reason is that underlying HAServiceImpl's uses your actual service name to register its RPC handler as JMX Notification uses RPC behind the scene. (If Im not wrong method name is handleEvent.)
So you might ask what could happen if I register my service with original service name for RPC? Basically your service will not be getting any notifications from anywhere and in order to see what's happening you might need to change logging level to TRACE for jboss.
Note: If you are going to use instance of a custom class as data in your jmx notification, make sure that you are not using loader-repository element in jboss-app.xml.
If you used it, ClassNotFoundException will occur.
please let me know if anything is wrong.
Cheers
Erkin
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4232293#4232293
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4232293
More information about the jboss-user
mailing list