Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
errorhandler-nxg-cg
Advanced tools
Library to connect to a message broker (like rabbitmq) and create a specific queue for error handling purposes.
[
This code has the objective to send messages to a message broker (like rabbitmq) queues for the N3xGen Platform (NXGP). This messages primarily will send an error message from NXGP components to be handled.
This library is useful to add into the NXGP components developed by their owners in order to have information for errors at flows execution time.
As components are used in the NXGP flows regardless that the library should be added on component code, when the flow is running, an exchange and some queues are created using the ID flow (assigned from NXGP). In the case of the queues, two queues are created for each step in the NXGP flow.
The queue naming structure is as follows:
flow�flowID:stepName:messages
flow�flowID:stepName:rebounds
Using the same structure for the NXGP error handler queue (for each step) the next queue is created, internally, by the errorhandler-nxg-cg library.
flow�flowID:stepName:deadletter
Where "flow" is a constant word, the "flowID" is the ID assigned by the NXGP to the flow, the "stepName" is the name configured to each node in the flow and the words "message"/"rebounds"/"deadletter" are constants.
And it is configured an exchange (the same used by the other queues).
Once this configuration is created by the library, messages can be sent to this queue.
The library can be installed from npm page with the next:
npm install errorhandler-nxg-cg
, npm i errorhandler-nxg-cg
or yarn install errorhandler-nxg-cg
//Sample applied into a component function for NXGP
module.exports.process = async function processTrigger(msg, cfg, snapshot = {}) {
try {
await msgbkr.prepareErrorQueue();
//Your code here...
} catch (e) {
console.error(`ERROR: ${e}`);
this.emit('error', e);
}
};
Resultant sample:
* Note: The library requires that the NXGP has the "ELASTICIO_LISTEN_MESSAGES_ON
" environment variable. If this variable is not available, the library defines an auto-generated queue and exchange.
//Sample applied into a component function for NXGP
module.exports.process = async function processTrigger(msg, cfg, snapshot = {}) {
try {
await msgbkr.producerMessage(msg,'myQueueName');
//Your code here...
} catch (e) {
console.error(`ERROR: ${e}`);
this.emit('error', e);
}
};
Resultant sample:
* Note: The library requires that the NXGP has the "ELASTICIO_LISTEN_MESSAGES_ON
" environment variable. If this variable is not available, the library defines an auto-generated queue and exchange (using the QueueName argument).
//Sample applied into a component function for NXGP
module.exports.process = async function processTrigger(msg, cfg, snapshot = {}) {
try {
let {data} = msg;
//Your code here...
} catch (e) {
console.error(`ERROR: ${e}`);
this.emit('error', e);
await msgbkr.producerErrorMessage(msg, e);
}
};
Resultant sample:
* Note: The library requires that the NXGP has the "ELASTICIO_LISTEN_MESSAGES_ON
" environment variable. If this variable is not available, the library defines an auto-generated queue and exchange.
The library contains a testing code that allows the user the behavior of the original code. This sample code shows to the user how to use the methods the library has.
The user must keep in mind that this code is developed to work without the NXGP, and according to this the code creates the default queues as explained at the end of each method explanation (at section 2).
To run the testing code the next command can be used (the starting location must be the code folder of this library):
npm test
FAQs
Library to connect to a message broker (like rabbitmq) and create a specific queue for error handling purposes.
The npm package errorhandler-nxg-cg receives a total of 1 weekly downloads. As such, errorhandler-nxg-cg popularity was classified as not popular.
We found that errorhandler-nxg-cg demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.