0

I have a clustered java hibernate application (with 2 nodes) listening to an AWS SQS FIFO. The messages in the queue contains a specific MessageGroupId. When java listener is reading the messages, i can see that the messages with same MessageGroupId are going to multiple listeners. This is causing issues at the hibernate side where one cluster node is overwriting the data set by the other node. Any suggestions on how to address the queue issue?

Ann

Ann
  • 217
  • 1
  • 9
  • Per the documentation: "When you receive a message with a message group ID, no more messages for the same message group ID are returned unless you delete the message or it becomes visible." – jarmod Sep 15 '22 at 17:31

1 Answers1

0

Message group ID is for labelling messages, not for routing them to specific consumers.

I'd suggest reading the documentation on FIFO queues:

You can't request to receive messages with a specific message group ID.

When receiving messages from a FIFO queue with multiple message group IDs, Amazon SQS first attempts to return as many messages with the same message group ID as possible. This allows other consumers to process messages with a different message group ID. When you receive a message with a message group ID, no more messages for the same message group ID are returned unless you delete the message or it becomes visible.

Unfortunately you're going to have to rethink your approach. I'd need more information to make a real recommendation, but SNS is typically better suited for a "one to many" relationship.