This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch activemq-5.15.x
in repository https://gitbox.apache.org/repos/asf/activemq.git
The following commit(s) were added to refs/heads/activemq-5.15.x by this push:
new ffc0930 [AMQ-7246] Add scheduledMessageCount attribute on the
JobSchedulerView MBean
ffc0930 is described below
commit ffc09305243da186cd6535afebadba4df33bbdf4
Author: jbonofre <[email protected]>
AuthorDate: Tue Jan 12 18:43:46 2021 +0100
[AMQ-7246] Add scheduledMessageCount attribute on the JobSchedulerView MBean
(cherry picked from commit f01e35f7d95bee8c22c5eb45b8b25375fc6ece59)
---
.../activemq/broker/jmx/JobSchedulerView.java | 22 ++++++++++++++++++++++
.../activemq/broker/jmx/JobSchedulerViewMBean.java | 20 ++++++++++++++++++++
2 files changed, 42 insertions(+)
diff --git
a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/JobSchedulerView.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/JobSchedulerView.java
index def4218..92dfe92 100644
---
a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/JobSchedulerView.java
+++
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/JobSchedulerView.java
@@ -24,10 +24,14 @@ import javax.management.openmbean.TabularData;
import javax.management.openmbean.TabularDataSupport;
import javax.management.openmbean.TabularType;
+import org.apache.activemq.Message;
+import org.apache.activemq.ScheduledMessage;
import org.apache.activemq.broker.jmx.OpenTypeSupport.OpenTypeFactory;
import org.apache.activemq.broker.scheduler.Job;
import org.apache.activemq.broker.scheduler.JobScheduler;
import org.apache.activemq.broker.scheduler.JobSupport;
+import org.apache.activemq.openwire.OpenWireFormat;
+import org.apache.activemq.util.ByteSequence;
/**
* MBean object that can be used to manage a single instance of a
JobScheduler. The object
@@ -77,6 +81,24 @@ public class JobSchedulerView implements
JobSchedulerViewMBean {
}
@Override
+ public int getDelayedMessageCount() throws Exception {
+ int counter = 0;
+ OpenWireFormat wireFormat = new OpenWireFormat();
+ for (Job job : jobScheduler.getAllJobs()) {
+ Message msg = (Message) wireFormat.unmarshal(new
ByteSequence(job.getPayload()));
+ if (msg.getLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY) > 0)
{
+ counter++;
+ }
+ }
+ return counter;
+ }
+
+ @Override
+ public int getScheduledMessageCount() throws Exception {
+ return this.jobScheduler.getAllJobs().size();
+ }
+
+ @Override
public TabularData getNextScheduleJobs() throws Exception {
OpenTypeFactory factory = OpenTypeSupport.getFactory(Job.class);
CompositeType ct = factory.getCompositeType();
diff --git
a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/JobSchedulerViewMBean.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/JobSchedulerViewMBean.java
index 82a48ae..9aedbef 100644
---
a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/JobSchedulerViewMBean.java
+++
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/JobSchedulerViewMBean.java
@@ -122,4 +122,24 @@ public interface JobSchedulerViewMBean {
@MBeanInfo("get the scheduled Jobs in the Store within the time range. Not
HTML friendly ")
public abstract TabularData getAllJobs(@MBeanInfo("start: yyyy-MM-dd
hh:mm:ss")String start,@MBeanInfo("finish: yyyy-MM-dd hh:mm:ss")String
finish)throws Exception;
+ /**
+ * Get the number of messages in the scheduler.
+ *
+ * @return the number of messages in the scheduler.
+ *
+ * @throws Exception if an error occurs while querying the scheduler store.
+ */
+ @MBeanInfo("get the number of scheduled message (basically message in the
scheduler")
+ public abstract int getScheduledMessageCount() throws Exception;
+
+ /**
+ * Get the number of delayed messages.
+ *
+ * @return the number of delayed messages.
+ *
+ * @throws Exception if an error occurs while querying the scheduler store.
+ */
+ @MBeanInfo("get the number of delayed message")
+ public abstract int getDelayedMessageCount() throws Exception;
+
}