Commit 486b2d6e authored by Andre Freyssinet's avatar Andre Freyssinet

Fix JORAM-372 and adds a MBean method to clear the queue.

parent 7b90b839
......@@ -343,9 +343,13 @@ public class Queue extends Destination implements QueueMBean {
/**
* Removes all request that the expiration time is expired.
*
* Be careful,this method is part of the Queue MBean interface, it can be called outside the
* reactions of the engine thread. In order to avoid synchronization issues we should avoid
* direct manipulation of requests list (see JORAM-372, JORAM-373).
*/
public void cleanWaitingRequest() {
cleanWaitingRequest(System.currentTimeMillis());
public final void cleanWaitingRequest() {
// cleanWaitingRequest(System.currentTimeMillis());
}
/**
......@@ -376,7 +380,7 @@ public class Queue extends Destination implements QueueMBean {
*/
public final int getWaitingRequestCount() {
if (requests != null) {
cleanWaitingRequest(System.currentTimeMillis());
// cleanWaitingRequest();
return requests.size();
}
return 0;
......@@ -388,15 +392,19 @@ public class Queue extends Destination implements QueueMBean {
/** List holding the messages before delivery. */
protected transient List<Message> messages;
public byte getType() {
return DestinationConstants.QUEUE_TYPE;
}
/**
* Removes all messages that the time-to-live is expired.
*
* Be careful,this method is part of the Queue MBean interface, it can be called outside the
* reactions of the engine thread. In order to avoid synchronization issues we should avoid
* direct manipulation of messages list (see JORAM-372, JORAM-373).
*/
public void cleanPendingMessage() {
cleanPendingMessage(System.currentTimeMillis());
}
public byte getType() {
return DestinationConstants.QUEUE_TYPE;
public final void cleanPendingMessage() {
// cleanPendingMessage(System.currentTimeMillis());
}
/**
......@@ -1267,6 +1275,14 @@ public class Queue extends Destination implements QueueMBean {
replyToTopic(new AdminReply(true, null), replyTo, requestMsgId, replyMsgId);
}
/**
* Removes all pending messages.
*/
@Override
public void clear() {
sendTo(getId(), new FwdAdminRequestNot(new ClearQueue(), null, null, null));
}
private void clearQueue(AgentId replyTo,
String requestMsgId,
String replyMsgId) {
......@@ -1284,7 +1300,8 @@ public class Queue extends Destination implements QueueMBean {
messages.clear();
nbExpirations = 0;
}
replyToTopic(new AdminReply(true, null), replyTo, requestMsgId, replyMsgId);
if (replyTo != null)
replyToTopic(new AdminReply(true, null), replyTo, requestMsgId, replyMsgId);
}
/**
......
......@@ -180,4 +180,9 @@ public interface QueueMBean extends DestinationMBean {
boolean isPause();
void setPause(boolean pause);
/**
* Removes all pending messages.
*/
public void clear();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment