Skip to content

Use microprofile reactive-messaging for SQS and add pattern resilience for messaging#220

Draft
matheusandre1 wants to merge 2 commits intomcruzdev:mainfrom
matheusandre1:issue46
Draft

Use microprofile reactive-messaging for SQS and add pattern resilience for messaging#220
matheusandre1 wants to merge 2 commits intomcruzdev:mainfrom
matheusandre1:issue46

Conversation

@matheusandre1
Copy link
Copy Markdown
Contributor

@matheusandre1 matheusandre1 commented Jan 26, 2026

This pull request covers, Closes #46 , Closes: #45

SQS.java persisted a Record in PostgreSQL (QuarkusTransaction.requiringNew)
Then, it sent the result to SQS via @Outgoing("whatsapp-recognized")

Instead of sending directly to SQS, we write the output message to an outbox table within the same transaction that persists the Record. A separate process (relay) reads from this table and sends it to SQS asynchronously and resiliently.

I believe that so far it follows good practices of the outbox pattern.

Guaranteeing:

  • Atomicity: Record and OutboxMessage are in the same JPA transaction
    -Resilience: If the relay fails to send to SQS, the message remains PENDING and is retried
  • Ordering: Messages are processed in createdAt order; FIFO of the destination queue is preserved via messageGroupId
  • Idempotence: The destination queue has content_based_deduplication = true in Terraform
  • Non-blocking: The relay does not participate in the transaction consuming the original message

Copy link
Copy Markdown
Owner

@mcruzdev mcruzdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@mcruzdev
Copy link
Copy Markdown
Owner

Possible Closes #46 , , but this will affect the other pull request I made, the #200, It's very likely that there will be some conflict, what would be the best practice for this cc: @mcruzdev ?

Let's merge this one first and after you need to change the another haha, there is no way to escape!

Comment thread timeless-api/src/main/java/dev/matheuscruz/infra/queue/SQS.java Outdated
@matheusandre1 matheusandre1 marked this pull request as draft April 30, 2026 22:49
@matheusandre1
Copy link
Copy Markdown
Contributor Author

matheusandre1 commented May 1, 2026

Take a look @mcruzdev the outbox pattern requires idempotence, right?

@matheusandre1 matheusandre1 changed the title Use microprofile reactive-messaging for SQS Use microprofile reactive-messaging for SQS and add pattern resiliencia for messaging May 1, 2026
@matheusandre1 matheusandre1 changed the title Use microprofile reactive-messaging for SQS and add pattern resiliencia for messaging Use microprofile reactive-messaging for SQS and add pattern resilience for messaging May 1, 2026
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

Successfully merging this pull request may close these issues.

Use microprofile reactive-messaging for SQS Handle dual-writes when processing incoming messages

2 participants