[
http://jira.jboss.com/jira/browse/JBESB-193?page=comments#action_12345026 ]
Tom Fennelly commented on JBESB-193:
------------------------------------
Just wanted to add another note to this issue, otherwise I'll forget.
One possible workaround for people that encounter an issue with the current notification
model may be (depending on the issue of course :-) ) to use one of the Message containers
(e.g. Body, Attachment) to attach the notification data to the message such that it can be
retrieved again from within the "getOk/ErrorNotification" methods.
Example:
public class MyMessageActionProcessor implements ActionProcessor {
public Message process(Message message) throws ActionProcessingException {
// ... Do some processing on the message...
// ... encouter an error...
Object specialMandatoryAttachment =
message.getAttachment().get("specialMandatoryAttachment");
if(specialMandatoryAttachment == null) {
// ... Exit with exception, setting an error notification to be picked up by the
getErrorNotification call) ...
setNotification(message, "... Special Attachment Object required by
MyMessageActionProcessor not set on Message XYZ ... ");
message.getFault().setCode(URI.create("fault://MyMessageActionProcessor?messageid=XYZ"));
message.getFault().setReason("A44197");
throw new ActionProcessingException("Special Attachment Object required by
MyMessageActionProcessor not set on Message XYZ");
}
// ... Do some more processing on the message ...
// ... Exit without throwing an exception (can optionally set a notification to be
picked up by the getOkNotification call) ...
setNotification(message, "... Message XYZ processed successfully ... ");
return message;
}
public Serializable getOkNotification(Message message) {
return getNotification(message);
}
public Serializable getErrorNotification(Message message) {
return getNotification(message);
}
private void setNotification(Message message, Serializable notification) {
message.getAttachment().put(NOTIFICATION_KEY, notification);
}
private Serializable getNotification(Message message) {
return (Serializable) message.getAttachment().get(NOTIFICATION_KEY);
}
private static String NOTIFICATION_KEY = "PROCESSING_NOTIFICATION";
}
Note that a solution like this will not work with any of the Abstract*Processor
implementions that have blocked access to the Message (e.g AbstractFileAction).
Also note, this is just 1 possible solution. I'm sure there are others!!
Need support for notification generatoin from within
ActionProcessor.process method
-----------------------------------------------------------------------------------
Key: JBESB-193
URL:
http://jira.jboss.com/jira/browse/JBESB-193
Project: JBoss ESB
Issue Type: Task
Security Level: Public(Everyone can see)
Affects Versions: 4.1
Reporter: Tom Fennelly
Assigned To: Mark Little
Fix For: 4.1
In version 4.0, the Action Processing pipeline management code raises notifications in
response to an exception from the ActionProcessor.process method. The pipeline managemnt
code calls the getOkNotification (no exception) or getErrorNotification (exception) to get
the notification message.
For many reasons, this is a very flawed model. Notifications should be raised from
within the process method by means of attaching the notifications (error or otherwise) to
the message (the mechanism is a design issue). Once the process method returns, the
pipline processing management code can check the message for notifications. If there are
errors, it can/should (?) abort the message processing, send the error notification (by
whatever notification options are configured on the listener) and signal the failure to
the calling process (by whatever failure config is configured on the listener).
The getOk and getErro methods can then be removed.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira