This package has been deprecated

Author message:

no longer in use

@emartech/rabbitmq-worker

1.7.1 • Public • Published

@emartech/rabbitmq-worker

BaseWorker

Automatically logs worker failures with context and elapsed time on success run.

Methods

retry(message, errorCode)

Re-queues the currently processed message for retry.

queueWorker(workerId, options)

Starts a new worker with the given worker id.

To set required keys in the options, set requiredKeys in the worker's configuration as an array.

Example

const { BaseWorker } = require('@emartech/rabbitmq-worker');

class MyWorker extends BaseWorker {

  async run(options) {
    console.log(options); // { option: 'foo' }
    console.log(this.config.foo); // bar
    
    if (errorHappened) {
      this.retry('Something happened', 400);
    }
    
    
    this.queueWorker('NextWorker', { newVar: 'foo' });
  }

}

MyWorker
  .create('my-worker-log-namespace')
  .execute({foo: 'bar'}, { option: 'foo' });

Ignition

Starts the given type of worker to consume a RabbitMQ queue.

A sample worker starting script my-worker.js:

const { Ignition } = require('@emartech/rabbitmq-worker');
const workerPool = require('./worker-pool');

Ignition.create(workerPool).start('MyWorker');

RabbitMq

See @emartech/rabbitmq-client for more information.

Configuration

@emartech/rabbitmq-worker uses node-config `package for configuration.

Required configuration example

{
  "RabbitMQ": "rabbitmq://connection",
  "Workers": {
    "MyWorker": { // All worker requires a config for it to run
      "queueName": "my-worker", // The queue's name to get options (message)
      "concurrency": 3, // Number of worker instances to start
      "prefetchCount": 10, // Prefetch count for consumer
      "autoNackTime": 60000, // Auto time-out for worker
      "customConfigVar": "foo"
    }
  }
}

Worker pool example

{
  MyWorker: require('./workers/my-worker')
}

Readme

Keywords

none

Package Sidebar

Install

npm i @emartech/rabbitmq-worker

Weekly Downloads

18

Version

1.7.1

License

ISC

Unpacked Size

15.3 kB

Total Files

13

Last publish

Collaborators

  • mruell
  • akapa
  • mkls
  • kaaj
  • knagy
  • jfillmore
  • rehreth
  • pecc
  • mhegedus
  • norbert-levajsics-emarsys
  • mmartin
  • bsoos
  • emarsys-deployer
  • draven
  • drahos.istvan
  • judge
  • erikpetroemar
  • emarsys-security
  • daniel.banky
  • szeist
  • rgargya
  • marton.papp.emarsys
  • dgyenes
  • s.viktor
  • m4w4q7
  • david.barkoczi
  • adroszler
  • daniels1404
  • xin.he
  • qw3r
  • tamas.toth
  • gergaczd
  • viau
  • muddam
  • gerike
  • alkra
  • epgrubmair
  • bence.uto
  • cseby92
  • morban
  • ettancos
  • epmartini
  • gabor.balla.emarsys
  • mzsombor
  • ejpersson
  • ejwalker
  • llosonczy
  • iben12
  • kartonfarkas
  • adamoa
  • mbarna
  • peva
  • bforgacs
  • zsomborh
  • kozma
  • ngabor84
  • zerosuxx
  • andrasp3a
  • edosrecki
  • eadaniel
  • selator
  • fhase
  • kkimak
  • gaborb
  • glendvai
  • lveraszto
  • bozsadam
  • rdoczi
  • fentosi
  • boristomic
  • mbazso
  • dmihalek
  • lhalasz
  • evspasevski
  • jason-nelson-01
  • bence.toth
  • dsztanko
  • tbugar
  • fqqdk
  • menyhertfatyol
  • zoltanrideg-emarsys
  • sarakoll
  • mmolnar-emar
  • attila.gal
  • benjamingehl
  • rkumari03
  • tdorkaa
  • lkonya
  • dudaaslaci
  • gpap_ema
  • vimtaai
  • lloki-emarsys
  • mrmeszaros
  • borzi
  • varszegik
  • pmaksa_emarsys
  • i850773
  • dfarago
  • estefanlesnjakovic
  • attilamuller01
  • mhunyady
  • atittel
  • marton.matusek
  • sapfs
  • fenyopeti
  • sixstep
  • sap-jjf
  • saphendricksjoerg
  • pjohnson02
  • retfalvibence
  • brandon-sap
  • mmothersill
  • jerryrichardson
  • arnaud.buchholz
  • jamescocker
  • manasbommakanti
  • adamszabolcs
  • ushnpm
  • mengjiao.zhao
  • ianhelmrich
  • btalos
  • mmartin2
  • dkorpos
  • jbleclerc
  • nvkaur2
  • tbucsanszki
  • pendicg24
  • pintera
  • asciortino1
  • dmorvai
  • nicolaeciumac
  • dimitrovn
  • maurogreco
  • oliverweisenburger
  • bercziand
  • nish343
  • scotthetrick
  • konradschewe
  • ivanfroehlich
  • zbalazs
  • mattfeldhake_emarsys
  • ttoth2
  • bborsi
  • ziyadg
  • greszter
  • sovagos
  • apoon
  • burci
  • mark.adorjan
  • xueboliang
  • skrivoo
  • azorahai3904
  • kolosh
  • jviesersap
  • drewhodsonsap
  • criley
  • iulianmihai
  • mariannag
  • bobby_russel
  • dkocsis-emarsys
  • agrucza
  • marko.fritzsche
  • demajo_ems
  • tothmarci25
  • tsiraitnpm
  • plsap
  • sseidmed
  • roxanams
  • bencekadaremar
  • viktor.szell
  • dunaicapa
  • ccarrollem
  • geczirobert
  • sap-ns
  • balintkemenyemarsys
  • dhruv-sap
  • irvansap
  • markjarvis
  • rollandgh
  • laralangnau
  • tillmannr
  • eggarcia
  • rimo86
  • sevket-ataseven
  • zholler
  • robertoraczemarsys
  • samthomas02
  • mkrikoor
  • mfel0123
  • luca.fasolino.se
  • ndomke
  • franziskajung
  • andras.sarro
  • dschuppa
  • dszunomar
  • emarsys-stephen-ives
  • bencso
  • rcsullag
  • dputta
  • dwolter_emarsys
  • jisaacson
  • tothbence8
  • d056437
  • ekkovats
  • alanshi
  • earlpitts
  • probalazs
  • rmafteiuscai
  • lhammerl
  • iabraham
  • andras-marton-emarsys
  • nathan-matthews-sap
  • sfariel
  • schroedersteffen
  • botondjavorka
  • danielisap
  • gillyes
  • bronika
  • tade82
  • dpkemarsys
  • karlabrandl
  • mlesh-sap
  • tonyhsap
  • aidanlesh-sap
  • nikolett.tar
  • sridevir
  • cenglersap
  • birokhun
  • abieler-sap
  • i534456
  • daniel.balazs
  • laszlo.ori
  • troywiegand
  • bcsizmadia
  • ariceem
  • csjakabos
  • borcsa
  • nnieman-sap
  • sap-am
  • vszegedi
  • ronnykrosse
  • taylor-seth
  • mrclsu
  • fcolombo-sap
  • mfawal
  • szb
  • ahorvath1991
  • torokhelen
  • matusekma