*/
protected void denyRequest(AgentId from, DenyRequest not) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "Queue.DenyRequest(" + from + ',' + not + ')');
Enumeration ids = not.getIds();
String msgId;
Message message;
AgentId consId;
int consCtx;
DMQManager dmqManager = null;
if (! ids.hasMoreElements()) {
// If the deny request is empty, the denying is a contextual one: it
// requests the denying of all the messages consumed by the denier in
// the denying context:
for (Iterator entries = deliveredMsgs.entrySet().iterator(); entries.hasNext();) {
// Browsing the delivered messages:
Map.Entry entry = (Map.Entry) entries.next();
msgId = (String) entry.getKey();
message = (Message) entry.getValue();
consId = (AgentId) consumers.get(msgId);
consCtx = ((Integer) contexts.get(msgId)).intValue();
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, " -> deny msg " + msgId + "(consId = " + consId + ')');
// If the current message has been consumed by the denier in the same
// context: denying it.
if (consId.equals(from) && consCtx == not.getClientContext()) {
// state change, so save.
setSave();
consumers.remove(msgId);
contexts.remove(msgId);
entries.remove();
message.setRedelivered();
// If message considered as undeliverable, adding
// it to the list of dead messages:
if (isUndeliverable(message)) {
message.delete();
if (dmqManager == null)
dmqManager = new DMQManager(dmqId, getId());
nbMsgsSentToDMQSinceCreation++;
dmqManager.addDeadMessage(message.getFullMessage(), MessageErrorConstants.UNDELIVERABLE);
} else {
// Else, putting the message back into the deliverables list:
storeMessageHeader(message);
}
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "Message " + msgId + " denied.");
}
}
}
// For a non empty request, browsing the denied messages:
for (ids = not.getIds(); ids.hasMoreElements();) {
msgId = (String) ids.nextElement();
message = (Message) deliveredMsgs.remove(msgId);
// Message may have already been denied. For example, a proxy may deny
// a message twice, first when detecting a connection failure - and
// in that case it sends a contextual denying -, then when receiving