Clients - nats : Producer

NATS producer would act as a streaming client allowing to stream messages between NATS streaming server. Producer would create a new NATS connection if a connection was not provided during the initialization.

send

(string subject, string | json message, string charset)

returns string | error

Produces a message to a NATS streaming server for the given subject.

Parameters

  • subject string
  • Could also be referred as the 'topic/queue' name.

  • message string | json
  • Message could be either a string or json representation.

  • charset string - UTF-8
  • Encoding of the message (by defaults it would be UTF-8).

  • Return Type

    (string | error)
  • GUID of acknowledgment or the specific error.

requestReply

(string subject, string | json message, string charset)

returns Message | error

Produces a message and would wait for a response.

Parameters

  • subject string
  • Would represent the topic/queue name.

  • message string | json
  • Message could be either a string or json representation.

  • charset string - UTF-8
  • Encoding of the message by default it would be UTF-8.

  • Return Type

    (Message | error)
  • Response message or an error.

close

()

returns error?

Close a given connection.

  • Return Type

    (error?)
  • () or error if unable to complete close operation.