Coder Social home page Coder Social logo

e-commerce-api's Introduction

Amqp interface

this light-weight module helps in handling and managing amqp message dispatch to employ an error free solution

Usage

const amqpInterface = require('amqp-interface')
//this class will take an argument of arrays containing 
//the queues to be asserted 
let queue_names = ['Social', 'Error']
const app = new amqpInterface([...queue_names])

//if the connection string is not passed to the function 

//setup an ENV variable called AMQP_CONN_URI
//or it would default to 'amqp://guest:[email protected]:5672/'

//or add it as the first argument as such

let overrideURI = {
    uri: process.env.WHATEVER_AMQP_URI_STRING
}

app.setupChannel(overrideURI)
    .then(res=>{
        console.log('Interface Setup is complete!!')
    })
    .catch(err=>{
        console.log('Error occured but you can still continue publishing your messages they wont get lost !!')
    })

 

Now to publish to the queue

Here where the magic happens. if there is an error, the interface will continue trying to reconnect to the amqp server while recieving these messages on the queue, dangerous aproach right, dont worry the interfaces got you covered. When there is a crash, the queue is automatically saved to a file called queue.offline.json and is completely merged if the application is restarted and the amqp server is still down and flushed immediately if the amqp server is up and running again

//publishing to a queue named Social as defined in Class above 
//with the messages ===> { helo: 'spansdem' }
 app.publishToQueue('Social', { helo: 'spansdem' })

e-commerce-api's People

Contributors

aremumahmud avatar

Watchers

 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.