|
|
@ -36,6 +36,7 @@ class MessageManager {
|
|
|
|
recvAck: false, // aka "delivered"
|
|
|
|
recvAck: false, // aka "delivered"
|
|
|
|
readAck: false, // "read"
|
|
|
|
readAck: false, // "read"
|
|
|
|
response: false, // "resp"
|
|
|
|
response: false, // "resp"
|
|
|
|
|
|
|
|
failed: false, // failed
|
|
|
|
deliveryLog: {},
|
|
|
|
deliveryLog: {},
|
|
|
|
} : {
|
|
|
|
} : {
|
|
|
|
duplexCapable: false,
|
|
|
|
duplexCapable: false,
|
|
|
@ -106,15 +107,22 @@ class MessageManager {
|
|
|
|
let deliveryChain = msg.routingParams.connectors.map((connectorDeliveryTry) => {
|
|
|
|
let deliveryChain = msg.routingParams.connectors.map((connectorDeliveryTry) => {
|
|
|
|
const connectorName = connectorDeliveryTry[0],
|
|
|
|
const connectorName = connectorDeliveryTry[0],
|
|
|
|
connectorArgs = connectorDeliveryTry.slice(1),
|
|
|
|
connectorArgs = connectorDeliveryTry.slice(1),
|
|
|
|
connectorConfig = config.connectors[connectorName]
|
|
|
|
connectorConfig = config.connectors[ ConnectorRegistry.getConfigKey( connectorName ) ]
|
|
|
|
//const UUID = md5(JSON.stringify(connectorDeliveryTry))
|
|
|
|
//const UUID = md5(JSON.stringify(connectorDeliveryTry))
|
|
|
|
|
|
|
|
const UUID = connectorName+':'+md5(JSON.stringify([connectorName,...connectorArgs]))
|
|
|
|
|
|
|
|
|
|
|
|
const chainPromise = (res) => {
|
|
|
|
const chainPromise = (res) => {
|
|
|
|
ConnectorRegistry.events.removeAllListeners(`msg:status:${ msgId }:failed`)
|
|
|
|
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(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
|
|
console.log(`${ msgId } timed out ${ connectorName }:${ connectorArgs.join(',') }, continuing...`)
|
|
|
|
|
|
|
|
ConnectorRegistry.reportState({ id: msgId }, UUID, 'timeout')
|
|
|
|
res([false, 'timeout'])
|
|
|
|
res([false, 'timeout'])
|
|
|
|
}, !!connectorConfig && !!connectorConfig.duplexTimeout ? connectorConfig.duplexTimeout*1e3 : 30e3)
|
|
|
|
}, connectorTimeout)
|
|
|
|
ConnectorRegistry.events.once(`msg:status:${ msgId }:failed`, () => {
|
|
|
|
ConnectorRegistry.events.once(`msg:status:${ msgId }:failed`, () => {
|
|
|
|
console.log(`${ msgId } failed via ${ connectorName }:${ connectorArgs.join(',') }, continuing...`)
|
|
|
|
console.log(`${ msgId } failed via ${ connectorName }:${ connectorArgs.join(',') }, continuing...`)
|
|
|
|
|
|
|
|
ConnectorRegistry.reportState({ id: msgId }, UUID, 'failed')
|
|
|
|
res([false, 'failed'])
|
|
|
|
res([false, 'failed'])
|
|
|
|
})
|
|
|
|
})
|
|
|
|
console.log(`Trying to deliver msg#${ msg.id } with ${ connectorName }:${ connectorArgs.join(',') }`)
|
|
|
|
console.log(`Trying to deliver msg#${ msg.id } with ${ connectorName }:${ connectorArgs.join(',') }`)
|
|
|
@ -147,6 +155,7 @@ class MessageManager {
|
|
|
|
.catch(($) => {
|
|
|
|
.catch(($) => {
|
|
|
|
this._clearEventHandlers4MsgID(msgId)
|
|
|
|
this._clearEventHandlers4MsgID(msgId)
|
|
|
|
console.log('DELIVERY WAS A TOTAL FAILURE', $)
|
|
|
|
console.log('DELIVERY WAS A TOTAL FAILURE', $)
|
|
|
|
|
|
|
|
const dLog = this.messages[ msgId ]._routerData.failed = true
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -159,7 +168,7 @@ class MessageManager {
|
|
|
|
let deliveryChain = msg.routingParams.connectors.map((connectorDeliveryTry) => {
|
|
|
|
let deliveryChain = msg.routingParams.connectors.map((connectorDeliveryTry) => {
|
|
|
|
const connectorName = connectorDeliveryTry[0],
|
|
|
|
const connectorName = connectorDeliveryTry[0],
|
|
|
|
connectorArgs = connectorDeliveryTry.slice(1),
|
|
|
|
connectorArgs = connectorDeliveryTry.slice(1),
|
|
|
|
connectorConfig = config.connectors[connectorName]
|
|
|
|
connectorConfig = config.connectors[ ConnectorRegistry.getConfigKey( connectorName ) ]
|
|
|
|
const chainPromise = (res, rej) => {
|
|
|
|
const chainPromise = (res, rej) => {
|
|
|
|
this._clearEventHandlers4MsgID(msgId)
|
|
|
|
this._clearEventHandlers4MsgID(msgId)
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|