Quarkus with ActiveMQ?

五迷三道 提交于 2019-12-11 11:58:46

问题


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?


回答1:


Additionally to the answer provided by @John Clingan (Thanks!) to use VertX directly, you can also use microprofile-reactive-messaging:

  1. The current version (0.0.7) of the smallrye amqp extension does not work with Quarkus (No empty Constructor for CDI). A fix is already in the master branch.
git clone https://github.com/smallrye/smallrye-reactive-messaging.git
cd smallrye-reactive-messaging
mvn install
  1. Add the newly built artifact to your pom
<dependency>
   <groupId>io.smallrye.reactive</groupId>
   <artifactId>smallrye-reactive-messaging-amqp</artifactId>
   <version>0.0.8-SNAPSHOT</version>
</dependency>
  1. Configure amqp in application.properties
# 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. Use microprofile-reactive-messaging

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 Receiving messages

@ApplicationScoped
public class AmqpReceiver {    

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

Tested with quarkus 0.14.0 and 0.13.3.



来源:https://stackoverflow.com/questions/55782716/quarkus-with-activemq

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!