package io.quarkus.smallrye.reactivemessaging.runtime;

import javax.enterprise.context.Dependent;
import javax.enterprise.event.Observes;
import javax.inject.Inject;

import io.quarkus.runtime.StartupEvent;
import io.smallrye.reactive.messaging.extension.MediatorManager;

@Dependent
public class SmallRyeReactiveMessagingLifecycle {

    @Inject
    MediatorManager mediatorManager;

    void onApplicationStart(@Observes StartupEvent event) {
        try {
            mediatorManager.initializeAndRun();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}

@@ -49,16 +49,50 @@
 ntime;%0A%0A
+import javax.annotation.Priority;%0A
 import j
@@ -450,16 +450,81 @@
 Observes
+ @Priority(javax.interceptor.Interceptor.Priority.LIBRARY_BEFORE)
  Startup

change priority in StartupEvent observer to initialize MediatorManager earlier