1.120.0 • Published 9 months ago

@biorate/amqp v1.120.0

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

AMQP

AMQP connector

Examples:

import { inject, container, Types, Core } from '@biorate/inversion';
import { IConfig, Config } from '@biorate/config';
import { AmqpConnector } from '@biorate/amqp';

const connectionName = 'amqp';
const channelName = 'test';

export class Root extends Core() {
  @inject(AmqpConnector) public connector: AmqpConnector;
}

container.bind<IConfig>(Types.Config).to(Config).inSingletonScope();
container.bind<AmqpConnector>(AmqpConnector).toSelf().inSingletonScope();
container.bind<Root>(Root).toSelf().inSingletonScope();

container.get<IConfig>(Types.Config).merge({
  Amqp: [
    {
      name: connectionName,
      urls: ['amqp://localhost:5672'],
    },
  ],
});

const root = <Root>container.get<Root>(Root);

(async () => {
  root.connector.createChannel(connectionName, {
    name: channelName,
    json: true,
    setup: async (channel: Channel) => {
      await channel.assertExchange('test-exchange', 'topic');
      await channel.assertQueue('test-queue', { exclusive: true, autoDelete: true });
      await channel.bindQueue('test-queue', 'test-exchange', '#send');
      await channel.consume('test-queue', (data: ConsumeMessage | null) => {
        console.log(data?.content?.toString?.()); // {"test": 1}
      });
    },
  });
  root.connector.channel(channelName)!.publish('test-exchange', '#send', { test: 1 });
})();

Learn

  • Documentation can be found here - docs.

Release History

See the CHANGELOG

License

MIT

Copyright (c) 2021-present Leonid Levkin (llevkin)

1.96.0

1 year ago

1.95.1

1 year ago

1.91.5

1 year ago

1.95.0

1 year ago

1.91.4

1 year ago

1.93.1

1 year ago

1.91.3

1 year ago

1.93.0

1 year ago

1.91.2

1 year ago

1.91.1

1 year ago

1.91.0

1 year ago

1.90.0

1 year ago

1.100.0

11 months ago

1.120.0

9 months ago

1.104.0

11 months ago

1.102.0

11 months ago

1.102.1

11 months ago

1.76.3

2 years ago

1.72.0

2 years ago

1.65.4

2 years ago

1.60.0

2 years ago