Clients -
nats :
Producer
The producer provides the capability to publish messages to the NATS server.
The nats:Producer
needs the nats:Connection
to be initialized.
Constructor
__init
(Connection connection)
- connection Connection
-
An established NATS connection
Remote Methods
publish | Publishes data to a given subject.
|
request | Publishes data to a given subject and waits for a response.
|
Methods
Closes a given connection.
Publishes data to a given subject.
nats:Error? result = producer->publish(subject, <@untainted>message);
Parameters
- subject string
-
The subject to send the message
- data Content
-
Data to publish
- replyTo string | service | () (default ())
-
The subject or the callback service to which the receiver should send the response
-
Return Type
(Error?) ()
or else anats:Error
if there is a problem when publishing the message
Publishes data to a given subject and waits for a response.
nats:Message|nats:Error reqReply = producer->request(subject, <@untainted>message, 5000);
Parameters
- subject string
-
The subject to send the message
- data Content
-
Data to publish
- duration int? (default ())
-
The time (in milliseconds) to wait for the response