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