Answers for "bullmq redis cluster"

0

bullmq redis cluster

const { Queue, Worker } = require('bullmq')
const Redis = require('ioredis')

const clusterQueue = new Queue('Superhero', {
	prefix: '{bullMQ}',
	connection: new Redis.Cluster([
		{ host: '127.0.0.1', port: 6379 },
		{ host: '127.0.0.1', port: 6380 },
		{ host: '127.0.0.1', port: 6381 }
	])
})

async function renderQueue() {
	await clusterQueue.add('name:speaker', 'batman')
}

renderQueue()

const WorkerQueue = new Worker('Superhero', async (job) => console.log(job.data), {
	connection: new Redis.Cluster([
		{ host: '127.0.0.1', port: 6379 },
		{ host: '127.0.0.1', port: 6380 },
		{ host: '127.0.0.1', port: 6381 }
	]),
	prefix: '{bullMQ}'
})

WorkerQueue.on('waiting', () => console.log('jobs waiting'))
WorkerQueue.on('completed', () => console.log('jobs completed'))
WorkerQueue.on('failed', () => console.log('jobs failed'))
Posted by: Guest on February-23-2021
0

bullmq redis cluster

const Queue = require('bull')
const Redis = require('ioredis')

const clusterQueue = new Queue('Name', {
	prefix: '{clusterQueue}',
	createClient: () =>
		new Redis.Cluster([
			{ host: '127.0.0.1', port: 6379 },
			{ host: '127.0.0.1', port: 6380 },
			{ host: '127.0.0.1', port: 6381 }
		])
})

clusterQueue.process((job, done) => {
	console.log(job.data)
	done()
})

clusterQueue.add({ heroe: 'superman' })
Posted by: Guest on February-23-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language