softwaremill / softwaremill/elasticmq

Unable to acknowledge message in custom error handler

Open
#120 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
2.9k
Forks
203
Avg merge
1d 7h
Merged PRs (30d)
6

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with QueueMessageListener.java and CustomErrorHandler, then inspect the DefaultMessageListenerContainer configuration using CLIENT_ACKNOWLEDGE and reproduce the missing acknowledgement with the logged receipt handle. Done means identifying the relevant acknowledgement behavior or configuration and documenting a confirmed fix or limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, java
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.