Type: Bug
Component:
"SQS"
Describe the bug
When using @SqsListener with multiple @SqsHandler methods, if a handler method is Message<'Pojo'> instead of just 'Pojo', routing always falls through to the default handler.
Sample
Using Spring boot 3.x and spring cloud aws 4.0.0
// This WORKS — Pojo parameter
@SqsListener(queueNames = "myQueue")
public class WorkingListener {
@SqsHandler
public void onCreated(MyPojo event) {
// Correctly routed
}
@SqsHandler
public void onUpdated(MyOtherPojo event) {
// Correctly routed
}
@SqsHandler(isDefault = true)
public void onDefault(Event event) {
// Only receives truly unmatched events
}
}
// This FAILS — Message<Pojo> parameter
@SqsListener(queueNames = "myQueue")
public class BrokenListener {
@SqsHandler
public void onCreated(Message<Pojo> message) {
// Never reached — falls through to default
}
@SqsHandler
public void onUpdated(Message<MyOtherPojo> message) {
// Never reached — falls through to default
}
@SqsHandler(isDefault = true)
public void onDefault(Event event) {
// ALL events end up here
}
}
Workaround
Add the POJO as the first parameter for routing, and Message as a second parameter:
@SqsHandler
public void onCreated(Pojo pojo, Message<Pojo> message) {
// 'pojo' enables correct routing with access to message metadata
}
``
Type: Bug
Component:
"SQS"
Describe the bug
When using @SqsListener with multiple @SqsHandler methods, if a handler method is Message<'Pojo'> instead of just 'Pojo', routing always falls through to the default handler.
Sample
Using Spring boot 3.x and spring cloud aws 4.0.0
Workaround
Add the POJO as the first parameter for routing, and Message as a second parameter: