{
  "id": "streamreader",
  "title": "StreamReader",
  "url": "https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/gears-v1/jvm/classes/readers/streamreader/",
  "summary": "Reads Redis stream data.",
  "tags": [
    "docs",
    "operate",
    "stack"
  ],
  "last_updated": "2026-04-22T11:55:45+02:00",
  "page_type": "content",
  "content_hash": "4635a8cd10aab0280177e0dc6f47120c70ad1b5862c0f7945c1267771bc31a58",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Reads Redis stream data."
    },
    {
      "id": "parameters",
      "title": "Parameters",
      "role": "parameters",
      "text": "| Name | Type | Default value | Description |\n|------|------|---------------|-------------|\n| batchSize | integer | 1 | The number of new messages that will cause the functions to run |\n| duration | integer | 0 | How many seconds to wait before execution, regardless of batch size |\n| failurePolicy | FailurePolicy | FailurePolicy.CONTINUE | How to handle execution failure (CONTINUE/ABORT/RETRY) |\n| failureRetryInterval | integer | 5000 | The number of seconds to wait before retrying |\n| pattern | string | \"\\*\" (match all keys) | The pattern of keys that store streams |\n| startId | string | \"0-0\" | Start reading from this stream ID |\n| trimStream | boolean | true | Whether or not to trim the stream |"
    },
    {
      "id": "output-records",
      "title": "Output records",
      "role": "returns",
      "text": "Creates a record for each message in the input stream.\n\nEach record is a `HashMap<String, Object>` with the following fields:\n\n| Name | Type | Description |\n|------|------|-------------|\n| id | string | The message's ID |\n| key | string | The stream key name |\n| value | HashMap<String, byte[]> | The message's data |"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "The following example creates a `StreamReader` with default values:\n\n[code example]\n\nTo change the parameter values for a `StreamReader`, use their setter methods:\n\n[code example]"
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "java",
      "code": "StreamReader reader = new StreamReader();",
      "section_id": "examples"
    },
    {
      "id": "examples-ex1",
      "language": "java",
      "code": "StreamReader reader = new StreamReader();\n// Get streams for keys that match \"weather\"\nreader.setPattern(\"weather\");\n// Run RedisGears functions after every 10 messages\nreader.setBatchSize(10);",
      "section_id": "examples"
    }
  ]
}
