Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@
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
Expand Down Expand Up @@ -76,6 +80,24 @@ public TabularData getAllJobs(String startTime, String finishTime) throws Except
return rc;
}

@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}