Orders para test y flujo de migraciones mas simple
This commit is contained in:
@@ -17,6 +17,11 @@ export class RabbitMQEventBus implements EventBus {
|
||||
private buildStructure?: (chan: Channel) => Promise<void>
|
||||
private maxRetry: number = 0
|
||||
|
||||
connection?: AmqpConnectionManager
|
||||
channel?: ChannelWrapper
|
||||
connected: Boolean = false
|
||||
|
||||
private connectionOptions: RMQConnectionParams
|
||||
constructor(args: {
|
||||
connectionParams: RMQConnectionParams,
|
||||
buildStructure?: (chan: Channel) => Promise<void>,
|
||||
@@ -73,11 +78,6 @@ export class RabbitMQEventBus implements EventBus {
|
||||
//return this.channel.nack(msg, false, requeue)
|
||||
}
|
||||
|
||||
connection?: AmqpConnectionManager
|
||||
channel?: ChannelWrapper
|
||||
connected: Boolean = false
|
||||
|
||||
private connectionOptions: RMQConnectionParams
|
||||
|
||||
public async connect() {
|
||||
|
||||
@@ -96,28 +96,35 @@ export class RabbitMQEventBus implements EventBus {
|
||||
} catch (e) {
|
||||
console.error("[RMQ] Error estableciendo la conexion con el servidor", e)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
publish(events: DomainEvent[]): Promise<void> {
|
||||
|
||||
return new Promise((res, rej) => {
|
||||
publish(events: DomainEvent[]): Promise<{ success: DomainEvent[], error: DomainEvent[] }> {
|
||||
return new Promise(async (res, rej) => {
|
||||
const successEvents: DomainEvent[] = []
|
||||
const errorEvents: DomainEvent[] = []
|
||||
try {
|
||||
for (const event of events) {
|
||||
const exchange = "sim.exchange"
|
||||
const routingKey = event.key
|
||||
const content = Buffer.from(JSON.stringify(event))
|
||||
this.channel?.publish(exchange, routingKey, content, {}, (err, ok) => {
|
||||
await this.channel?.publish(exchange, routingKey, content, {
|
||||
headers: {
|
||||
...event.headers
|
||||
}
|
||||
}, (err, ok) => {
|
||||
if (err == undefined) {
|
||||
console.log("Evento publicado ", event)
|
||||
successEvents.push(event)
|
||||
} else {
|
||||
console.error("Error publicando", event)
|
||||
errorEvents.push(event)
|
||||
}
|
||||
})
|
||||
}
|
||||
return res()
|
||||
return res({
|
||||
success: successEvents,
|
||||
error: errorEvents
|
||||
})
|
||||
} catch (err) {
|
||||
return rej(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user