Open roxrook opened 2 years ago
Hi. Redis integration is pretty simple. you only need two things:
1) Redis dependency
implementation 'com.agorapulse:micronaut-worker-queues-redis:1.2.1-micronaut-3.0'
2) Redis URI which can be set with REDIS_URI
environment property or redis.url
in the configuration file
redis:
uri: redis://...
Then you create a job with consumer and producer:
public class MyJob {
public Publisher<String> producerMethod() {
// produce messages into queue
}
public void consumerMethod(String message) {
// do something with message
}
}
I've used String
in the example, but you can use any object which can be de/serialized to JSON.
see more https://agorapulse.github.io/micronaut-worker/#_jobs_using_queue
Thanks. My Redis instances also requires username, password and ssl. Besides I want to configure the correct size for connection pool and share it with other business logic as a singleton so I'm wondering if there is a way to configure it in code?
Please, check the Micronaut Redis configuration for further information. They are read from redis.
configuration properties.
Can you guys provide some examples on how to configure Redis queue with and without YAML? Thanks!