IMQService.(constructor)
Constructs a service.
Signature:
constructor(options?: Partial<IMQServiceOptions>, name?: string);
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
options |
Partial<IMQServiceOptions> |
(Optional) service options, shallow-merged over DEFAULT_IMQ_SERVICE_OPTIONS, except |
|
name |
string |
(Optional) overrides the class name as the service/queue name, and as the description cache key |
Exceptions
TypeError when IMQService is instantiated directly. Note the check is by resolved name, so passing 'IMQService' as the name of a subclass throws as well.
Remarks
Constructing a service installs process signal handlers for SIGTERM, SIGINT, SIGHUP and SIGQUIT. On any of them the service tears the queue down, closes the metrics server, and then force-exits with code 0 after IMQ_SHUTDOWN_TIMEOUT — a fixed timer, not a drain: requests still being processed are not awaited.
With IMQServiceOptions.drain on — or IMQ_DRAIN_ENABLE=1 — SIGTERM and SIGINT instead start a graceful drain: stop consuming, await the requests already in flight for at most IMQServiceOptions.drainTimeout, then tear down and exit 0. That drain takes over from every signal handler this package registered, including this service's own for SIGHUP/SIGQUIT and any client's in the same process, and forces handleSignals: false on the queue so the queue layer does not exit mid-drain. Handlers registered by anything other than this package are never touched.
The merged options are passed straight to the queue factory, so vendor and cluster/clusterManagers select the transport implementation.
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.