5.12.108 • Published 10 months ago

@patrtorg/ipsum-nisi v5.12.108

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@patrtorg/ipsum-nisi

npm npm GitHub license npm

Welcome to @patrtorg/ipsum-nisi! 🚀

This guide will help you get started with setting up a Redis message broker system based on Redis Streams using this powerful tool. Below are step-by-step instructions on initializing the Redis connection, creating subscribers and publishers, handling rejected messages, and more.

!NOTE Make sure to replace placeholders such as 'channel', 'group', 'action', and data with your actual channel names, consumer groups, actions, and data objects.

Installation

You can install the @patrtorg/ipsum-nisi library using npm:

npm install @patrtorg/ipsum-nisi

Getting Started

Now let's dive into how you can use the @patrtorg/ipsum-nisi library in your Node.js applications.

Initialize the Redis Connection

To start using the library, you need to initialize the Redis connection. Here's how you can do it:

import @patrtorg/ipsum-nisi, { Subscriber, Publisher } from '@patrtorg/ipsum-nisi';
await @patrtorg/ipsum-nisi.bootstrap('redis://localhost:6379');

Create a Subscriber

Subscribers listen for messages on specific channels and consume them while assigned to a consumer group. You can create a subscriber instance like this:

const subscriber = new Subscriber({ channels: ['channel'], group: 'group' });
subscriber.subscribe(async ({ channel, action, data, id }) => {
  // Process the received message...
});

Create a Publisher

Publishers send messages to specific channels. Here's how you can create a publisher instance and publish a message:

const publisher = new Publisher({ channel: 'channel' });
const data = { foo: 'bar' };
await publisher.publish('action', data);

Unsubscribe and Stop the Redis Connection

When you're done with streaming messages, you can unsubscribe from channels and stop the Redis connection:

await subscriber.unsubscribe();
await @patrtorg/ipsum-nisi.stop();

Handle Rejected Messages

In case of rejected messages, you can read and reprocess them using the following methods:

await @patrtorg/ipsum-nisi.readRejectedMessages({ ids, from, to, action });
await @patrtorg/ipsum-nisi.reprocessRejectedMessages({ messages, ids, from, to, action });

Parameters:

  • ids (optional): An array of message IDs to filter rejected messages.
  • from (optional): The start date from which to filter rejected messages.
  • to (optional): The end date until which to filter rejected messages.
  • action (optional): Parameter used to filter rejected messages by a specific action.

If none of the previous parameters are defined, all messages will be retrieved.

  • messages(optional): Array of objects with optional properties: id, channel, group, and data. These properties are intended to republish the rejected messages (filtered by the previous parameters) to a different channel than they had, to a different consumer group from the one that revoked them, or with new properties in the data object.

Conclusion

That's it! You've learned how to set up a Redis message broker system using the @patrtorg/ipsum-nisi library. Feel free to explore more features and customize it according to your project's needs.

You can also find here a cool cheatsheet ❤️ about Redis Streams.

Happy messaging! 📨

5.12.108

10 months ago

5.12.107

10 months ago

5.12.106

10 months ago

4.12.106

10 months ago

4.12.105

10 months ago

4.12.104

10 months ago

4.12.103

10 months ago

4.12.102

10 months ago

4.12.101

10 months ago

4.12.100

10 months ago

4.12.99

10 months ago

4.12.98

10 months ago

4.12.97

10 months ago

4.12.96

10 months ago

4.11.96

10 months ago

4.10.96

11 months ago

4.10.95

11 months ago

4.9.95

11 months ago

4.8.95

11 months ago

4.7.95

11 months ago

4.7.94

11 months ago

4.7.93

11 months ago

4.7.92

11 months ago

4.7.91

11 months ago

4.7.90

11 months ago

4.7.89

11 months ago

4.7.88

11 months ago

4.7.87

11 months ago

4.7.86

11 months ago

4.7.85

11 months ago

4.7.84

11 months ago

4.7.83

11 months ago

4.7.82

11 months ago

4.7.81

11 months ago

4.7.80

11 months ago

4.7.79

11 months ago

4.6.79

11 months ago

4.6.78

11 months ago

4.6.77

11 months ago

4.6.76

11 months ago

4.6.75

11 months ago

4.6.74

11 months ago

4.6.73

11 months ago

4.6.72

11 months ago

4.6.71

11 months ago

4.6.70

12 months ago

4.6.69

12 months ago

4.6.68

12 months ago

4.6.67

12 months ago

4.5.67

12 months ago

4.5.66

12 months ago

4.5.65

12 months ago

4.5.64

12 months ago

4.5.63

12 months ago

4.5.62

12 months ago

4.4.62

12 months ago

4.4.61

12 months ago

4.4.60

12 months ago

4.4.59

12 months ago

4.4.58

12 months ago

4.4.57

12 months ago

4.3.57

12 months ago

4.3.56

12 months ago

4.3.55

12 months ago

4.3.54

12 months ago

4.3.53

1 year ago

3.3.53

1 year ago

3.3.52

1 year ago

3.3.51

1 year ago

3.3.50

1 year ago

3.3.49

1 year ago

3.3.48

1 year ago

3.3.47

1 year ago

3.3.46

1 year ago

3.3.45

1 year ago

3.3.44

1 year ago

3.3.43

1 year ago

3.3.42

1 year ago

3.3.41

1 year ago

3.3.40

1 year ago

3.3.39

1 year ago

3.3.38

1 year ago

3.3.37

1 year ago

3.3.36

1 year ago

3.3.35

1 year ago

2.3.35

1 year ago

2.3.34

1 year ago

2.3.33

1 year ago

2.3.32

1 year ago

2.3.31

1 year ago

2.3.30

1 year ago

2.3.29

1 year ago

2.3.28

1 year ago

2.3.27

1 year ago

2.3.26

1 year ago

2.3.25

1 year ago

2.3.24

1 year ago

2.3.23

1 year ago

2.3.22

1 year ago

2.3.21

1 year ago

1.3.21

1 year ago

1.3.20

1 year ago

1.3.19

1 year ago

1.3.18

1 year ago

1.3.17

1 year ago

1.3.16

1 year ago

1.3.15

1 year ago

1.3.14

1 year ago

1.3.13

1 year ago

1.2.13

1 year ago

1.2.12

1 year ago

1.2.11

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago