Closed undernorthernsky closed 5 years ago
And if you don't run in an OOM, you will sooner or later run in an StackOverflowException. What I could do, is to create an "AsyncMessageProcessor" that handles the messages asynchronously (so dispatching happens in a separate thread). This would avoid the stack overflow and the OOM because the stack would always be fixed sized. I would do this for the current HEAD which targets JDK 8. Does that sound reasonable to you?
Yes, switching to async would certainly solve the issue. Though that would require some kind of persistence to avoid dropping messages when the application shuts down? Which effectively duplicates DirectoryResender?
I am not sure if this issue is really relevant for most users; the core problem is "sync" resending, which might be an edge case.
The way we are currently using the lib requires sync (re-)sending; so for the moment we are going forward with the modified MessageProcessor.
So maybe you don't need to "fix" anything; possibly document the problem w.r.t. ImmediateResender (or even deprecate it). I mainly wanted some feedback, feel free to close as wontfix :-)
Well, I don't think it requires a persistence. If you're currently shutting down your application and there is something to resend, it might also be lost (e.g. when run in a daemon thread).
If there is an async message processor it simply avoids stacking the stacktraces but it also does not throw the exceptions directly. You may wanna have a look at the AsyncMessageProcessor
class I just committed.
I'll play with it next week. Just from reading there seem to be a few problems:
executeAction
in the Runnable fails once, isn't that entry gone from the queue?In my mind pushing mutable object (aMsg, aOptions) to another thread and returning early is questionable; for example calling aMsg.getMDN()
after sending won't work reliably even for sync MDNs.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This is similar to #16; the scenario is repeated failure to send a message.
The final exception isn't too interesting; but anyway:
The problem seems to be the recursive chain of calls:
AS2SenderModule -> DefaultMessageProcessor -> ResenderModule -> DefaultMessageProcessor -> AS2SenderModule -> ...
.Each time the exception is caught in AS2SenderModule, wrapped, stashed and rethrown if the next attempt (
doResend
) fails again; then caught again inDefaultMessageProcessor
and rethrown as a ProcessorException.This is the length of
getStackAsString()
inProcessorException::_getMessage
:I don't see a "good" way to avoid the geometric increase; for our usage the following works, but aborting early might not be correct in the general case.