messagingClient

Creates messaging client reader for given transport layer

Importing

import { messagingClient } from '@marblejs/messaging';

Type declaration

messagingClient :: MessagingClientConfig
-> Reader<Context, Promise<MessagingClient>>

Parameters

parameter

definition

config

MessagingClientConfig

MessagingClientConfig

parameter

definition

msgTransformer

<optional> TransportMessageTransformer

transport

Transport (see: #createMicroservice)

options

StrategyOptions (see: #createMicroservice)

Because of asynchronous nature of messaging client, all created readers have to be bound to server creators via eager binding ๐Ÿ‘‰ #bindEagerlyToโ€‹

To learn more about messagingClient output interface please visit:

Example (AMQP):

import { bindEagerlyTo, createContextToken } from '@marblejs/core';
import { messagingClient, Transport } from '@marblejs/messaging';
โ€‹
const AmqpClientToken = createContextToken<MessagingClient>('AmqpClient');
โ€‹
const AmqpClient = messagingClient({
transport: Transport.AMQP,
options: {
host: 'amqp://localhost:5672',
queue: 'some_queue_name',
queueOptions: { durable: false },
timeout: 360 * 1000,
},
});
โ€‹
...
โ€‹
const dependencies = [
bindEagerlyTo(AmqpClientToken)(AmqpClient),
];
โ€‹

Example (REDIS):

import { bindEagerlyTo, createContextToken } from '@marblejs/core';
import { messagingClient, Transport } from '@marblejs/messaging';
โ€‹
const RedisClientToken = createContextToken<MessagingClient>('RedisClient');
โ€‹
const RedisClient = messagingClient({
transport: Transport.REDIS,
options: {
host: 'redis://127.0.0.1:6379',
channel: 'some_channel_name',
timeout: 360 * 1000,
},
});
โ€‹
...
โ€‹
const dependencies = [
bindEagerlyTo(RedisClientToken)(RedisClient),
];
โ€‹