使用 ActiveMQ 的 Quarkus? [英] Quarkus with ActiveMQ?
本文介绍了使用 ActiveMQ 的 Quarkus?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在用 Kafka 试用 Quarkus 后,我想知道如何将它与 ActiveMQ 一起使用.我无法找到任何文档.Quarkus.io 提到了对 amqp 协议的支持.
After trying out Quarkus with Kafka I‘m wondering how to use it with ActiveMQ. I was not able to find any documentation. Quarkus.io mentions support for amqp protocoll.
有人知道如何实现这一目标吗?
Does somebody know how to achieve this?
推荐答案
除了@John Clingan 提供的答案(谢谢!)直接使用 VertX,您还可以使用 microprofile-reactive-messaging:
Additionally to the answer provided by @John Clingan (Thanks!) to use VertX directly, you can also use microprofile-reactive-messaging:
- smallrye amqp 扩展的当前版本 (0.0.7) 不适用于 Quarkus(CDI 没有空构造函数).修复程序已经在主分支中.
git clone https://github.com/smallrye/smallrye-reactive-messaging.git
cd smallrye-reactive-messaging
mvn install
- 将新构建的工件添加到您的 pom 中
<dependency>
<groupId>io.smallrye.reactive</groupId>
<artifactId>smallrye-reactive-messaging-amqp</artifactId>
<version>0.0.8-SNAPSHOT</version>
</dependency>
- 在 application.properties 中配置 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
- 使用 microprofile-reactive-messaging
3.1 从 rest servlet 发送消息
3.1 Sending messages from a 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 进行测试.
Tested with quarkus 0.14.0 and 0.13.3.
这篇关于使用 ActiveMQ 的 Quarkus?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文