*/
private void reactToClientRequest(int key, ProducerMessages req) throws RequestException {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "UserAgent.reactToClientRequest(" + key + ',' + req + ')');
AgentId destId = AgentId.fromString(req.getTarget());
if (destId == null)
throw new RequestException("Request to an undefined destination (null).");
ProducerMessages pm = req;
if (interceptorsIN != null && !interceptorsIN.isEmpty()) {
org.objectweb.joram.shared.messages.Message m = null;
Vector msgs = ((ProducerMessages) req).getMessages();
Vector newMsgs = new Vector();
for (int i = 0; i < msgs.size(); i++) {
m = (org.objectweb.joram.shared.messages.Message) msgs.elementAt(i);
Iterator it = interceptorsIN.iterator();
while (it.hasNext()) {
MessageInterceptor interceptor = (MessageInterceptor) it.next();
if (!interceptor.handle(m)) {
m = null;
break;
}
}
if (m != null) {
newMsgs.add(m);
} else {
// send the originals messages to the user DMQ.
sendToDMQ((org.objectweb.joram.shared.messages.Message) msgs.elementAt(i), MessageErrorConstants.INTERCEPTORS);
}
}
// no message to send. Send reply to the producer.
if (newMsgs.size() == 0 && !msgs.isEmpty()) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "UserAgent.reactToClientRequest : no message to send.");
if (destId.getTo() == getId().getTo() && !pm.getAsyncSend()) {
// send producer reply
sendNot(getId(), new SendReplyNot(key, pm.getRequestId()));
}
return;
}
//update producer message.
((ProducerMessages) pm).setMessages(newMsgs);
pm = req;
}
ClientMessages not = new ClientMessages(key, pm.getRequestId(), pm.getMessages());
setDmq(not);
if (destId.getTo() == getId().getTo()) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, " -> local sending");
not.setPersistent(false);
not.setExpiration(0L);
if (pm.getAsyncSend()) {