Listener: Listener

Isolated

Represents the NATS listener to which a subscription service should be bound in order to receive messages.

Constructor

Initializes the NATS listener.

1nats:Listener natsListener = check new(nats:DEFAULT_URL);
init (string | string[ ] url, *ConnectionConfiguration config)
  • url string | string[ ]
  • The NATS broker URL. For a clustered use case, provide the URLs as a string array

LifeCycle Methods

attach

Binds a service to the nats:Listener.

Methods

detach

Stops consuming messages and detaches the service from the nats:Listener.

'start

Starts the nats:Listener.

gracefulStop

Stops the nats:Listener gracefully.

immediateStop

Stops the nats:Listener forcefully.

attach

function attach(Service s, string[ ] | string? name) returns error?
Isolated Function

Binds a service to the nats:Listener.

1check natsListener.attach(service, "serviceName");

Parameters

  • s Service
  • The type descriptor of the service

  • name string[ ] | string? (default ())
  • The name of the service

Return Type

(error?)

() or else a nats:Error upon failure to attach

detach

function detach(Service s) returns error?
Isolated Function

Stops consuming messages and detaches the service from the nats:Listener.

1check natsListener.detach(service);

Parameters

  • s Service
  • The type descriptor of the service

Return Type

(error?)

() or else a nats:Error upon failure to detach

'start

function 'start() returns error?
Isolated Function

Starts the nats:Listener.

1check natsListener.'start();

Return Type

(error?)

() or else a nats:Error upon failure to start the listener

gracefulStop

function gracefulStop() returns error?
Isolated Function

Stops the nats:Listener gracefully.

1check natsListener.gracefulStop();

Return Type

(error?)

() or else a nats:Error upon failure to stop the listener

immediateStop

function immediateStop() returns error?
Isolated Function

Stops the nats:Listener forcefully.

1check natsListener.immediateStop();

Return Type

(error?)

() or else a nats:Error upon failure to stop the listener