OEJMX
- JMX (Java Management Extensions) is a Java framework-supplied technology that is part of the core JVM process.
- OEJMX is an OpenEdge command-line interface to get and set properties and execute actions within Tomcat and ABL web applications. It ties directly into java.exe, there is no need to have the oemanager.war deployed to the instance.
- The OEJMX utility is included in the PASOE instance under <PASOE>/bin directory and runs from PROENV.
How to stop an agent using OEJMX:
- Run an OEJMX Query to get the agentID
- Run an OEJMX action to stop the MSA. This operation will shut down the MSAgent without causing existing request(s) to fail.
1. Get Agent information
- Create a text file with a file extension .qry (getAgents.qry)
- Replace <ablAppName> with PASOE instance ABL webapp name.
{"O":"PASOE:type=OEManager,name=AgentManager","M":["getAgents","<ablAppName>"]}
- Run the query from PROENV:
Any path can be used to get the output in a different location, by default the output file is written to the <PASOE instance>/temp directory
$ <CATALINA_BASE>/bin/oejmx.sh -Q getAgents.qry -O getAgents.out
- Review the Output generated: getAgents.out
Query: Line 1. PASOE:type=OEManager,name=AgentManager, getAgents(oepas1)
Result: {"getAgents":{"agents":[{"agentId":"y8g7FfuoQti182KG1tQzkw","pid":"14104","state":"AVAILABLE"}]}}
2. Stop the agent using agentid or PID with the stopAgent action
- Create a text file with a file extension .qry (stopAgent.qry)
- Replace <agentid> with the agentId or PID returned from the output above.
{"O":"PASOE:type=OEManager,name=AgentManager","M":["stopAgent","<agentid>",<Integer waitToFinish>,<Integer waitAfterStop>]}
Example: stopAgent.qry
{"O":"PASOE:type=OEManager,name=AgentManager","M":["stopAgent","14104",120000,10000]}
- waitToFinish: (ms) 2 minutes for the stop process to wait for the agent to finish serving requests. No new requests are received by the agent during this period. If the agent finishes processing its current request before 2 minutes, the agent immediately shuts down, otherwise the agent is sent a STOP message when the wait time completes.
- waitAfterStop: (ms) 10 seconds additional time to wait for the agent to stop at which time a KILL message is sent.
- Run the query from PROENV:
$ <PASOE>/bin/oejmx.sh -Q stopAgent.qry -O /usr/wrk/stopAgent.out
- Review the Output generated: stopAgent.out
Query: Line 1. PASOE:type=OEManager,name=AgentManager, stopAgent(14104, 120000, 10000)
Result: {"stopAgent":true}
3. Once the MSA is stopped
Use-Case 1: To recycle agents
This is intended to work with a PAS instance configured with maxAgents >= 2. Our recommendation is to have a min/initial number of 2 agents, with enough sessions/connections configured to handle typical workload on one agent, so that a “spare” is always available to begin taking requests. After stopping the agent, traffic that was originally handled by the lead agent ( to stop and recycle ) requests are handled by the next agent available to the PAS instance. The minagents = 2 will assure the agent is started, otherwise if another MSA is required it can be manually started with OEJMX:
{"O":"PASOE:type=OEManager,name=SessionManager","M":["addAgent","oepas1"]}
The result should look like this:
{"addAgent":{"agentId":"3BrUvyXfT4m1RRM7gtSy1Q","pid":"10892","state":"AVAILABLE"}}
Use-Case 2: To specifically stop a problem MSA before shutting down the instance
Typically specific agent Sessions may need to be terminated with a hard-stop (1) before stopping the MSA as outlined above:
{"O":"PASOE:type=OEManager,name=AgentManager","M":["terminateABLSession","agentID","sessionId","1"]}
The
terminateABLSession, terrminate Options are detailed in the following Article:
Once the MSA has been stopped, the PAS instance itself can be stopped with tcman/pasman stop:
- The stop is received by the session manager
- The session manager stops taking requests
- The session manager asks the agent(s) to stop
- The session manager waits for agent(s) to complete all requests
- When all agents are done, they exit
- Then the tomcat process ends