github.com/Jeffail/benthos/v3@v3.65.0/website/docs/components/inputs/nats_stream.md (about)

     1  ---
     2  title: nats_stream
     3  type: input
     4  status: stable
     5  categories: ["Services"]
     6  ---
     7  
     8  <!--
     9       THIS FILE IS AUTOGENERATED!
    10  
    11       To make changes please edit the contents of:
    12       lib/input/nats_stream.go
    13  -->
    14  
    15  import Tabs from '@theme/Tabs';
    16  import TabItem from '@theme/TabItem';
    17  
    18  
    19  Subscribe to a NATS Stream subject. Joining a queue is optional and allows
    20  multiple clients of a subject to consume using queue semantics.
    21  
    22  
    23  <Tabs defaultValue="common" values={[
    24    { label: 'Common', value: 'common', },
    25    { label: 'Advanced', value: 'advanced', },
    26  ]}>
    27  
    28  <TabItem value="common">
    29  
    30  ```yaml
    31  # Common config fields, showing default values
    32  input:
    33    label: ""
    34    nats_stream:
    35      urls:
    36        - nats://127.0.0.1:4222
    37      cluster_id: test-cluster
    38      client_id: benthos_client
    39      queue: benthos_queue
    40      subject: benthos_messages
    41      durable_name: benthos_offset
    42      unsubscribe_on_close: false
    43  ```
    44  
    45  </TabItem>
    46  <TabItem value="advanced">
    47  
    48  ```yaml
    49  # All config fields, showing default values
    50  input:
    51    label: ""
    52    nats_stream:
    53      urls:
    54        - nats://127.0.0.1:4222
    55      cluster_id: test-cluster
    56      client_id: benthos_client
    57      queue: benthos_queue
    58      subject: benthos_messages
    59      durable_name: benthos_offset
    60      unsubscribe_on_close: false
    61      start_from_oldest: true
    62      max_inflight: 1024
    63      ack_wait: 30s
    64      tls:
    65        enabled: false
    66        skip_cert_verify: false
    67        enable_renegotiation: false
    68        root_cas: ""
    69        root_cas_file: ""
    70        client_certs: []
    71      auth:
    72        nkey_file: ""
    73        user_credentials_file: ""
    74  ```
    75  
    76  </TabItem>
    77  </Tabs>
    78  
    79  Tracking and persisting offsets through a durable name is also optional and
    80  works with or without a queue. If a durable name is not provided then subjects
    81  are consumed from the most recently published message.
    82  
    83  When a consumer closes its connection it unsubscribes, when all consumers of a
    84  durable queue do this the offsets are deleted. In order to avoid this you can
    85  stop the consumers from unsubscribing by setting the field
    86  `unsubscribe_on_close` to `false`.
    87  
    88  ### Metadata
    89  
    90  This input adds the following metadata fields to each message:
    91  
    92  ``` text
    93  - nats_stream_subject
    94  - nats_stream_sequence
    95  ```
    96  
    97  You can access these metadata fields using
    98  [function interpolation](/docs/configuration/interpolation#metadata).
    99  
   100  ### Authentication
   101  
   102  There are several components within Benthos which utilise NATS services. You will find that each of these components
   103  support optional advanced authentication parameters for [NKeys](https://docs.nats.io/nats-server/configuration/securing_nats/auth_intro/nkey_auth)
   104  and [User Credentials](https://docs.nats.io/developing-with-nats/security/creds).
   105  
   106  An in depth tutorial can be found [here](https://docs.nats.io/developing-with-nats/tutorials/jwt).
   107  
   108  #### NKey file
   109  
   110  The NATS server can use these NKeys in several ways for authentication. The simplest is for the server to be configured
   111  with a list of known public keys and for the clients to respond to the challenge by signing it with its private NKey
   112  configured in the `nkey_file` field.
   113  
   114  More details [here](https://docs.nats.io/developing-with-nats/security/nkey).
   115  
   116  #### User Credentials file
   117  
   118  NATS server supports decentralized authentication based on JSON Web Tokens (JWT). Clients need an [user JWT](https://docs.nats.io/nats-server/configuration/securing_nats/jwt#json-web-tokens)
   119  and a corresponding [NKey secret](https://docs.nats.io/developing-with-nats/security/nkey) when connecting to a server
   120  which is configured to use this authentication scheme.
   121  
   122  The `user_credentials_file` field should point to a file containing both the private key and the JWT and can be
   123  generated with the [nsc tool](https://docs.nats.io/nats-tools/nsc).
   124  
   125  More details [here](https://docs.nats.io/developing-with-nats/security/creds).
   126  
   127  ## Fields
   128  
   129  ### `urls`
   130  
   131  A list of URLs to connect to. If an item of the list contains commas it will be expanded into multiple URLs.
   132  
   133  
   134  Type: `array`  
   135  Default: `["nats://127.0.0.1:4222"]`  
   136  
   137  ```yaml
   138  # Examples
   139  
   140  urls:
   141    - nats://127.0.0.1:4222
   142  
   143  urls:
   144    - nats://username:password@127.0.0.1:4222
   145  ```
   146  
   147  ### `cluster_id`
   148  
   149  The ID of the cluster to consume from.
   150  
   151  
   152  Type: `string`  
   153  Default: `"test-cluster"`  
   154  
   155  ### `client_id`
   156  
   157  A client ID to connect as.
   158  
   159  
   160  Type: `string`  
   161  Default: `"benthos_client"`  
   162  
   163  ### `queue`
   164  
   165  The queue to consume from.
   166  
   167  
   168  Type: `string`  
   169  Default: `"benthos_queue"`  
   170  
   171  ### `subject`
   172  
   173  A subject to consume from.
   174  
   175  
   176  Type: `string`  
   177  Default: `"benthos_messages"`  
   178  
   179  ### `durable_name`
   180  
   181  Preserve the state of your consumer under a durable name.
   182  
   183  
   184  Type: `string`  
   185  Default: `"benthos_offset"`  
   186  
   187  ### `unsubscribe_on_close`
   188  
   189  Whether the subscription should be destroyed when this client disconnects.
   190  
   191  
   192  Type: `bool`  
   193  Default: `false`  
   194  
   195  ### `start_from_oldest`
   196  
   197  If a position is not found for a queue, determines whether to consume from the oldest available message, otherwise messages are consumed from the latest.
   198  
   199  
   200  Type: `bool`  
   201  Default: `true`  
   202  
   203  ### `max_inflight`
   204  
   205  The maximum number of unprocessed messages to fetch at a given time.
   206  
   207  
   208  Type: `int`  
   209  Default: `1024`  
   210  
   211  ### `ack_wait`
   212  
   213  An optional duration to specify at which a message that is yet to be acked will be automatically retried.
   214  
   215  
   216  Type: `string`  
   217  Default: `"30s"`  
   218  
   219  ### `tls`
   220  
   221  Custom TLS settings can be used to override system defaults.
   222  
   223  
   224  Type: `object`  
   225  
   226  ### `tls.enabled`
   227  
   228  Whether custom TLS settings are enabled.
   229  
   230  
   231  Type: `bool`  
   232  Default: `false`  
   233  
   234  ### `tls.skip_cert_verify`
   235  
   236  Whether to skip server side certificate verification.
   237  
   238  
   239  Type: `bool`  
   240  Default: `false`  
   241  
   242  ### `tls.enable_renegotiation`
   243  
   244  Whether to allow the remote server to repeatedly request renegotiation. Enable this option if you're seeing the error message `local error: tls: no renegotiation`.
   245  
   246  
   247  Type: `bool`  
   248  Default: `false`  
   249  Requires version 3.45.0 or newer  
   250  
   251  ### `tls.root_cas`
   252  
   253  An optional root certificate authority to use. This is a string, representing a certificate chain from the parent trusted root certificate, to possible intermediate signing certificates, to the host certificate.
   254  
   255  
   256  Type: `string`  
   257  Default: `""`  
   258  
   259  ```yaml
   260  # Examples
   261  
   262  root_cas: |-
   263    -----BEGIN CERTIFICATE-----
   264    ...
   265    -----END CERTIFICATE-----
   266  ```
   267  
   268  ### `tls.root_cas_file`
   269  
   270  An optional path of a root certificate authority file to use. This is a file, often with a .pem extension, containing a certificate chain from the parent trusted root certificate, to possible intermediate signing certificates, to the host certificate.
   271  
   272  
   273  Type: `string`  
   274  Default: `""`  
   275  
   276  ```yaml
   277  # Examples
   278  
   279  root_cas_file: ./root_cas.pem
   280  ```
   281  
   282  ### `tls.client_certs`
   283  
   284  A list of client certificates to use. For each certificate either the fields `cert` and `key`, or `cert_file` and `key_file` should be specified, but not both.
   285  
   286  
   287  Type: `array`  
   288  Default: `[]`  
   289  
   290  ```yaml
   291  # Examples
   292  
   293  client_certs:
   294    - cert: foo
   295      key: bar
   296  
   297  client_certs:
   298    - cert_file: ./example.pem
   299      key_file: ./example.key
   300  ```
   301  
   302  ### `tls.client_certs[].cert`
   303  
   304  A plain text certificate to use.
   305  
   306  
   307  Type: `string`  
   308  Default: `""`  
   309  
   310  ### `tls.client_certs[].key`
   311  
   312  A plain text certificate key to use.
   313  
   314  
   315  Type: `string`  
   316  Default: `""`  
   317  
   318  ### `tls.client_certs[].cert_file`
   319  
   320  The path to a certificate to use.
   321  
   322  
   323  Type: `string`  
   324  Default: `""`  
   325  
   326  ### `tls.client_certs[].key_file`
   327  
   328  The path of a certificate key to use.
   329  
   330  
   331  Type: `string`  
   332  Default: `""`  
   333  
   334  ### `auth`
   335  
   336  Optional configuration of NATS authentication parameters.
   337  
   338  
   339  Type: `object`  
   340  
   341  ### `auth.nkey_file`
   342  
   343  An optional file containing a NKey seed.
   344  
   345  
   346  Type: `string`  
   347  Default: `""`  
   348  
   349  ```yaml
   350  # Examples
   351  
   352  nkey_file: ./seed.nk
   353  ```
   354  
   355  ### `auth.user_credentials_file`
   356  
   357  An optional file containing user credentials which consist of an user JWT and corresponding NKey seed.
   358  
   359  
   360  Type: `string`  
   361  Default: `""`  
   362  
   363  ```yaml
   364  # Examples
   365  
   366  user_credentials_file: ./user.creds
   367  ```
   368  
   369