Skip to content

Function: queueEntrypoint() ​

queueEntrypoint(queueComponentName, options?): EntrypointAdapter<QueueContext<{ }>>

The adapter of the queue channel: it consumes the queues of the @QueueAction actions through a Queue component (by its registration name) and delivers each message to its action, in a QueueContext. The options of the actions are checked and their groups registered when the adapter starts (an ordered action on a driver without the ordering fails it); the messages are consumed once the application has launched. When the application stops, the consumers stop and the messages being processed complete (shutdownTimeout of the entrypoint); the ones still running then are delivered again later, neither acknowledged nor sent to the dead letter queue.

Parameters ​

queueComponentName ​

string

The name of the Queue component.

options? ​

QueueEntrypointOptions

The name, the middlewares and the error handler of the adapter.

Returns ​

EntrypointAdapter<QueueContext<{ }>>

The adapter, for the queue option of the entrypoint.

Example ​

typescript
import {Application} from 'lakutata'
import {buildEntrypoints, Controller} from 'lakutata/com/entrypoint'
import {buildQueueOptions, QueueAction, queueEntrypoint} from '@lakutata/queue'

class MailController extends Controller {
    @QueueAction('mail.send')
    public async send(input: {to: string}): Promise<void> {
        console.log('mail to', input.to)
    }
}

Application.run(() => ({
    id: 'mail.app',
    name: 'Mail',
    components: {
        queue: buildQueueOptions(),
        entrypoint: buildEntrypoints({
            controllers: [MailController],
            queue: queueEntrypoint('queue')
        })
    },
    //Created at launch: the actions consume from then on
    bootstrap: ['entrypoint']
}))

Released under the MIT License.