5

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?

lucky
  • 126
  • 7
  • 2
    Here is a blog post that runs Vert.x APIs inside of Quarkus to talk to ActiveMQ over AMQP: https://medium.com/@yazidaqel/quarkus-vertx-a-powerfull-combination-part-1-introduction-b039b911686 – John Clingan Apr 22 '19 at 15:16
  • If it's AMQP, it's natively supported already. – WesternGun Nov 09 '22 at 08:08

1 Answers1

4

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.

lucky
  • 126
  • 7
  • Additionally I have opened issue for smallrye: https://github.com/smallrye/smallrye-reactive-messaging/issues/95 – lucky Apr 28 '19 at 17:35