BusConfiguration
Creates a configuration in order to initialize a new BusInstance.
Methods
withHandler(classHandler)
Registers a class handler that receives a message and performs a unit of work. When Bus is initialized it will configure the transport to subscribe to the type of message handled by the handler and upon receipt will forward the message through to the handle()
function.
Arguments
Argument | Description | Default |
---|---|---|
| A class responsible for handling messages that implements Handler | None |
Example
withHandler(functionHandler)
Registers a function handler that receives a message and performs a unit of work. When Bus is initialized it will configure the transport to subscribe to the type of message handled by the function handler and upon receipt will forward the message to the function.
Arguments
Argument | Description | Default |
---|---|---|
| A functional handler mapping initialized using | None |
Example
withCustomHandler(messageHandler, customResolver)
Registers a custom handler that receives messages from external systems, or messages that don't implement the Message interface from @node-ts/bus-messages.
Arguments
Argument | Description | Default |
---|---|---|
| A handler that receives the custom message | None |
| A discriminator that determines if an incoming message should be mapped to this handler | None |
Example
See also System messages.
withWorkflow(workflow)
Registers a workflow definition so that all of the messages it depends on will be subscribed to and forwarded to the handlers inside the workflow.
Arguments
Argument | Description | Default |
---|---|---|
| Workflow definition to register | None |
Example
See also Workflows.
withTransport(transport)
Configures Bus to use a different transport than the default MemoryQueue.
Arguments
Argument | Description | Default |
---|---|---|
| A configured transport to use | None |
Example
See also Transports.
withLogger(loggerFactory)
Configures Bus to use a different logging provider than the default consoler logger.
Arguments
Argument | Description | Default |
---|---|---|
| A factory that creates a new logger | None |
Example
See also Loggers.
withSerializer(serializer)
Configures Bus to use a different serialization provider. The provider is responsible for transforming messages to/from a serialized representation, as well as ensuring all object properties are a strong type.
Arguments
Argument | Description | Default |
---|---|---|
| Serializer to use | None |
Example
See also Serializer.
withPersistence(persistence)
Configures Bus to use a different persistence provider than the default InMemoryPersistence provider. This is used to persist workflow data and is unused if not using workflows.
Arguments
Argument | Description | Default |
---|---|---|
| Persistence provider to use | None |
Example
See also Persistence.
withConcurrency(concurrency)
Sets the message handling concurrency beyond the default value of 1, which will increase the number of messages handled in parallel.concurrency
Arguments
Argument | Description | Default |
---|---|---|
| The number of messages that can be handled in parallel | None |
Example
withContainer(containerAdapter)
Use a local dependency injection/IoC container to resolve handlers and workflows.
Configures Bus to use a different persistence provider than the default InMemoryPersistence provider. This is used to persist workflow data and is unused if not using workflows.
Arguments
Argument | Description | Default |
---|---|---|
| An adapter that allows Bus to resolve class instances from the underlying IoC container | None |
Example
See also Dependency injection.
withMessageReadMiddleware(middleware)
Run custom middleware before/after the point a message is read from the transport and then dispatched to handlers and workflow handlers.
Arguments
Argument | Description | Default |
---|---|---|
| A middleware function that will be executed after a message is read from the transport and before it is dispatched to handlers. | None |
Example
See also Middleware.
withRetryStrategy(retryStrategy)
Configure the bus to use a different retry strategy instead of the default.
Arguments
Argument | Description | Default |
---|---|---|
| An implementation of |
|
Example
See also Retry Strategies.
initialize([options])
Initialize a configured BusInstance. This should be called after all options have been provided for the configuration.
Last updated