tirsen / activemessaging

ActiveMessaging is an attempt to bring the simplicity and elegance of Rails development to the world of messaging. Messaging, (or event-driven architecture) is widely used for enterprise integration, with frameworks such as Java's JMS, and products such as ActiveMQ, Tibco, IBM MQSeries etc
0 stars 0 forks source link

should not delete message when on_message raises an exception (asqs adapter) #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. when using asqs adapter
2. on_message method raises exception
3. message deleted

What is the expected output? What do you see instead?
message was deleted, but it should not if any exception

What version of the product are you using? On what operating system?
VERSION = "0.5" in activemessaging.rb
checked out from repository on 8 oct

Please provide any additional information below.

Original issue reported on code.google.com by mainpl...@gmail.com on 11 Oct 2007 at 11:11

GoogleCodeExporter commented 9 years ago
I don't think it is as simple as every time there is an exception in 
on_message, it
should not delete the message.

At the point where on_message is called, the message has in fact gotten to its
processing destination - so you could argue that delivery is successful, it is 
now up
to the on_message or on_error logic to decide if the message should be deleted 
or not
- but activemessaging itself should probably not behave always one way or the 
other.

If on_message is called, and raises an exception, it means the message was:
1) received
2) potentially partially processed

...which means while some people might want to see that message show up again, 
it may
also be that it will be a problem if it gets processed again (e.g. perhaps the
processor finished everything except sending an email at the end, and redoing 
the
rest of the processing would be bad).  There is no safe assumption of on_message
being a single transaction, nor of it being idempotent, so always retrying by 
not
deleting the message could be worse than deleting it.

Also, it could well mean that getting the message again will throw the same 
error
again (say there is a logic error which certain data in the message will always 
cause
to raise an exception), which means a message could potentially never be 
deleted.

So I think the answer is that this should be conditional in some way. If you 
read
through the activemessaging list there is a discussion of the same problem, 
including
suggestions such as having a specific exception class cause the message to be 
left
undeleted or deleted, or a return value from on_message.

Original comment by kooks...@gmail.com on 11 Oct 2007 at 1:16

GoogleCodeExporter commented 9 years ago
There is now a special exception that wil cause the message to not be deleted:
ActiveMessaging::AbortMessageException

If you raise that, then the message will not be deleted, but instead will do 
nothing,
so that the visibility timeout will let the message get retried later.

Note: you can get into an infinite loop condition here - I have no check to see 
how
many times a message comes in and throws an error, so you are somewhat at your 
own
risk using this until more work gets done to fix this.  I am considering keeping
track of messages by id that have been seen before so that you can have a retry 
count
- will probably add that unless I think of something better, or someone gives 
me a
good suggestion.

Note also that support for this exception, AbortMessageException, ahas been 
added not
only to SQS, but the stomp and reliable messaging adapters too.

Original comment by kooks...@gmail.com on 4 Feb 2008 at 4:55