Giter VIP home page Giter VIP logo

test-bull-redis-queue's Introduction

Test Redis Queue

Test using Redis queue with bull library to make sure one message is only consumed by one consumer at the one time.

Prerequisite

  • Docker
  • NodeJS

Testing Strategy

  • Producer produce message to Redis, each message contain unique content data.
  • Start multi consumers listen to the Redis in the same queue.
  • Consumers will write the content to MongoDB.
  • After finish, check is there any duplicated content data in MongoDB.

Flow of producer and consumer

flow

Run

Run Redis and MongoDB

docker compose up

Open another terminal and run

node index.js

The expected output:

==> Data is cleared
2022-10-02T14:30:54.476Z producer Redis connected
2022-10-02T14:30:54.706Z producer Total messages sent: 100
2022-10-02T14:30:54.830Z producer Total messages sent: 200
2022-10-02T14:30:54.951Z producer Total messages sent: 300
...
...
2022-10-02T14:31:10.005Z producer Total messages sent: 9800
2022-10-02T14:31:10.141Z producer Total messages sent: 9900
2022-10-02T14:31:10.278Z producer Total messages sent: 10000
Producer exited. Wait 5 seconds for consumers process all messages
Consumers exited. Start verifier
2022-10-02T14:31:15.587Z verifier Database connected
==> Total records 10000
==> Aggregate duplicated result []
==> No duplicated

test-bull-redis-queue's People

Watchers

James Cloos avatar Raymond Phu Nguyen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.