-
-
Notifications
You must be signed in to change notification settings - Fork 281
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
Assert queues are all the same type in setQueueNames so applications … #1001
base: main
Are you sure you want to change the base?
Assert queues are all the same type in setQueueNames so applications … #1001
Conversation
Hi @internetstaff, sorry for the long delay. Your proposal sounds reasonable.
I'm not sure I follow - as far as I'm aware if a container throws at startup, the app won't start up. So with the change you're proposing I believe it should prevent the app from starting up? What am I missing? Thanks. |
@Override | ||
public void setQueueNames(Collection<String> queueNames) { | ||
super.setQueueNames(queueNames); | ||
assertAllQueuesSameType(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to check this in two places, how about we only check it here on setQueueNames
and do that before calling super
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, and confirmed this still resolves the issue for me.
…fail to start rather than throwing endless Executor errors.
2e0ac45
to
156ffca
Compare
Sorry for the delay - I had to fire this back up myself. :) What I see with this condition is that I do get "Application run failed" but the application doesn't shut down. Instead, it stays in a zombie state. With this change, it logs the error and shuts down. |
…fail to start rather than throwing endless Executor errors.
📢 Type of change
📜 Description
This asserts there's not a mix of FIFO and non-FIFO queues earlier in
SqsMessageListenerContainer.setQueueNames
instead of waiting for the container to fail on startup.💡 Motivation and Context
Migrating from 2.x, we had an
@SqsListener
with a mix of queue types. Instead of failing at startup, there's only one line logged:s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'io.awspring.cloud.messaging.internalEndpointRegistryBeanName'
... followed by an endless loop of AWS SDK
executor not accepting a task
errors from all queues.This is probably not an ideal fix - it seems like any failure in
io.awspring.cloud.sqs.listener.DefaultListenerContainerRegistry#start
should be fatal rather than leaving queues in a weird half-started state. I didn't go that deeply. Feel free to chuck this for a wider fix. :)💚 How did you test it?
Added a simple UT, then pulled the SNAPSHOT into the application with the issue. Verified the app failed immediately with a very clear error.
📝 Checklist
🔮 Next steps