Difference between revisions of "Nats publish"
Jump to navigation
Jump to search
(Created page with "{{lc}} {{nats}}") |
|||
(13 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{lc}} | {{lc}} | ||
+ | [[nats]] pub | ||
+ | [[nats]] publish | ||
+ | [[nats publish --help]] | ||
− | {{nats}} | + | <pre><nowiki> nats pub testsubject --count 10 "Message {{Count}} @ {{Time}}"</nowiki></pre> |
+ | 10:38:45 Published 19 bytes to "testsubject" | ||
+ | 10:38:45 Published 19 bytes to "testsubject" | ||
+ | 10:38:45 Published 19 bytes to "testsubject" | ||
+ | 10:38:45 Published 19 bytes to "testsubject" | ||
+ | 10:38:45 Published 19 bytes to "testsubject" | ||
+ | 10:38:45 Published 19 bytes to "testsubject" | ||
+ | 10:38:45 Published 19 bytes to "testsubject" | ||
+ | 10:38:45 Published 19 bytes to "testsubject" | ||
+ | 10:38:45 Published 19 bytes to "testsubject" | ||
+ | 10:38:45 Published 20 bytes to "testsubject" | ||
+ | |||
+ | |||
+ | [[nats]] publish | ||
+ | <pre> | ||
+ | error: required argument 'subject' not provided | ||
+ | |||
+ | usage: nats publish [<flags>] <subject> [<body>] | ||
+ | |||
+ | Generic data publish utility | ||
+ | |||
+ | Body and Header values of the messages may use Go | ||
+ | templates to create unique messages. | ||
+ | |||
+ | nats pub test --count 10 "Message {{Count}} @ {{Time}}" | ||
+ | |||
+ | Multiple messages with random strings between 10 | ||
+ | and 100 long: | ||
+ | |||
+ | nats pub test --count 10 "Message {{Count}}: {{ Random 10 100 }}" | ||
+ | |||
+ | Available template functions are: | ||
+ | |||
+ | Count the message number | ||
+ | TimeStamp RFC3339 format current time | ||
+ | Unix seconds since 1970 in UTC | ||
+ | UnixNano nano seconds since 1970 in UTC | ||
+ | Time the current time | ||
+ | ID an unique ID | ||
+ | Random(min, max) random string at least min long, at most max | ||
+ | |||
+ | Args: | ||
+ | <subject> Subject to subscribe to | ||
+ | [<body>] Message body | ||
+ | |||
+ | Flags: | ||
+ | --reply=REPLY Sets a custom reply to | ||
+ | subject | ||
+ | -H, --header=HEADER ... Adds headers to the | ||
+ | message | ||
+ | --count=1 Publish multiple | ||
+ | messages | ||
+ | --sleep=SLEEP When publishing multiple | ||
+ | messages, sleep between | ||
+ | publishes | ||
+ | --force-stdin Force reading from stdin | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | |||
+ | == Related == | ||
+ | * <code>[[nats subscribe]]</code> | ||
+ | |||
+ | == See also == | ||
+ | * {{nats pub}} | ||
+ | * {{nats}} | ||
+ | |||
+ | [[Category:NATS]] |
Latest revision as of 12:56, 9 July 2024
nats pub nats publish nats publish --help
nats pub testsubject --count 10 "Message {{Count}} @ {{Time}}"
10:38:45 Published 19 bytes to "testsubject" 10:38:45 Published 19 bytes to "testsubject" 10:38:45 Published 19 bytes to "testsubject" 10:38:45 Published 19 bytes to "testsubject" 10:38:45 Published 19 bytes to "testsubject" 10:38:45 Published 19 bytes to "testsubject" 10:38:45 Published 19 bytes to "testsubject" 10:38:45 Published 19 bytes to "testsubject" 10:38:45 Published 19 bytes to "testsubject" 10:38:45 Published 20 bytes to "testsubject"
nats publish
error: required argument 'subject' not provided usage: nats publish [<flags>] <subject> [<body>] Generic data publish utility Body and Header values of the messages may use Go templates to create unique messages. nats pub test --count 10 "Message {{Count}} @ {{Time}}" Multiple messages with random strings between 10 and 100 long: nats pub test --count 10 "Message {{Count}}: {{ Random 10 100 }}" Available template functions are: Count the message number TimeStamp RFC3339 format current time Unix seconds since 1970 in UTC UnixNano nano seconds since 1970 in UTC Time the current time ID an unique ID Random(min, max) random string at least min long, at most max Args: <subject> Subject to subscribe to [<body>] Message body Flags: --reply=REPLY Sets a custom reply to subject -H, --header=HEADER ... Adds headers to the message --count=1 Publish multiple messages --sleep=SLEEP When publishing multiple messages, sleep between publishes --force-stdin Force reading from stdin
Related[edit]
See also[edit]
Advertising: