Quarkus EventBus - Set address of ConsumeEvent

160 Views Asked by At

In application.properties I set the address name of the EventBus, as follows:

event-bus.channel = persist

In my consumer class, I defined the method consuming the message, with ConsumeEvent annotation:

@ApplicationScoped
@Slf4j
public class MyConsumer {
    @ConsumeEvent("{event-bus.channel}")
    public void consumeMessage(String message){
        log.debug("Received a message: " + message);
    }
}

The address is not set as "persist", because the consumer does not receive any message from the producer.

If I change the annotation as

@ConsumeEvent("persist")

the consumer can receive messages.

I also tried change the annotation as

@ConsumeEvent(ConfigProvider.getConfig().getValue("event-bus.channel", String.class))

but it does not work, because the parameter must be a constant.

How can I set the address in the annotation with a property defined in application.properties?

0

There are 0 best solutions below