Message driven beans and other resource adapters based on JCA technology have lifecycle stages that can be controlled for precise timing of when a message is to be read from queue or when a file need to be read from a location. Prior to EJB 2.1, MDB's were just message listeners based on listener ports and could read messages only from JMS queues. With subsequent revisions they were based on JCA connector architecture which provided flexibility to have MDB's to not just listen JMS queues but also file systems, ofcourse proper listener need to be implemented. In addition, JMX extensions on these components provide non-intrusive way to control the lifecycle of JCA, which is Initialize, passivate and activate.
I came across a requirement to fetch messages dropped into the queue only at defined intervals and not just when message was available. Websphere JMX AdminService API exposes provides operations that can interrogate available J2CMessage bindings and issue commands to either pause, resume the endpoint listeners. One caveat though is these activation specs need to be initialized within your application for AdminService to look them up. In other words, if you have multiple EAR's encapsulated with MDB's and if you wish to control them centrally through another EAR (all deployed on same cell), you will not be able to passivate without them being activated first.
String endPointlistener = "*:*,type=J2CMessageEndpoint";
javax.management.ObjectName queryName =
new javax.management.ObjectName( endPointlistener);
AdminService adminService = AdminServiceFactory.getAdminService();
Set s = adminService.queryNames(queryName, null);
Iterator it = s.iterator();
List mbeans = new ArrayList();
while (it.hasNext()) {
ObjectName mBean = (ObjectName) it.next();
result = adminService.invoke(mBean, operationName, params,
signature);
}
No comments:
Post a Comment