Question
Axiom Technology Group
US
Last activity: 25 Jun 2018 8:58 EDT
Start the listener using activity
Hi All,
We have a requirement to start and stop the listener based on a business logic. We are able to stop the listener using the below code.
com.pega.pegarules.priv.management.MBeanManagement.executeMBeanOperation( "com.pega.pegarules.management.internal.ListenerManagement", "StopListener",
"MyListenerName", null, null);
We used the below function to start the listener. This is not working as expected.
com.pega.pegarules.priv.management.MBeanManagement.executeMBeanOperation("com.pega.pegarules.management.internal.ListenerManagement","StartListener",
"MyListenerName", null, null);
Please let me know if there is any issue in the above call. Thanks in advance.
Pega version: 7.3.1
Regards,
Nizam
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Instellars
IN
Hi Nizam,
Try this and see if the listener you are trying to start is available or not. You will need to fetch the XML, parse it and get the name of the listener if it is available and then pass it to StartListener.
String AvailableListenersXML = (String)com.pega.pegarules.priv.management.MBeanManagement.executeMBeanOperation(
"com.pega.pegarules.management.internal.ListenerManagement", "AvailableListeners", null, null, null);
// from the XML returned by AvailableListenersXML, parse out /AvailableListeners/Listener/Name into ListenerNames[]
for (String ListenerName in ListenerNames[]) {
com.pega.pegarules.priv.management.MBeanManagement.executeMBeanOperation(
"com.pega.pegarules.management.internal.ListenerManagement", "StartListener", ListenerName, null, null);
}
Virgin Media
GB
Hi Ajay,
I've tried this but cannot get the xml document of returned listeners to be parsed and iterated over. I'm no java developer. Can you provide us with a solution please?
This is what I have attempted to no avail, as the document ends up being empty for some reason and it throws exceptions in the logs.
Hi Ajay,
I've tried this but cannot get the xml document of returned listeners to be parsed and iterated over. I'm no java developer. Can you provide us with a solution please?
This is what I have attempted to no avail, as the document ends up being empty for some reason and it throws exceptions in the logs.
String AvailableListenersXML = (String) com.pega.pegarules.priv.management.MBeanManagement.executeMBeanOperation(
"com.pega.pegarules.management.internal.ListenerManagement", "AvailableListeners", null, null, null);
// from the XML returned by AvailableListenersXML, parse out /AvailableListeners/Listener/Name into ListenerNames[]
try {
javax.xml.parsers.DocumentBuilderFactory dbFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
javax.xml.parsers.DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
StringBuilder xmlStringBuilder = new StringBuilder();
xmlStringBuilder.append(AvailableListenersXML);
java.io.ByteArrayInputStream input = new java.io.ByteArrayInputStream(xmlStringBuilder.toString().getBytes("UTF-8"));
org.w3c.dom.Document doc = dBuilder.parse(AvailableListenersXML);
//doc.getDocumentElement().normalize();
oLog.infoForced(doc);
javax.xml.xpath.XPath xPath = javax.xml.xpath.XPathFactory.newInstance().newXPath();
String expression = "/AvailableListeners/Listener/Name";
oLog.infoForced(expression);
org.w3c.dom.NodeList nodeList = (org.w3c.dom.NodeList) xPath.compile(expression).evaluate(AvailableListenersXML, javax.xml.xpath.XPathConstants.NODESET);
String[] ListenerNames = new String[nodeList.getLength()];
oLog.infoForced(java.util.Arrays.toString(ListenerNames));
for (String ListenerName: ListenerNames) {
myXML = ListenerName;
oLog.infoForced(myXML);
//com.pega.pegarules.priv.management.MBeanManagement.executeMBeanOperation("com.pega.pegarules.management.internal.ListenerManagement", "StartListener", ListenerName, null, null);
}
} catch (javax.xml.parsers.ParserConfigurationException e) {
throw new PRRuntimeException(e);
} catch (org.xml.sax.SAXException e) {
throw new PRRuntimeException(e);
} catch (java.io.IOException e) {
throw new PRRuntimeException(e);
} catch (javax.xml.xpath.XPathExpressionException e) {
throw new PRRuntimeException(e);
}
Thanks
Craig
Pegasystems Inc.
IN
You might want to go through below article
Let me know if you require any further steps to be explained here .
Virgin Media
GB
OK I finally got it to return me the list of listeners, however when I invoke
com.pega.pegarules.priv.management.MBeanManagement.executeMBeanOperation("com.pega.pegarules.management.internal.ListenerManagement", "StartListener", param1, null, null);
I get an error message :-
OK I finally got it to return me the list of listeners, however when I invoke
com.pega.pegarules.priv.management.MBeanManagement.executeMBeanOperation("com.pega.pegarules.management.internal.ListenerManagement", "StartListener", param1, null, null);
I get an error message :-
Exception encountered while invoking MBean. javax.management.ReflectionException: Target method not found: com.pega.pegarules.management.internal.ListenerManagement.StartListener at javax.management.modelmbean.RequiredModelMBean.resolveMethod(Unknown Source) at javax.management.modelmbean.RequiredModelMBean.invoke(Unknown Source) at com.pega.pegarules.priv.management.PegaModelMBean.invoke(PegaModelMBean.java:121) at com.pega.pegarules.priv.management.MBeanManagement.executeMBeanOperation(MBeanManagement.java:246) at com.pega.pegarules.priv.management.MBeanManagement.executeMBeanOperation(MBeanManagement.java:134) at com.pegarules.generated.activity.sh_action_restartlisteners_bf38e39c3cc2722200f7da1dfb18400f.step1_circum0(sh_action_restartlisteners_bf38e39c3cc2722200f7da1dfb18400f.java:215) at com.pegarules.generated.activity.sh_action_restartlisteners_bf38e39c3cc2722200f7da1dfb18400f.perform(sh_action_restartlisteners_bf38e39c3cc2722200f7da1dfb18400f.java:71) at com.pega.pegarules.session.internal.mgmt.Executable.doActivity(Executable.java:3597) at com.pega.pegarules.session.internal.mgmt.Executable.doAction(Executable.java:3330) at com.pegarules.generated.activity.ra_action_pyrunrecordexecute_f7d1e1c1513eef165c7ecbe136f3addd.step2_circum0(ra_action_pyrunrecordexecute_f7d1e1c1513eef165c7ecbe136f3addd.java:249) at com.pegarules.generated.activity.ra_action_pyrunrecordexecute_f7d1e1c1513eef165c7ecbe136f3addd.perform(ra_action_pyrunrecordexecute_f7d1e1c1513eef165c7ecbe136f3addd.java:88) at com.pega.pegarules.session.internal.mgmt.Executable.doActivity(Executable.java:3597) at com.pega.pegarules.session.internal.mgmt.Executable.invokeActivity(Executable.java:10845) at com.pegarules.generated.activity.ra_action_pzrunrecordexecute_c38281e0bb63f7c4aab88814460c8435.step11_circum0(ra_action_pzrunrecordexecute_c38281e0bb63f7c4aab88814460c8435.java:1027) at com.pegarules.generated.activity.ra_action_pzrunrecordexecute_c38281e0bb63f7c4aab88814460c8435.perform(ra_action_pzrunrecordexecute_c38281e0bb63f7c4aab88814460c8435.java:246) at com.pega.pegarules.session.internal.mgmt.Executable.doActivity(Executable.java:3597) at com.pega.pegarules.session.internal.mgmt.base.ThreadRunner.runActivitiesAlt(ThreadRunner.java:646) at com.pega.pegarules.session.internal.mgmt.PRThreadImpl.runActivitiesAlt(PRThreadImpl.java:481) at com.pega.pegarules.session.internal.engineinterface.service.HttpAPI.runActivities(HttpAPI.java:3414) at com.pega.pegarules.session.external.engineinterface.service.EngineAPI.processRequestInner(EngineAPI.java:399) at sun.reflect.GeneratedMethodAccessor866.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.pega.pegarules.session.internal.PRSessionProviderImpl.performTargetActionWithLock(PRSessionProviderImpl.java:1338) at com.pega.pegarules.session.internal.PRSessionProviderImpl.doWithRequestorLocked(PRSessionProviderImpl.java:1075) at com.pega.pegarules.session.internal.PRSessionProviderImpl.doWithRequestorLocked(PRSessionProviderImpl.java:930) at com.pega.pegarules.session.external.engineinterface.service.EngineAPI.processRequest(EngineAPI.java:336) at com.pega.pegarules.session.internal.engineinterface.service.HttpAPI.invoke(HttpAPI.java:854) at com.pega.pegarules.session.internal.engineinterface.etier.impl.EngineImpl._invokeEngine_privact(EngineImpl.java:331) at com.pega.pegarules.session.internal.engineinterface.etier.impl.EngineImpl.invokeEngine(EngineImpl.java:274) at com.pega.pegarules.session.internal.engineinterface.etier.impl.EngineImpl.invokeEngine(EngineImpl.java:251) at com.pega.pegarules.priv.context.JNDIEnvironment.invokeEngineInner(JNDIEnvironment.java:278) at com.pega.pegarules.priv.context.JNDIEnvironment.invokeEngine(JNDIEnvironment.java:223) at com.pega.pegarules.web.impl.WebStandardImpl.makeEtierRequest(WebStandardImpl.java:678) at com.pega.pegarules.web.impl.WebStandardImpl.doPost(WebStandardImpl.java:394) at sun.reflect.GeneratedMethodAccessor865.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.pega.pegarules.internal.bootstrap.PRBootstrap.invokeMethod(PRBootstrap.java:370) at com.pega.pegarules.internal.bootstrap.PRBootstrap.invokeMethodPropagatingThrowable(PRBootstrap.java:411) at com.pega.pegarules.boot.internal.extbridge.AppServerBridgeToPega.invokeMethodPropagatingThrowable(AppServerBridgeToPega.java:224) at com.pega.pegarules.boot.internal.extbridge.AppServerBridgeToPega.invokeMethod(AppServerBridgeToPega.java:273) at com.pega.pegarules.internal.web.servlet.WebStandardBoot.doPost(WebStandardBoot.java:129) at com.pega.pegarules.internal.web.servlet.WebStandardBoot.doGet(WebStandardBoot.java:100) at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1096) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:674) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.NoSuchMethodException: com.pega.pegarules.management.internal.ListenerManagement.StartListener() at java.lang.Class.getMethod(Unknown Source) ... 67 more
And in the log we get "java.lang.NoSuchMethodException: com.pega.pegarules.management.internal.ListenerManagement.StartListener()"
This suggests that the method StartListener doesn't exist. We are running 7.31. Also when I send in the listener name do I need to specify exactly what is returned by the AvailableListeners or the shortname?
Thanks
Craig
UPDATE : I found this page https://community.pega.com/support/support-articles/prsysmgmtwar-deployment-issue-pega-715 which describes exactly the error I am getting but SMA doesn't have an issue and we don't have another commons-logging.jar in our lib folder or anywhere else. Also within jconsole when I look at the StartListener method it's expecting the Listener ID as a string but won't accept either the full name from the available listeners or the shortname! Any ideas?
Virgin Media
GB
OK further information.
I have found that the following method calls work :-
ListenerStatus
AvailableListeners
Restart
Stop
The following method calls fail :-
StartListener throws "Exception during engine invocation: com.pega.pegarules.management.internal.ListenerManagementAPI.StartListener java.lang.NullPointerException" during both jconsole and pega call
Only working within jconsole :-
Start requires Listener Class, Listener Name and Listener Java Class which are params 1,2 & 4. Call from pega only takes 3 params!
Within pega get error "Exception encountered while invoking MBean. javax.management.ReflectionException: Target method not found: com.pega.pegarules.management.internal.ListenerManagement.Start"
So I can stop & restart and check the status but I cannot start a listener!
Any idea what's going on here?
Cheers
Craig