带有 ActiveMQ 的 Quarkus?

Quarkus with ActiveMQ?

在使用 Kafka 试用 Quarkus 之后,我想知道 如何将它与 ActiveMQ 一起使用。我无法 查找任何文档。 Quarkus.io 提到支持 amqp 协议。

有人知道如何实现吗?

除了@John Clingan 提供的答案(谢谢!)直接使用 VertX,您还可以使用 microprofile-reactive-messaging:

  1. smallrye amqp 扩展的当前版本 (0.0.7) 不适用于 Quarkus(CDI 没有空构造函数)。主分支中已经有修复。
git clone https://github.com/smallrye/smallrye-reactive-messaging.git
cd smallrye-reactive-messaging
mvn install
  1. 将新建的工件添加到您的 pom
<dependency>
   <groupId>io.smallrye.reactive</groupId>
   <artifactId>smallrye-reactive-messaging-amqp</artifactId>
   <version>0.0.8-SNAPSHOT</version>
</dependency>
  1. 在application.properties
  2. 中配置amqp
# amqp output
smallrye.messaging.sink.my-amqp-output.type=io.smallrye.reactive.messaging.amqp.Amqp
smallrye.messaging.sink.my-amqp-output.address=test-activemq-amqp
smallrye.messaging.sink.my-amqp-output.containerId=test-activemq-clientid
smallrye.messaging.sink.my-amqp-output.host=localhost

# amqp input
smallrye.messaging.source.my-amqp-input.type=io.smallrye.reactive.messaging.amqp.Amqp
smallrye.messaging.source.my-amqp-input.address=test-activemq-amqp
smallrye.messaging.source.my-amqp-input.containerId=test-activemq-clientid
smallrye.messaging.source.my-amqp-input.host=localhost
  1. 使用 microprofile-reactive-messaging

3.1 从 rest servlet 发送消息

@Path("/hello")
public class HelloWorldResource {

    @Inject
    @Stream("my-amqp-output")
    Emitter<String> emitter;

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {        
        emitter.send("hello!");
        return "hello send";
    }
}

3.2 接收消息

@ApplicationScoped
public class AmqpReceiver {    

    @Incoming("my-amqp-input")
    public void receive(String input) {
        //process message
    }
}

已使用 quarkus 0.14.0 和 0.13.3 进行测试。