LogoLogo
ChangelogGitHubTwitterGitter
v3.x
v3.x
  • Marble.js
  • Getting started
    • Installation
    • Quick setup
  • HTTP
    • Effects
    • Middlewares
    • Routing
    • Errors
    • Output
    • Context
    • Advanced
      • Logging
      • Validation
      • Server Events
      • Streaming
      • Continuous mode
  • Messaging
    • Core concepts
      • Events
      • Effects
    • Microservices
      • AMQP (RabbitMQ)
      • Redis Pub/Sub
    • CQRS
    • WebSockets
  • Testing
    • HTTP routes testing
  • Other
    • How does it glue together?
    • Migration guides
      • Migration from version 2.x
      • Migration from version 1.x
    • API reference
      • core
        • bindTo
        • bindEagerlyTo
        • createEvent
        • createServer
        • combineRoutes
        • createContextToken
        • EffectFactory
        • r.pipe
        • httpListener
        • operator: matchEvent
        • operator: use
        • operator: act
      • messaging
        • eventBus
        • messagingClient
        • createMicroservice
        • reply
      • websockets
        • webSocketListener
        • operator: broadcast
        • operator: mapToServer
      • middleware-multipart
      • middleware-cors
      • middleware-joi
      • middleware-jwt
        • Token signing
      • middleware-io
      • middleware-logger
      • middleware-body
    • Style Guide
    • FAQ
Powered by GitBook
On this page
  • Installation
  • Overview
  1. Messaging
  2. Microservices

Redis Pub/Sub

Redis Pub/Sub implements the messaging system where the publishers sends the messages while the subscribers receive them.

PreviousAMQP (RabbitMQ)NextCQRS

Last updated 5 years ago

Aside from data storage, can be used as a Publisher/Subscriber platform. In this pattern, publishers can issue messages to any number of subscribers on a channel. These messages are fire-and-forget, in that if a message is published and no subscribers exists, the message evaporates and cannot be recovered.

Installation

Before the usage remember to install required packages.

$ yarn add redis

Overview

import { createMicroservice, Transport } from '@marblejs/messaging';

const microservice = createMicroservice({
  transport: Transport.REDIS
  options: {
    host: 'redis://127.0.0.1:6379',
    channel: 'hello_channel',
  },
  // ...
});
import { createMicroservice, Transport } from '@marblejs/messaging';

const client = messagingClient({
  transport: Transport.REDIS
  options: {
    host: 'redis://127.0.0.1:6379',
    channel: 'hello_channel',
  },
  // ...
});

The options property is specific to the chosen transport layer. REDIS exposes the following properties:

Attribute

description

host

Host address of the Redis server

channel

Channel name which your microservice will listen to

timeout

Timeout for RPC-like communication. Defaults to 120 seconds

port

Port of the Redis server

password

If set, client will run Redis auth command on connect.

Redis