Closed samu-developments closed 10 months ago
Example application: https://github.com/samu-developments/sqs-mn-issue Created from Intellij with Micronaut project with SQS and JMS dependencies selected.
To test it you need a SQS queue in AWS named "test_queue", and run the application with valid AWS credentials so the application can talk to SQS.
Stacktrace:
09:48:08.618 [main] ERROR i.m.j.c.JMSQueueListenerMethodProcessor - Failed to register listener for destination test_queue
javax.jms.JMSException: SQSSession does not support MessageSelector. This should be null.
at com.amazon.sqs.javamessaging.SQSSession.createConsumer(SQSSession.java:600)
at io.micronaut.jms.listener.JMSListener.start(JMSListener.java:134)
at io.micronaut.jms.listener.JMSListenerRegistry.register(JMSListenerRegistry.java:68)
at io.micronaut.jms.listener.JMSListenerRegistry.register(JMSListenerRegistry.java:115)
at io.micronaut.jms.configuration.AbstractJMSListenerMethodProcessor.registerListener(AbstractJMSListenerMethodProcessor.java:168)
at io.micronaut.jms.configuration.AbstractJMSListenerMethodProcessor.process(AbstractJMSListenerMethodProcessor.java:93)
at io.micronaut.context.DefaultBeanContext.lambda$initializeContext$32(DefaultBeanContext.java:2044)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1707)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
at io.micronaut.context.DefaultBeanContext.initializeContext(DefaultBeanContext.java:2018)
at io.micronaut.context.DefaultApplicationContext.initializeContext(DefaultApplicationContext.java:290)
at io.micronaut.context.DefaultBeanContext.readAllBeanDefinitionClasses(DefaultBeanContext.java:3337)
at io.micronaut.context.DefaultBeanContext.finalizeConfiguration(DefaultBeanContext.java:3690)
at io.micronaut.context.DefaultBeanContext.start(DefaultBeanContext.java:345)
at io.micronaut.context.DefaultApplicationContext.start(DefaultApplicationContext.java:198)
at io.micronaut.runtime.Micronaut.start(Micronaut.java:73)
at io.micronaut.runtime.Micronaut.run(Micronaut.java:322)
at io.micronaut.runtime.Micronaut.run(Micronaut.java:297)
at com.example.ApplicationKt.main(Application.kt:6)
When could we expect a fix for this ? I cant even pass null for the value in annotation
@samu-developments : Facing the same issue. Are you maybe aware of any workaround for now?
@samu-developments : Facing the same issue. Are you maybe aware of any workaround for now?
Yes, I just built the project with the fix from https://github.com/micronaut-projects/micronaut-jms/pull/440 and copy the jms-core jar to projectRoot/libs
folder. Then in build.gradle.kts:
implementation(files("libs/micronaut-jms-core-3.0.2-SNAPSHOT.jar"))
Nice. Thank you for sharing this workaround.
The problem here seems to be ksp
annotation processor. It works properly with kapt
(so - you can use it as a workaround).
The thing is that when MN registers annotation default values in DefaultAnnotationMetadata.registerAnnotationDefaults()
, these default values come from the annotation processor. Kapt returns null for a default value of empty string, while Ksp returns empty string as default value. Thus then - under Kapt, null gets propagated to SQSSession.createConsumer
and it works and under Ksp it's empty string which gets there and it doesnt work because AWS implementation thinks the messageSelector
is defined...
This unfortunately means, that it might be a wider issue, as it affects all ""
defaults :-/
Expected Behavior
Consuming from SQS queue should work.
Actual Behaviour
@Queue annotation defaults messageSelector to "" https://github.com/micronaut-projects/micronaut-jms/blob/9c77b572519bb463b5b409fb8ef556f46a23547f/jms-core/src/main/java/io/micronaut/jms/annotations/Queue.java#L134
AWS sdk is not happy about non null message selector:
https://github.com/awslabs/amazon-sqs-java-messaging-lib/blob/4cb91355cb92d9361a2179233c9db89383b1299e/src/main/java/com/amazon/sqs/javamessaging/SQSSession.java#L572
AWS sdk is likely not adding this in the foreseeable future.. https://github.com/awslabs/amazon-sqs-java-messaging-lib/issues/4
Steps To Reproduce
Environment Information
No response
Example Application
No response
Version
core: 4.1.8, jms: 3.0.1