Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@pebula/nesbus

0.0.5 • Public • Published

@pebula/nesbus

Documentation npm (scoped)

NesBus (Nest / Service Bus) is a microservice extension for NestJS that adds support for Azure Service Bus within NestJS in a simple and intuitive way.

It simplifies how we use and manage service bus through an declarative API that automate message handling & emitter registration:

Message Handling

Handling incoming service bus message is now as easy as handling incoming REST requests.

@Controller()
export class ServiceBusController {
  @Queue<MethodDecorator>(({
    name: 'nesbus-queue.demo'
  })
  async myQueueEntity(@Ctx() contextSbContext) {
  }
}

Client Emitters

Defining service bus emitters (Sender) requires no logic, you can compose a client emitter in seconds:

@Injectable()
export class ServiceBusEmitClient {
 
  @QueueEmitter({
    name: 'nesbus-queue.demo'
  })
  myQueueEntity: Sender;
}

Easy Setup

The library also helps with service bus entity management through a declarative API for automatic creation of service bus entities based on the entities we define in the controllers / services in our application.

We call it provision.

This allows a code-first approach for service bus management and architecture.

Leverage Advanced Architecture Patterns

By simplifying the work with service bus, Nesbus enables the use of more advanced architecture patterns that you can use to manage the flow of your application.

Using Observables you can now implement a CQRS or Event Sourcing models out of the box. In addition, Observables along with Interceptors allow us to use plugins that encapsulate behaviors for us.

For example, the SbBackoffRetry plugin wraps incoming service bus messages and handles them when their handler throws. It will perform a retry to handle them again but with a delay between each try. The delay is not constant and it is based on an algorithm (linear / exponential) so the effect of periodic stress on you server is reduced.

Install

npm i @pebula/nesbus

DownloadsWeekly Downloads

9

Version

0.0.5

License

MIT

Unpacked Size

1.97 MB

Total Files

570

Last publish

Collaborators

  • avatar