The SIF® Zone
creating, assimilating, and promoting excellence in SIF® agent development

Error when throwing exception from OnEvent -- is this a bug or a feature??

rated by 0 users
Not Answered This post has 0 verified answers | 7 Replies | 3 Followers

Top 10 Contributor
44 Posts
Points 800
Miriam Fein-Cole posted on 12-08-2009 11:52

My OnEvent handler for StudentPersonal is throwing the following exception:

                    throw new ADKTransportException ("Unable to delete student", zone);

My understanding was that if you throw an ADKTransportException, the ZIS will keep the message in the agent's queue, which is what I would like.  But I'm getting the errors below.  Is this a bug in the ADK or am I not understanding this correctly? 

Also, I see that the SIFWorks ZIS allows one to turn off the "Retry message when acknowledged with a Transport Error " flag.  Is it typical that a ZIS would allow this setting to be configurable?  In other words, does that mean I can't count on the message remaining in my queue if I throw a Transport exception?  If that's the case, should I explicitly query for the specific object if an error occurs adding or updating an object so that am ensured of getting another message?  Please advise on the best way to handle errors.

Thanks,

Miriam

 

2009-12-08 14:38:21,437 DEBUG [ADK.Agent$SapphireZone] EvDisp done waiting for acknowlegement code
2009-12-08 14:38:21,437 DEBUG [ADK.Agent$SapphireZone] EvDisp received an exception instead of an acknowledgement code
2009-12-08 14:38:21,437 ERROR [ADK.Agent$SapphireZone] Dispatching SIF_Event: Unable to delete student
Dispatching SIF_Event: Unable to delete student
    at com.edustructures.sifworks.impl.MessageDispatcher$EvDisp.waitForAckCode(MessageDispatcher.java:2175)
    at com.edustructures.sifworks.impl.MessageDispatcher$EvDisp.dispatch(MessageDispatcher.java:2236)
    at com.edustructures.sifworks.impl.MessageDispatcher.dispatchEvent(MessageDispatcher.java:695)
    at com.edustructures.sifworks.impl.MessageDispatcher.dispatch(MessageDispatcher.java:463)
    at com.edustructures.sifworks.impl.MessageDispatcher.pull(MessageDispatcher.java:1881)
    at com.edustructures.sifworks.impl.HttpPullProtocolHandler.run(HttpPullProtocolHandler.java:119)
    at java.lang.Thread.run(Unknown Source)
Caused by: Unable to delete student
    at StudentPersonalHandler.onEvent(StudentPersonalHandler.java:328)
    at com.edustructures.sifworks.impl.MessageDispatcher$EvDisp.run(MessageDispatcher.java:2264)
    ... 1 more
2009-12-08 14:38:21,437 ERROR [ADK.Agent$SapphireZone] ADKException in Subscriber.onEvent message handler for SIF_Event
Dispatching SIF_Event: Unable to delete student
    at com.edustructures.sifworks.impl.MessageDispatcher$EvDisp.waitForAckCode(MessageDispatcher.java:2175)
    at com.edustructures.sifworks.impl.MessageDispatcher$EvDisp.dispatch(MessageDispatcher.java:2236)
    at com.edustructures.sifworks.impl.MessageDispatcher.dispatchEvent(MessageDispatcher.java:695)
    at com.edustructures.sifworks.impl.MessageDispatcher.dispatch(MessageDispatcher.java:463)
    at com.edustructures.sifworks.impl.MessageDispatcher.pull(MessageDispatcher.java:1881)
    at com.edustructures.sifworks.impl.HttpPullProtocolHandler.run(HttpPullProtocolHandler.java:119)
    at java.lang.Thread.run(Unknown Source)
Caused by: Unable to delete student
    at StudentPersonalHandler.onEvent(StudentPersonalHandler.java:328)
    at com.edustructures.sifworks.impl.MessageDispatcher$EvDisp.run(MessageDispatcher.java:2264)
    ... 1 more
