* This method is used internally by the platform in order
* to notify the sender of a message that a failure was reported by
* the Message Transport Service.
*/
public void notifyFailureToSender(GenericMessage msg, AID receiver, InternalError ie) {
ACLMessage acl = msg.getACLMessage();
if (acl == null) {
// ACLMessage can be null in case we get a failure delivering a message coming from an external platform (received by a local MTP).
// In this case in fact the message is encoded. Try to decode it so that a suitable FAILURE response can be sent back.
// If the payload is mangled in some way (e.g. encrypted) decoding will fail and no suitable FAILURE response will be sent
try {
acl = ((IncomingEncodingFilter) encInFilter).decodeMessage(msg.getEnvelope(), msg.getPayload());
acl.setEnvelope(msg.getEnvelope());
msg.setACLMessage(acl);
}
catch (Exception e) {
// Just do nothing
e.printStackTrace();
}
}
if (acl == null) {
myLogger.log(Logger.WARNING, "Cannot notify failure to sender: GenericMessage contains no ACLMessage");
return;
}
if ("true".equals(acl.getUserDefinedParameter(ACLMessage.IGNORE_FAILURE))) {
// Ignore the failure
return;
}
GenericCommand cmd = new GenericCommand(MessagingSlice.NOTIFY_FAILURE, MessagingSlice.NAME, null);