Search code examples
oracle-aqhelidon

Helidon AQ connector does not throw error on database connection reset


I am working on helidon SE service where AQ connector is being used. The service is registered as listener/subscriber to a multi-consumer queue. If database connection is reset due to db restart, AQ connector does not throw any error. The subscription becomes invalid and service is no longer able to receive messages. Is there a way to identify if DB connection is alive and more importantly if the subscriber is active? Also wanted to know any hook points where the error (to be thrown is connection is reset) could be intercepted so that AQ can re-establish connection with DB and activate the subscription?

Tried AQ connector for Helidon SE described here - https://medium.com/helidon/helidon-messaging-with-oracle-aq-a023928dbbb8 As the connector is not able to intercept DB connection reset, this fails if database is restarted.


Solution

  • Helidon AQ connector should not really throw any exception, as it is reactive, it sends an error signal to downstream of subscribed reactive stream instead. Example from the article ignores error signals for the sake of simplicity. You can handle errors in many ways, this is one of them:

    .subscriber(fromAq, multi -> multi
            .peek(m -> System.out.println("Message received: " + m.getPayload()))
            .onError(t -> t.printStackTrace())// << Error handling!!!
            .flatMap(m -> Single.create(m.ack(), true))
            .ignoreElements()
    )