Bug bucle infinito de mensajes delay <-> cola
This commit is contained in:
@@ -11,7 +11,8 @@ post {
|
|||||||
}
|
}
|
||||||
|
|
||||||
body:form-urlencoded {
|
body:form-urlencoded {
|
||||||
iccid: 8933201124059175967
|
iccid: 8933201124059176320
|
||||||
|
offer: SAVEFAMILY1
|
||||||
}
|
}
|
||||||
|
|
||||||
settings {
|
settings {
|
||||||
|
|||||||
@@ -38,14 +38,21 @@ export class RabbitMQEventBus implements EventBus {
|
|||||||
return this.channel.ack(msg)
|
return this.channel.ack(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO:
|
||||||
|
* - Esta implementacion del nack debe estar en objenious
|
||||||
|
*/
|
||||||
async nack(msg: ConsumeMessage, requeue?: boolean) {
|
async nack(msg: ConsumeMessage, requeue?: boolean) {
|
||||||
if (this.channel == undefined) throw new Error("[RMQ] Canal no iniciallizado");
|
if (this.channel == undefined) throw new Error("[RMQ] Canal no iniciallizado");
|
||||||
|
|
||||||
|
console.log("NACK: ", msg.properties.headers)
|
||||||
|
|
||||||
const headers = msg.properties.headers || {}
|
const headers = msg.properties.headers || {}
|
||||||
const numberRetry = headers['x-retry-count'] || 0
|
const numberRetry = headers['x-retry-count'] || 0
|
||||||
const routingKey = msg.fields.routingKey
|
const routingKey = msg.fields.routingKey
|
||||||
|
|
||||||
if (numberRetry < this.maxRetry) {
|
if (numberRetry < this.maxRetry) {
|
||||||
|
console.log("Dalaying")
|
||||||
await this.channel.publish("sim.ex.objenious.delayed", routingKey, msg.content, {
|
await this.channel.publish("sim.ex.objenious.delayed", routingKey, msg.content, {
|
||||||
headers: {
|
headers: {
|
||||||
...headers,
|
...headers,
|
||||||
@@ -53,6 +60,7 @@ export class RabbitMQEventBus implements EventBus {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
console.log("DeadLetter")
|
||||||
await this.channel.publish("sim.ex.objenious.dlx", routingKey, msg.content, {
|
await this.channel.publish("sim.ex.objenious.dlx", routingKey, msg.content, {
|
||||||
headers: {
|
headers: {
|
||||||
...headers
|
...headers
|
||||||
@@ -60,6 +68,8 @@ export class RabbitMQEventBus implements EventBus {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hace falta?
|
||||||
|
this.channel.ack(msg)
|
||||||
//return this.channel.nack(msg, false, requeue)
|
//return this.channel.nack(msg, false, requeue)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +110,11 @@ export class RabbitMQEventBus implements EventBus {
|
|||||||
const routingKey = event.key
|
const routingKey = event.key
|
||||||
const content = Buffer.from(JSON.stringify(event))
|
const content = Buffer.from(JSON.stringify(event))
|
||||||
this.channel?.publish(exchange, routingKey, content, {}, (err, ok) => {
|
this.channel?.publish(exchange, routingKey, content, {}, (err, ok) => {
|
||||||
console.log("Confirmacion", err, ok)
|
if (err == undefined) {
|
||||||
|
console.log("Evento publicado ", event)
|
||||||
|
} else {
|
||||||
|
console.error("Error publicando", event)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return res()
|
return res()
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ OBJ_AUTHORIZATION=XOc7FtwXD8hUX2SFVX94XSty8wkOmChkwDNF09O_aIxPubMDdFUdCDCB4zpzSI
|
|||||||
OBJ_CLI_ASSERTION=XOc7FtwXD8hUX2SFVX94XSty8wkOmChkwDNF09O_aIxPubMDdFUdCDCB4zpzSIxi8nOcTg7r_LM_nmd5qm7uLbksf_XArjI8iAyhjKz_2BAXPhmvKs4Fc9f3vv5LDfCVrPB9lP8P7rJ66_qnWs4jvhLQxSfn29m96hgXeCf8oySdIDUjN2q9Js3KAS5LL52Ri6ryvUeO1PvMhaPQMWRqoHIqTV1wPfPtiqQwcjUPmu5GeW164Kq1JLgV3KaGzfCZ9Qv9lbv30EJrukXxWuLCAhBS0kzrBXZoWvf2pb9uh3Am_93_dDxiIGQfIap9ZU_m8ZD1HPgvZOMCY6ZkxQconQ
|
OBJ_CLI_ASSERTION=XOc7FtwXD8hUX2SFVX94XSty8wkOmChkwDNF09O_aIxPubMDdFUdCDCB4zpzSIxi8nOcTg7r_LM_nmd5qm7uLbksf_XArjI8iAyhjKz_2BAXPhmvKs4Fc9f3vv5LDfCVrPB9lP8P7rJ66_qnWs4jvhLQxSfn29m96hgXeCf8oySdIDUjN2q9Js3KAS5LL52Ri6ryvUeO1PvMhaPQMWRqoHIqTV1wPfPtiqQwcjUPmu5GeW164Kq1JLgV3KaGzfCZ9Qv9lbv30EJrukXxWuLCAhBS0kzrBXZoWvf2pb9uh3Am_93_dDxiIGQfIap9ZU_m8ZD1HPgvZOMCY6ZkxQconQ
|
||||||
OBJ_CLIENT_ID=savefamily_rest_ws
|
OBJ_CLIENT_ID=savefamily_rest_ws
|
||||||
OBJ_KID=xNfbMiyL1ORXGP8lElhcv8nVaG3EJKye4Lc1YoN3I1E
|
OBJ_KID=xNfbMiyL1ORXGP8lElhcv8nVaG3EJKye4Lc1YoN3I1E
|
||||||
OBJ_BASE_URL=https://api-getway.objenious.com/ws
|
//OBJ_BASE_URL=https://api-getway.objenious.com/ws
|
||||||
//OBJ_BASE_URL=https://api-getway.objenious.com/ws/test
|
OBJ_BASE_URL=https://api-getway.objenious.com/ws/test
|
||||||
|
|||||||
@@ -76,7 +76,10 @@ export class SimController {
|
|||||||
const iccid = msgData.payload.iccid
|
const iccid = msgData.payload.iccid
|
||||||
const offer = msgData.payload.offer
|
const offer = msgData.payload.offer
|
||||||
|
|
||||||
if (offer == undefined) throw new Error("Error activando la sim, no se ha especificado la oferta")
|
if (offer == undefined) {
|
||||||
|
this.eventBus.nack(msg)
|
||||||
|
throw new Error("Error activando la sim, no se ha especificado la oferta")
|
||||||
|
}
|
||||||
|
|
||||||
this.tryUseCase(msg, this.useCases.activate({
|
this.tryUseCase(msg, this.useCases.activate({
|
||||||
dueDate: this.genDueDate(2 * 60).toISOString(),
|
dueDate: this.genDueDate(2 * 60).toISOString(),
|
||||||
|
|||||||
@@ -66,8 +66,6 @@ export class SimController {
|
|||||||
|
|
||||||
const { iccid, offer } = req.body
|
const { iccid, offer } = req.body
|
||||||
|
|
||||||
//TODO: incluir lo de las offers
|
|
||||||
|
|
||||||
const compañia = this.compañiaFromIccid(iccid)
|
const compañia = this.compañiaFromIccid(iccid)
|
||||||
|
|
||||||
if (compañia == undefined) {
|
if (compañia == undefined) {
|
||||||
@@ -81,7 +79,7 @@ export class SimController {
|
|||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.simUseCases.activation({ iccid, compañia })
|
await this.simUseCases.activation({ iccid, compañia, offer })
|
||||||
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
iccid: iccid,
|
iccid: iccid,
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export class SimUsecases {
|
|||||||
return this.eventBus.publish([activationEvent])
|
return this.eventBus.publish([activationEvent])
|
||||||
}
|
}
|
||||||
|
|
||||||
async activation(args: { iccid: string, compañia: string, offer?: string }) {
|
async activation(args: { iccid: string, compañia: string, offer: string }) {
|
||||||
|
|
||||||
const activationEvent = <SimEvents.activation>{
|
const activationEvent = <SimEvents.activation>{
|
||||||
key: `sim.${args.compañia}.activate`,
|
key: `sim.${args.compañia}.activate`,
|
||||||
|
|||||||
Reference in New Issue
Block a user