O. Loïc
O. Loïc

Reputation: 1

How do I catch exceptions from my MqttPahoMessageHandler to perform recovery or timeout processing?

I'm currently implementing a process for receiving MQTT frames and then exporting them to another MQTT broker. Except that the broker in question is sometimes not accessible. It is therefore important for me to manage my errors when sending this frame.

Here's the current flow I've put in place :

@Bean
public IntegrationFlow telemetryFlow() {
    return IntegrationFlow
        .from(broadcastChannel)
        .handle(thingsBoardPubMqttHandler)
        .get();
}

I've tried to set up a parallel flow to this one with the default error channel as from. But when I take the exception, it is never called with the exception :

@Bean
public IntegrationFlow errorFlow() {
    return IntegrationFlow.from(errorChannel())
        .log(LoggingHandler.Level.ERROR)
        .get();
}

Here is my current spring integration configuration

spring.integration.channels.autoCreate=true
spring.integration.channels.error.requireSubscribers=true
spring.integration.taskScheduler.poolSize=10
spring.integration.readOnly.headers=
spring.integration.channels.maxUnicastSubscribers=2147483647
spring.integration.endpoints.noAutoStartup=
spring.integration.channels.error.ignoreFailures=false
spring.integration.messagingTemplate.throwExceptionOnLateReply=false
spring.integration.channels.maxBroadcastSubscribers=2147483647
spring.integration.endpoints.defaultTimeout=30000

Thank you in advance for your feedback

Upvotes: 0

Views: 10

Answers (0)

Related Questions