|
|
|
@ -104,6 +104,7 @@ class MessageManager {
|
|
|
|
|
if (!!msg.locked) throw 'message is locked'
|
|
|
|
|
|
|
|
|
|
//console.log(msg.routingParams.connectors)
|
|
|
|
|
let timeoutList = []
|
|
|
|
|
let deliveryChain = msg.routingParams.connectors.map((connectorDeliveryTry) => {
|
|
|
|
|
const connectorName = connectorDeliveryTry[0],
|
|
|
|
|
connectorArgs = connectorDeliveryTry.slice(1),
|
|
|
|
@ -115,11 +116,13 @@ class MessageManager {
|
|
|
|
|
ConnectorRegistry.events.removeAllListeners(`msg:status:${ msgId }:failed`)
|
|
|
|
|
const connectorTimeout = !!connectorConfig && !!connectorConfig.duplexTimeout ? connectorConfig.duplexTimeout*1e3 : 30e3
|
|
|
|
|
console.log("connector", connectorName, "duplex Timeout is", connectorTimeout)
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
console.log(`${ msgId } timed out ${ connectorName }:${ connectorArgs.join(',') }, continuing...`)
|
|
|
|
|
ConnectorRegistry.reportState({ id: msgId }, UUID, 'timeout')
|
|
|
|
|
res([false, 'timeout'])
|
|
|
|
|
}, connectorTimeout)
|
|
|
|
|
timeoutList.push(
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
console.log(`${ msgId } timed out ${ connectorName }:${ connectorArgs.join(',') }, continuing...`)
|
|
|
|
|
ConnectorRegistry.reportState({ id: msgId }, UUID, 'timeout')
|
|
|
|
|
res([false, 'timeout'])
|
|
|
|
|
}, connectorTimeout)
|
|
|
|
|
)
|
|
|
|
|
ConnectorRegistry.events.once(`msg:status:${ msgId }:failed`, () => {
|
|
|
|
|
console.log(`${ msgId } failed via ${ connectorName }:${ connectorArgs.join(',') }, continuing...`)
|
|
|
|
|
ConnectorRegistry.reportState({ id: msgId }, UUID, 'failed')
|
|
|
|
@ -134,6 +137,7 @@ class MessageManager {
|
|
|
|
|
new Promise(res => { // Delivery Event for this message
|
|
|
|
|
ConnectorRegistry.events.once(`msg:status:${ msgId }:delivered`, (_, uuid) => {
|
|
|
|
|
console.log(`${ msgId } delivered via ${ uuid }`)
|
|
|
|
|
for (let x of timeoutList) clearTimeout(x)
|
|
|
|
|
return res()
|
|
|
|
|
})
|
|
|
|
|
}),
|
|
|
|
@ -150,7 +154,8 @@ class MessageManager {
|
|
|
|
|
.then(($) => {
|
|
|
|
|
this._clearEventHandlers4MsgID(msgId)
|
|
|
|
|
const dLog = this.messages[ msgId ]._routerData.deliveryLog
|
|
|
|
|
console.log('DELIVERY WAS A SUCCESS', Object.keys(dLog).map(x=>`${ x } is ${ dLog[x] }`).join('\n'))
|
|
|
|
|
for (let x of timeoutList) clearTimeout(x)
|
|
|
|
|
//console.log('DELIVERY WAS A SUCCESS', Object.keys(dLog).map(x=>`${ x } is ${ dLog[x] }`).join('\n'))
|
|
|
|
|
})
|
|
|
|
|
.catch(($) => {
|
|
|
|
|
this._clearEventHandlers4MsgID(msgId)
|
|
|
|
|