{
  "id": "register",
  "title": "Register",
  "url": "https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/gears-v1/jvm/classes/gearsbuilder/register/",
  "summary": "Registers the pipeline of functions to run when certain events occur.",
  "tags": [
    "docs",
    "operate",
    "stack"
  ],
  "last_updated": "2026-04-22T11:55:45+02:00",
  "page_type": "content",
  "content_hash": "2049acdd6184b2dac81bc260ea29f04b56f45a8ffcae4e265118f9394aa9e185",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "[code example]\n\nRegisters the pipeline of functions to run when certain [events](https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/gears-v1/register-events) occur. The registered functions will run each time the event occurs.\n\nExecution modes:\n\n| Name | Description |\n|------|-------------|\n| ASYNC | Runs asynchronously on all of the shards. |\n| ASYNC_LOCAL | Runs asynchronously but only on the current shard that generated the event. |\n| SYNC | Runs synchronously only on the same shard that generated the event. |\n\n\nIf you call `register()` without specifying an execution mode, it will default to `ASYNC`."
    },
    {
      "id": "parameters",
      "title": "Parameters",
      "role": "parameters",
      "text": "| Name | Type | Description |\n|------|------|-------------|\n| mode | ExecutionMode | The execution mode to use (ASYNC/ASYNC_LOCAL/SYNC) |\n| onRegister | OnRegisteredOperation | Register callback that will be called on each shard upon register |\n| onUnregistered | OnUnregisteredOperation | Unregister callback that will be called on each shard upon unregister |"
    },
    {
      "id": "returns",
      "title": "Returns",
      "role": "returns",
      "text": "Returns a registration ID."
    },
    {
      "id": "example",
      "title": "Example",
      "role": "example",
      "text": "[code example]"
    }
  ],
  "examples": [
    {
      "id": "overview-ex0",
      "language": "java",
      "code": "public java.lang.String register()\n\npublic java.lang.String register​(ExecutionMode mode)\n\npublic java.lang.String register​(\n    ExecutionMode mode, \n    gears.operations.OnRegisteredOperation onRegister, \n    gears.operations.OnUnregisteredOperation onUnregistered)",
      "section_id": "overview"
    },
    {
      "id": "example-ex0",
      "language": "java",
      "code": "GearsBuilder.CreateGearsBuilder(reader).register();",
      "section_id": "example"
    }
  ]
}