2009-12-08 14:38:21,453 ERROR [ADK.Agent$SapphireZone] Translated to a SIFException
[Category=12; Code=1] ADKException in Subscriber.onEvent message handler for SIF_Event. Dispatching SIF_Event: Unable to delete student
    at com.edustructures.sifworks.impl.MessageDispatcher$EvDisp.waitForAckCode(MessageDispatcher.java:2175)
    at com.edustructures.sifworks.impl.MessageDispatcher$EvDisp.dispatch(MessageDispatcher.java:2236)
    at com.edustructures.sifworks.impl.MessageDispatcher.dispatchEvent(MessageDispatcher.java:695)
    at com.edustructures.sifworks.impl.MessageDispatcher.dispatch(MessageDispatcher.java:463)
    at com.edustructures.sifworks.impl.MessageDispatcher.pull(MessageDispatcher.java:1881)
    at com.edustructures.sifworks.impl.HttpPullProtocolHandler.run(HttpPullProtocolHandler.java:119)
    at java.lang.Thread.run(Unknown Source)
Caused by: Unable to delete student
    at StudentPersonalHandler.onEvent(StudentPersonalHandler.java:328)
    at com.edustructures.sifworks.impl.MessageDispatcher$EvDisp.run(MessageDispatcher.java:2264)
    ... 1 more

    at com.edustructures.sifworks.impl.MessageDispatcher.logAndThrowSIFException(MessageDispatcher.java:2371)
    at com.edustructures.sifworks.impl.MessageDispatcher.dispatch(MessageDispatcher.java:514)
    at com.edustructures.sifworks.impl.MessageDispatcher.pull(MessageDispatcher.java:1881)
    at com.edustructures.sifworks.impl.HttpPullProtocolHandler.run(HttpPullProtocolHandler.java:119)
    at java.lang.Thread.run(Unknown Source)
2009-12-08 14:38:21,453 DEBUG [ADK.Agent$SapphireZone] Handling exception by creating a SIF_Error
[Category=12; Code=1] ADKException in Subscriber.onEvent message handler for SIF_Event. Dispatching SIF_Event: Unable to delete student
    at com.edustructures.sifworks.impl.MessageDispatcher$EvDisp.waitForAckCode(MessageDispatcher.java:2175)
    at com.edustructures.sifworks.impl.MessageDispatcher$EvDisp.dispatch(MessageDispatcher.java:2236)
    at com.edustructures.sifworks.impl.MessageDispatcher.dispatchEvent(MessageDispatcher.java:695)
    at com.edustructures.sifworks.impl.MessageDispatcher.dispatch(MessageDispatcher.java:463)
    at com.edustructures.sifworks.impl.MessageDispatcher.pull(MessageDispatcher.java:1881)
    at com.edustructures.sifworks.impl.HttpPullProtocolHandler.run(HttpPullProtocolHandler.java:119)
    at java.lang.Thread.run(Unknown Source)
Caused by: Unable to delete student
    at StudentPersonalHandler.onEvent(StudentPersonalHandler.java:328)
    at com.edustructures.sifworks.impl.MessageDispatcher$EvDisp.run(MessageDispatcher.java:2264)
    ... 1 more

    at com.edustructures.sifworks.impl.MessageDispatcher.logAndThrowSIFException(MessageDispatcher.java:2371)
    at com.edustructures.sifworks.impl.MessageDispatcher.dispatch(MessageDispatcher.java:514)
    at com.edustructures.sifworks.impl.MessageDispatcher.pull(MessageDispatcher.java:1881)
    at com.edustructures.sifworks.impl.HttpPullProtocolHandler.run(HttpPullProtocolHandler.java:119)
    at java.lang.Thread.run(Unknown Source)
2009-12-08 14:38:21,453 DEBUG [ADK.Agent$SapphireZone] Send SIF_Ack (Status = none; Errors = 1)
2009-12-08 14:38:21,453 DEBUG [ADK.Agent$SapphireZone] [Category=12; Code=1] ADKException in Subscriber.onEvent message handler for SIF_Event: Dispatching SIF_Event: Unable to delete student
    at com.edustructures.sifworks.impl.MessageDispatcher$EvDisp.waitForAckCode(MessageDispatcher.java:2175)
    at com.edustructures.sifworks.impl.MessageDispatcher$EvDisp.dispatch(MessageDispatcher.java:2236)
    at com.edustructures.sifworks.impl.MessageDispatcher.dispatchEvent(MessageDispatcher.java:695)
    at com.edustructures.sifworks.impl.MessageDispatcher.dispatch(MessageDispatcher.java:463)
    at com.edustructures.sifworks.impl.MessageDispatcher.pull(MessageDispatcher.java:1881)
    at com.edustructures.sifworks.impl.HttpPullProtocolHandler.run(HttpPullProtocolHandler.java:119)
    at java.lang.Thread.run(Unknown Source)
