SMTP connections (CardSchema) while in exception state

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

SMTP connections (CardSchema) while in exception state

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:18 pm

by johnmunro >> Sat, 4 Jan 2003 14:16:24 GMT

I am trying to add a feature to our exception handler which automatically emails an exception report to a designated address. Using this, we wouldn't need to rely on users writing down exception details or sysadmins mailing us exception logs - we would be getting the information straight from the horse's mouth.

The SMTP connection requires a notification to be set up so that the connection object receives an event when the message has been sent (or has failed for whatever reason). In the event handler for this notification, the connection object is to delete itself; the exception handler then detects that the connection object has been deleted and continues processing from there. This is all straight out of the CardSchema SMTP documentation.

The problem is that the notification is never received, so the connection is never deleted, so the exception handler never continues processing.

The notification stuff seems to work fine when the email method is called from a jadescript, and the only thing I can see that is different is that the process is in exception state.

Does anyone know whether there is some sort of restriction on notifications when in exception state? Does anyone have an idea how to get around it?

I actually do have a workaround (the exception handler waits for Connection.state = Disconnected), but it leaves me with the feeling that it won't always work... and if we start using these emails as a part of our support strategy, we'll need to be confident that they're being sent whenever an exception is raised...

John Munro

---
Synergist Limited - Home of FileVision
The Bioscience Innovation Centre
Cowley Road, Cambridge, UK
CB4 0DS

Telephone: +44 (0) 1223 478200
Fax: +44 (0) 1223 477969
Email: john.munro@filevision.com
Web: http://www.filevision.com

The contents of this communication are confidential and are only intended to be read by the addressee. We apologize if you receive this communication in error and ask that you contact Synergist Limited immediately to arrange for its return. The use of any information contained in this communication by an unauthorized person is strictly prohibited. Synergist Limited cannot accept responsibility for the accuracy or completeness of this communication as it is being transmitted over a public network. If you suspect this message may have been intercepted or amended, please inform Synergist Limited.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: SMTP connections (CardSchema) while in exception state

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:18 pm

by allistar >> Sat, 4 Jan 2003 19:15:03 GMT

Hi John,
We have developed our own SMTP email sender in Jade (which is similar in nature to the CardSchema one, in the sense that it is an asynchronous state machine).

I noted exactly the same problem as you (when in exception state the notification never quite seems to get delivered). I'm not sure what the official Jade position on message processing while in exception state is, but here is how I fixed this:

Firstly I have allowed emails to be send either asynchronously or synchronously (i.e. blocking, so the method doesn't return until the email has been send). I found that sending synchronously in certain situations was much easier to tie into things like exception handlers. Here is the code for that method:

sendEmailSynchronous():String updating, protected;
//Allistar, 23 December 2002
//
constants
TimeOut = 5 * 60 * 1000; //5 minutes
vars
start: Integer;
timedOut: Boolean;begin

hasSendingCompleted := false;
start := app.clock();
//register a notification on this object
beginNotification(mySMTPConnection, mySMTPConnection.Event_Compl etion, Response_Cancel, 0);
mySMTPConnection.send();
while (not hasSendingCompleted) do
app.doWindowEvents(200);
if (app.clock() - start > TimeOut) then
timedOut := true;
break;
endif;
endwhile;
if (timedOut) then
return "The email did not send as sending it took too long"; else
return synchronousError;
endif;
end;

(I have translated this as best as I can into the way CardSchema does it, my implementation differs slightly):

In the CnSmtpState::setCompleted method at the bottom I manually call the "userNotification" method on the object that registered for the notification. Inside the userNotification method I make sure that the notification only gets handled once (as whn you are not in exception state the actual notification will get received).

This works flawlessly, although it may be considered a bit hacky (having to manually invoke the "userNotification" method on an object).

Hopefully this helps, it does require you to change a CardSchema method, and I'm not sure of the possibility (or legality) of doing so.

An alternative is to send the email after the exception has been processed. You can detect if an exception has happened in the method that arms the exception handler by making the signature of the exception handler:

exceptionHandler(ex: Exeption; exceptionHappened: Boolean output):Integer;

then in the epliog of the method that armed the exception handler you can go:

epilog
if (exeptionHappened) then
sendEmail();
endif;
end;

This will require you to store appropriate information off the exception object onto some transient object (as in the epilog in the above example you no longer have a handle to an exception object). Oh, and this method may be difficult if the exception handler is a global one.

Hopefully to can make some use of these 2 suggestions.

Regards,
Allistar.

------------------------------------------------------------------
Allistar Melville
Software Developer, Analyst allistar@silvermoon.co.nz
Auckland, NEW ZEALAND

Silvermoon Software
Specialising in JADE development and consulting
Visit us at: http://www.silvermoon.co.nz ------------------------------------------------------------------

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: SMTP connections (CardSchema) while in exception state

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:18 pm

by jadesupport >> Mon, 6 Jan 2003 19:55:25 GMT

John,

In JADE notifications are specifically not delivered to a process that is in exception state.

Once the process clears exception state, the pending notifications will then be delivered.

Thanks,
Brian Johnstone,
JADE Support.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: SMTP connections (CardSchema) while in exception state

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:18 pm

by johnmunro >> Tue, 7 Jan 2003 11:54:02 GMT
In JADE notifications are specifically not delivered to a process that is in exception state.

Does this include timer messages?

John Munro

---
Synergist Limited - Home of FileVision
The Bioscience Innovation Centre
Cowley Road, Cambridge, UK
CB4 0DS

Telephone: +44 (0) 1223 478200
Fax: +44 (0) 1223 477969
Email: john.munro@filevision.com
Web: http://www.filevision.com

The contents of this communication are confidential and are only intended to be read by the addressee. We apologize if you receive this communication in error and ask that you contact Synergist Limited immediately to arrange for its return. The use of any information contained in this communication by an unauthorized person is strictly prohibited. Synergist Limited cannot accept responsibility for the accuracy or completeness of this communication as it is being transmitted over a public network. If you suspect this message may have been intercepted or amended, please inform Synergist Limited.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: SMTP connections (CardSchema) while in exception state

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:18 pm

by cnwjadesupport >> Tue, 7 Jan 2003 21:45:48 GMT
Does this include timer messages?

Yes. Timers will also not 'fire' until the process clears exception state.
A one-shot timer will be delivered when the process eventually clears exception state.

A continous timer will discard repeat occurrences if the process is in exception state for a duration longer than the timer duration so you will not get a "flood" of timer events for a short continous timer after an extended period of exception state for a given process.

Thanks,
Brian Johnstone,
JADE Support.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: SMTP connections (CardSchema) while in exception state

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:18 pm

by ConcrdDev >> Wed, 15 Jan 2003 22:32:48 GMT

Hi John,

Using Cardschema we email our client exception logs back to our office - very successful - Often we are ringing our client back to get more details of what they were doing, or letting them know the fix is underway before they have registered that a problem exists. We have also been able to confront users to ask them about exceptions that have occurred - even though they deny an exception has occurred !!!

If you still need some help let me know by email, and I'l get a programmer to gather some methods together

Peter Gallagher
Gallagher Business Systems
peter@discoverconcord.com

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: SMTP connections (CardSchema) while in exception state

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:18 pm

by johnmunro >> Thu, 16 Jan 2003 17:15:15 GMT
If you still need some help let me know by email, and I'l get a programmer to gather some methods together

No thanks, sorted it in the end, it turns out that CnSmtpConnection has a property (completed) which is set when the mail is sent, so we can ignore the notifications and it works synchronously.

John Munro

---
Synergist Limited - Home of FileVision
The Bioscience Innovation Centre
Cowley Road, Cambridge, UK
CB4 0DS

Telephone: +44 (0) 1223 478200
Fax: +44 (0) 1223 477969
Email: john.munro@filevision.com
Web: http://www.filevision.com

The contents of this communication are confidential and are only intended to be read by the addressee. We apologize if you receive this communication in error and ask that you contact Synergist Limited immediately to arrange for its return. The use of any information contained in this communication by an unauthorized person is strictly prohibited. Synergist Limited cannot accept responsibility for the accuracy or completeness of this communication as it is being transmitted over a public network. If you suspect this message may have been intercepted or amended, please inform Synergist Limited.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 19 guests

cron