You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering if in Micronaut, something like in Spring can be achieved where by creating custom annotation we are able to populate custom properties into the application context. I have working example in Spring but can't figure out if it would work in Micronaut.
Spring:
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@TestPropertySource
public @interface EnableSqS {
/**
* Syntax: {property-to-be-set={queue-name}}
* example:
* "create-queues:sqs-queue-url=test-queue"
* this creates queue `test-queue` on application start up
* under property 'sqs-queue-url'
* @return
*/
@AliasFor(annotation = TestPropertySource.class, attribute = "properties")
String[] createQueues();
}
I implemented similar thing in Micronaut:
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
@PropertySource
annotation class EnableSqs(
@get:AliasFor(annotation = PropertySource::class, member = "value")
vararg val createQueues: String = []
)
but when running simple test to validate:
@EnableSqs(createQueues = ["create-queues:test-sqs-url:test-queue"])
internal class TestScnerio {
}
@Factory
internal class SqsQueueFactory(
private val environment: Environment,
) {
private val logger = KotlinLogging.logger {}
@Context
@Singleton
fun createQueues() = runBlocking {
logger.info { environment.getProperties("create-queues") }
}
}
There is no such property registered in the application context. Any idea if this could actually be achievable?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I was wondering if in Micronaut, something like in Spring can be achieved where by creating custom annotation we are able to populate custom properties into the application context. I have working example in Spring but can't figure out if it would work in Micronaut.
Spring:
I implemented similar thing in Micronaut:
but when running simple test to validate:
There is no such property registered in the application context. Any idea if this could actually be achievable?
Beta Was this translation helpful? Give feedback.
All reactions