Caused by: Unable to delete student
    at StudentPersonalHandler.onEvent(StudentPersonalHandler.java:328)
    at com.edustructures.sifworks.impl.MessageDispatcher$EvDisp.run(MessageDispatcher.java:2264)
    ... 1 more

  • | Post Points: 25

All Replies

Top 10 Contributor
72 Posts
Points 1,495

Hi,

Just to clarify, in your onEvent handler being more than once for the same event after throwing the exception.  I think the log is a bit misleading in that things are being written to the ERROR level that are really more of an INFO kind of statement.  The ZIS should resend the event unless it is configure to not do so.

  • | Post Points: 45
Top 10 Contributor
44 Posts
Points 800

Hi Jonathan,

Thanks for the response.  I am only throwing the exception once. I agree that the log statements can be misleading, but nonetheless clearly there is an error occurring in com.edustructures.sifworks.impl.MessageDispatcher$EvDisp.waitForAckCode and the message does not remain in my queue after I throw ADKTransportException.  Have you successfully thrown this error and seen messages retained in your queue?

Thanks,

Miriam

  • | Post Points: 25
Top 10 Contributor
72 Posts
Points 1,495

Hi Miriam,

I believe what the log is showing is your exception being sent up the stack sometimes to DEBUG output level and sometimes to ERROR.  The last entry 'Send SIF_Ack (Status = none; Errors = 1)' is where the ADK sends an Error Ack back to the ZIS - the error being your exception.  Can you see the Error Ack in the ZIS log?

You may want to try using a ADKException instead of a ADKTransportException as that exception is meant for internal 'plumbing-type' exceptions and not business logic problems.

Let me know if this helps,

Jonathan

  • | Post Points: 5
Top 10 Contributor
215 Posts
Points 5,055

ADKTransportException is used internally by the ADK and it makes no difference if an Agent developer throws it or not. The ADK internally treats it just like any other exception that might get thrown.

The ADK always catches any exceptions that are thrown and translates them into the appropriate SIF_Ack to return to the ZIS. A normal SIF_Ack, whether it indicates a SUCCESS or ERROR case will always remove the affected message from the agent's queue. This is by design, both in the ADK and in the SIF Infrastructure protocol.

There are certain cases where you may wish to keep the message you are processing in the ZIS queue. For example, if you cannot get a connection to your database, you may wish to keep the message in your queue and have the ZIS try again later. If you wish the message you are processing to stay in the ZIS queue, create an ADKException, call .setRetry( true ), and then throw it. In that case, the ADK will recognize it and send the appropriate SIF_Ack status code to keep the message in your queue.

Andrew Elmhorst
Chief Architect
Edustructures 

  • | Post Points: 25
Top 10 Contributor
44 Posts
Points 800

Thanks for your input.  I did what you suggest and it does the trick!  Is this a reliable means of ensuring that the message stays in my agent queue for all ZIS's?  It's exactly the case you mention, where I cannot get a connection to our database, that I want to do this.  In this case I will put the zone to sleep and keep retrying my connection until successful, at which point I'll wake up the zone and attempt to re-process the message.

Thanks,

Miriam

  • | Post Points: 25
Top 10 Contributor
215 Posts
Points 5,055

Yes, this will work for all ZIS's that are certified by SIF because the mechanism the ADK is using is a required behavior of the spec. The mechanism you are using for dealing with this case is a great design.

Cheers,

Andrew Elmhorst
Chief Architect
Edustructures 

  • | Post Points: 25
Top 10 Contributor
44 Posts
Points 800

Great!  Thanks so much for your help.

Miriam

  • | Post Points: 5
Page 1 of 1 (8 items) | RSS
Copyright ©2006-2009 sifzone.com
Sponsored by Edustructures
We Connect the Systems that Power Education
 
SIF and Schools Interoperability Framework are trademarks of the Schools Interoperability Framework Association.