ENT-2835: handle uncaught exception when bridge tries to send a message using a disconnected amqp client (#4399)

* ENT-2835: handle uncaught exception when bridge tries to send a message using a disconnected amqp client

* ENT-2835: remove emptyline

* ENT-2835: added comment explaining the exception handling
This commit is contained in:
bpaunescu 2018-12-11 16:51:35 +00:00 committed by GitHub
parent 74a0a6116c
commit 749c207bad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -191,7 +191,18 @@ class AMQPBridgeManager(config: MutualSslConfiguration, maxMessageSize: Int,
} }
} }
} }
amqpClient.write(sendableMessage) try {
amqpClient.write(sendableMessage)
} catch (ex: IllegalStateException) {
// Attempting to send a message while the AMQP client is disconnected may cause message loss.
// The failed message is rolled back after committing acknowledged messages.
lock.withLock {
ex.message?.let { logInfoWithMDC(it)}
logInfoWithMDC("Rollback rejected message uuid: ${artemisMessage.getObjectProperty("_AMQ_DUPL_ID")}")
session?.commit()
session?.rollback(false)
}
}
bridgeMetricsService?.packetAcceptedEvent(sendableMessage) bridgeMetricsService?.packetAcceptedEvent(sendableMessage)
} }
} }