Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to acknowledge message in custom error handler #120

Open
sumitsabhnani opened this issue Oct 25, 2017 · 4 comments
Open

Unable to acknowledge message in custom error handler #120

sumitsabhnani opened this issue Oct 25, 2017 · 4 comments

Comments

@sumitsabhnani
Copy link

Hello.

I have created a custom error handler to handle application exceptions and do logging or retrying based on the Exception type.
Below is the sample code what m trying to do:

//QueueMessageListener.java
`public void onMessage(Message message) {
try {
TextMessage textMessage = (TextMessage) message;

        Event event = toEvent(textMessage);

        processor.process(event);
    } catch (Exception ex) {
        throw new CustomException(message, ex);
    }

}`

//`
public class CustomErrorHandler implements ErrorHandler {

@Override
public void handleError(Throwable throwable) {
    if(throwable instanceof CustomException) {
        CustomException exception = (CustomException) throwable;
        Message message = exception.getSqsMessage();
        message.acknowledge();
    }

}
}`

//Configuration
DefaultMessageListenerContainer dmlc = new DefaultMessageListenerContainer(); dmlc.setConcurrency("1-5"); dmlc.setConnectionFactory(sqsConnectionFactory); dmlc.setDestinationName(queueProperties.getName()); dmlc.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE); dmlc.setMessageListener(messageListener); dmlc.setErrorHandler(customErrorHandler);

Issue here is, when the custom error handler executes handleError it does not acknowledges the message and message stay in the queue forever... I can see below message in logs
WARN com.amazon.sqs.javamessaging.acknowledge.RangedAcknowledger - SQSMessageID: 46a04726-8e09-48ce-947f-95cb2e8ae9a0 with SQSMessageReceiptHandle: 46a04726-8e09-48ce-947f-95cb2e8ae9a0#44b60e0f-2e02-42f1-a5c1-1db9a458b022 does not exist.

m I missing some configuration?

Regards,
Sumit

@adamw
Copy link
Member

adamw commented Nov 3, 2017

I haven't used the JMS interface so hard to say. Maybe you could create a small project which replicates the error?

@KevinJCross
Copy link

Im currently having a look into this because I am experiencing some problems like this.
With a little bit of investigation it uses the batchdelete operations.
Is this supported in elasticMq ?

@sumitsabhnani
Copy link
Author

@adamw sorry i missed the comment.... will try to build something and share....
@kevlarC i didn't get your question.. if you are talking about custom error handler thn yes it is supported and works fine (except message acknowledgement)... i m not very sure if exception handler should even be aware about message but since i came across this issue so thought of posting it....

@ghost
Copy link

ghost commented Nov 29, 2017

hi, It turns out there is something going on but Im not sure exactly what it is.
When we are running using the normal java jms from the aws SDK we quite often get

10:23:45.151 [DefaultMessageListenerContainer-3] WARN  c.a.s.j.a.RangedAcknowledger - SQSMessageID: 6a2c160c-03da-40e0-aae1-acb83b911f3b with SQSMessageReceiptHandle: 6a2c160c-03da-40e0-aae1-acb83b911f3b#1cabf4af-65cc-4d6b-95fe-b3c65ac64c87 does not exist.

Output from the sdk ... Since there is very little in the form of introspection for the queues I dont really know if they have or have not been removed from the queue. It uses a batch delete with the last receipt.

None the less I've got a workaround for our tests that we are using although I not sure its this exact problem. I investigated it while trying to find a fix and it seems there is something not quite right here.

I think we could make a test that sends a large amount of messages and links into the aws jms to receive and acknowledges them as quickly as possible then this warning should appear.

It may even be an incorrect log from the SDK.... although you would hope not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants