简体   繁体   中英

How consume and publish messages with Micronaut and RabbitMQ?

Micronaut 1.0.0 has just been released (2018-10-25) and in its documentation for RabbitMQ it doesn't seem to say how to actually consume or publish messages. It just says that you can create a project support RabbitMQ using:

mn create-app my-app --features rabbitmq

But once this is done the only thing of interest that is generated is the Application class:

import io.micronaut.runtime.Micronaut;

public class Application {

    public static void main(String[] args) {
        Micronaut.run(Application.class);
    }
}

and some yaml configuration:

---
micronaut:
    application:
        name: my-app

---
rabbitmq:
    uri: amqp://user:pass@host:10000/vhost
    requestedFrameMax: 10
    requestedChannelMax: 10
    connectionTimeout: 5000

But how can I actually start consuming and publishing messages with RabbitMQ using Micronaut?

Currently the RabbitMQ support is very minimal. What is provided for you is the ability to configure a ConnectionFactory with the micronaut environment.

"A RabbitMQ connection factory bean will be provided based on the configuration values supplied under the rabbitmq configuration key. All setter methods on ConnectionFactory are available to be configured."

It is then up to you to use the connection factory per the rabbitmq documentation https://www.rabbitmq.com/api-guide.html

Better support for RabbitMQ (similar to Kafka) is a high priority for Micronaut 1.1.0.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM