or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

activities.mdclient.mddata-conversion.mdexceptions.mdindex.mdworkers.mdworkflows.md

workers.mddocs/

0

# Worker Configuration and Management

1

2

APIs for configuring and managing Temporal workers that execute workflow and activity code, with options for concurrency, task routing, and performance tuning.

3

4

## Capabilities

5

6

### Worker Factory

7

8

Factory for creating and managing worker instances.

9

10

```java { .api }

11

/**

12

* Factory for creating and managing worker instances.

13

*/

14

public interface WorkerFactory {

15

/**

16

* Creates worker factory with workflow client.

17

* @param workflowClient workflow client instance

18

* @return worker factory

19

*/

20

static WorkerFactory newInstance(WorkflowClient workflowClient);

21

22

/**

23

* Creates worker factory with options.

24

* @param workflowClient workflow client instance

25

* @param factoryOptions factory options

26

* @return worker factory

27

*/

28

static WorkerFactory newInstance(WorkflowClient workflowClient, WorkerFactoryOptions factoryOptions);

29

30

/**

31

* Creates worker for task queue.

32

* @param taskQueue task queue name

33

* @return worker instance

34

*/

35

Worker newWorker(String taskQueue);

36

37

/**

38

* Creates worker with options.

39

* @param taskQueue task queue name

40

* @param options worker options

41

* @return worker instance

42

*/

43

Worker newWorker(String taskQueue, WorkerOptions options);

44

45

/**

46

* Gets workflow client.

47

* @return workflow client

48

*/

49

WorkflowClient getWorkflowClient();

50

51

/**

52

* Starts all workers in this factory.

53

*/

54

void start();

55

56

/**

57

* Shuts down all workers.

58

*/

59

void shutdown();

60

61

/**

62

* Shuts down and waits for termination.

63

* @param timeout maximum wait time

64

* @param unit time unit

65

* @return true if terminated within timeout

66

*/

67

boolean shutdownAndAwaitTermination(long timeout, TimeUnit unit);

68

69

/**

70

* Awaits termination of all workers.

71

* @param timeout maximum wait time

72

* @param unit time unit

73

* @return true if terminated within timeout

74

*/

75

boolean awaitTermination(long timeout, TimeUnit unit);

76

77

/**

78

* Checks if factory is started.

79

* @return true if started

80

*/

81

boolean isStarted();

82

83

/**

84

* Checks if factory is shutdown.

85

* @return true if shutdown

86

*/

87

boolean isShutdown();

88

89

/**

90

* Checks if factory is terminated.

91

* @return true if terminated

92

*/

93

boolean isTerminated();

94

95

/**

96

* Suspends polling on all workers.

97

*/

98

@Experimental

99

void suspendPolling();

100

101

/**

102

* Resumes polling on all workers.

103

*/

104

@Experimental

105

void resumePolling();

106

}

107

```

108

109

**Usage Examples:**

110

111

```java

112

public class WorkerFactoryExample {

113

public static void main(String[] args) {

114

// Create workflow client

115

WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();

116

WorkflowClient client = WorkflowClient.newInstance(service);

117

118

// Create worker factory

119

WorkerFactory factory = WorkerFactory.newInstance(client);

120

121

// Create workers for different task queues

122

Worker orderWorker = factory.newWorker("order-processing");

123

orderWorker.registerWorkflowImplementationTypes(OrderWorkflowImpl.class);

124

orderWorker.registerActivitiesImplementations(new OrderActivitiesImpl());

125

126

Worker paymentWorker = factory.newWorker("payment-processing",

127

WorkerOptions.newBuilder()

128

.setMaxConcurrentActivityExecutions(10)

129

.setMaxConcurrentWorkflowTaskExecutions(5)

130

.build()

131

);

132

paymentWorker.registerWorkflowImplementationTypes(PaymentWorkflowImpl.class);

133

paymentWorker.registerActivitiesImplementations(new PaymentActivitiesImpl());

134

135

// Start all workers

136

factory.start();

137

138

// Shutdown hook

139

Runtime.getRuntime().addShutdownHook(new Thread(() -> {

140

factory.shutdown();

141

try {

142

if (!factory.awaitTermination(10, TimeUnit.SECONDS)) {

143

System.err.println("Workers did not terminate within timeout");

144

}

145

} catch (InterruptedException e) {

146

Thread.currentThread().interrupt();

147

}

148

}));

149

150

System.out.println("Workers started");

151

}

152

}

153

```

154

155

### Worker

156

157

Individual worker for executing workflows and activities.

158

159

```java { .api }

160

/**

161

* Individual worker for executing workflows and activities.

162

*/

163

public interface Worker {

164

/**

165

* Registers workflow implementation types.

166

* @param workflowImplementationClasses workflow implementation classes

167

*/

168

void registerWorkflowImplementationTypes(Class<?>... workflowImplementationClasses);

169

170

/**

171

* Registers workflow implementation types with options.

172

* @param options registration options

173

* @param workflowImplementationClasses workflow implementation classes

174

*/

175

void registerWorkflowImplementationTypes(WorkflowImplementationOptions options, Class<?>... workflowImplementationClasses);

176

177

/**

178

* Registers activities implementations.

179

* @param activityImplementations activity implementation instances

180

*/

181

void registerActivitiesImplementations(Object... activityImplementations);

182

183

/**

184

* Registers activities implementations with options.

185

* @param options registration options

186

* @param activityImplementations activity implementation instances

187

*/

188

void registerActivitiesImplementations(ActivityImplementationOptions options, Object... activityImplementations);

189

190

/**

191

* Adds workflow implementation factory.

192

* @param workflowInterface workflow interface class

193

* @param factory workflow instance factory

194

*/

195

<R> void addWorkflowImplementationFactory(Class<R> workflowInterface, Func<R> factory);

196

197

/**

198

* Adds workflow implementation factory with options.

199

* @param options registration options

200

* @param workflowInterface workflow interface class

201

* @param factory workflow instance factory

202

*/

203

<R> void addWorkflowImplementationFactory(WorkflowImplementationOptions options, Class<R> workflowInterface, Func<R> factory);

204

205

/**

206

* Adds activity implementation factory.

207

* @param activityInterface activity interface class

208

* @param factory activity instance factory

209

*/

210

<R> void addActivityImplementationFactory(Class<R> activityInterface, Func<R> factory);

211

212

/**

213

* Adds activity implementation factory with options.

214

* @param options registration options

215

* @param activityInterface activity interface class

216

* @param factory activity instance factory

217

*/

218

<R> void addActivityImplementationFactory(ActivityImplementationOptions options, Class<R> activityInterface, Func<R> factory);

219

220

/**

221

* Starts the worker.

222

*/

223

void start();

224

225

/**

226

* Shuts down the worker.

227

*/

228

void shutdown();

229

230

/**

231

* Awaits worker termination.

232

* @param timeout maximum wait time

233

* @param unit time unit

234

* @return true if terminated within timeout

235

*/

236

boolean awaitTermination(long timeout, TimeUnit unit);

237

238

/**

239

* Checks if worker is started.

240

* @return true if started

241

*/

242

boolean isStarted();

243

244

/**

245

* Checks if worker is shutdown.

246

* @return true if shutdown

247

*/

248

boolean isShutdown();

249

250

/**

251

* Checks if worker is terminated.

252

* @return true if terminated

253

*/

254

boolean isTerminated();

255

256

/**

257

* Suspends polling for new tasks.

258

*/

259

@Experimental

260

void suspendPolling();

261

262

/**

263

* Resumes polling for new tasks.

264

*/

265

@Experimental

266

void resumePolling();

267

268

/**

269

* Checks if polling is suspended.

270

* @return true if polling is suspended

271

*/

272

@Experimental

273

boolean isPollingSupported();

274

275

/**

276

* Gets task queue name.

277

* @return task queue name

278

*/

279

String getTaskQueue();

280

281

/**

282

* Gets worker options.

283

* @return worker options

284

*/

285

WorkerOptions getOptions();

286

}

287

```

288

289

**Usage Examples:**

290

291

```java

292

public class WorkerExample {

293

public void setupWorkers() {

294

WorkerFactory factory = WorkerFactory.newInstance(client);

295

296

// Basic worker setup

297

Worker basicWorker = factory.newWorker("basic-tasks");

298

basicWorker.registerWorkflowImplementationTypes(BasicWorkflowImpl.class);

299

basicWorker.registerActivitiesImplementations(new BasicActivitiesImpl());

300

301

// Worker with custom options

302

Worker customWorker = factory.newWorker("custom-tasks",

303

WorkerOptions.newBuilder()

304

.setMaxConcurrentWorkflowTaskExecutions(20)

305

.setMaxConcurrentActivityExecutions(50)

306

.setWorkerActivationTimeout(Duration.ofSeconds(30))

307

.build()

308

);

309

310

// Register multiple workflow types

311

customWorker.registerWorkflowImplementationTypes(

312

OrderProcessingWorkflowImpl.class,

313

InventoryWorkflowImpl.class,

314

ShippingWorkflowImpl.class

315

);

316

317

// Register activities with factory

318

customWorker.addActivityImplementationFactory(

319

PaymentActivities.class,

320

() -> new PaymentActivitiesImpl(paymentService)

321

);

322

323

// Register workflow with factory for dependency injection

324

customWorker.addWorkflowImplementationFactory(

325

ComplexWorkflow.class,

326

() -> new ComplexWorkflowImpl(configService.getConfig())

327

);

328

329

factory.start();

330

}

331

332

public void demonstrateWorkerLifecycle() {

333

Worker worker = factory.newWorker("lifecycle-demo");

334

335

// Register implementations

336

worker.registerWorkflowImplementationTypes(DemoWorkflowImpl.class);

337

338

// Check status

339

assert !worker.isStarted();

340

assert !worker.isShutdown();

341

342

// Start worker

343

worker.start();

344

assert worker.isStarted();

345

346

// Suspend polling during maintenance

347

worker.suspendPolling();

348

349

// Resume after maintenance

350

worker.resumePolling();

351

352

// Shutdown gracefully

353

worker.shutdown();

354

try {

355

if (!worker.awaitTermination(30, TimeUnit.SECONDS)) {

356

System.err.println("Worker did not terminate within timeout");

357

}

358

} catch (InterruptedException e) {

359

Thread.currentThread().interrupt();

360

}

361

}

362

}

363

```

364

365

### Worker Options

366

367

Configuration options for worker behavior including concurrency limits and timeouts.

368

369

```java { .api }

370

/**

371

* Configuration options for worker behavior including concurrency limits and timeouts.

372

*/

373

public final class WorkerOptions {

374

/**

375

* Creates new builder.

376

* @return new WorkerOptions builder

377

*/

378

public static Builder newBuilder();

379

380

/**

381

* Creates builder from existing options.

382

* @param options existing options to copy

383

* @return new builder with copied options

384

*/

385

public static Builder newBuilder(WorkerOptions options);

386

387

/**

388

* Returns default instance.

389

* @return default WorkerOptions

390

*/

391

public static WorkerOptions getDefaultInstance();

392

393

/**

394

* Builder for WorkerOptions.

395

*/

396

public static final class Builder {

397

/**

398

* Maximum concurrent workflow task executions.

399

* @param maxConcurrentWorkflowTaskExecutions maximum concurrent workflow tasks

400

* @return this builder

401

*/

402

public Builder setMaxConcurrentWorkflowTaskExecutions(int maxConcurrentWorkflowTaskExecutions);

403

404

/**

405

* Maximum concurrent activity executions.

406

* @param maxConcurrentActivityExecutions maximum concurrent activities

407

* @return this builder

408

*/

409

public Builder setMaxConcurrentActivityExecutions(int maxConcurrentActivityExecutions);

410

411

/**

412

* Maximum concurrent local activity executions.

413

* @param maxConcurrentLocalActivityExecutions maximum concurrent local activities

414

* @return this builder

415

*/

416

public Builder setMaxConcurrentLocalActivityExecutions(int maxConcurrentLocalActivityExecutions);

417

418

/**

419

* Maximum workflow task queue poll thread count.

420

* @param maxWorkerActivitiesPerSecond max activities per second

421

* @return this builder

422

*/

423

public Builder setMaxWorkerActivitiesPerSecond(double maxWorkerActivitiesPerSecond);

424

425

/**

426

* Maximum activity task queue poll thread count.

427

* @param maxTaskQueueActivitiesPerSecond max task queue activities per second

428

* @return this builder

429

*/

430

public Builder setMaxTaskQueueActivitiesPerSecond(double maxTaskQueueActivitiesPerSecond);

431

432

/**

433

* Default workflow task start-to-close timeout.

434

* @param defaultWorkflowTaskStartToCloseTimeout default timeout

435

* @return this builder

436

*/

437

public Builder setDefaultWorkflowTaskStartToCloseTimeout(Duration defaultWorkflowTaskStartToCloseTimeout);

438

439

/**

440

* Default activity task start-to-close timeout.

441

* @param defaultActivityTaskStartToCloseTimeout default timeout

442

* @return this builder

443

*/

444

public Builder setDefaultActivityTaskStartToCloseTimeout(Duration defaultActivityTaskStartToCloseTimeout);

445

446

/**

447

* Default local activity task start-to-close timeout.

448

* @param defaultLocalActivityStartToCloseTimeout default timeout

449

* @return this builder

450

*/

451

public Builder setDefaultLocalActivityStartToCloseTimeout(Duration defaultLocalActivityStartToCloseTimeout);

452

453

/**

454

* Task queue poll timeout.

455

* @param taskQueuePollTimeout poll timeout

456

* @return this builder

457

*/

458

public Builder setTaskQueuePollTimeout(Duration taskQueuePollTimeout);

459

460

/**

461

* Enable logging of replay events.

462

* @param enableLoggingInReplay true to enable

463

* @return this builder

464

*/

465

public Builder setEnableLoggingInReplay(boolean enableLoggingInReplay);

466

467

/**

468

* Sticky queue schedule-to-start timeout.

469

* @param stickyQueueScheduleToStartTimeout sticky timeout

470

* @return this builder

471

*/

472

public Builder setStickyQueueScheduleToStartTimeout(Duration stickyQueueScheduleToStartTimeout);

473

474

/**

475

* Disable sticky execution.

476

* @param disableStickyExecution true to disable

477

* @return this builder

478

*/

479

public Builder setDisableStickyExecution(boolean disableStickyExecution);

480

481

/**

482

* Worker activation timeout.

483

* @param workerActivationTimeout activation timeout

484

* @return this builder

485

*/

486

public Builder setWorkerActivationTimeout(Duration workerActivationTimeout);

487

488

/**

489

* Local activity worker only mode.

490

* @param localActivityWorkerOnly true for local activity only

491

* @return this builder

492

*/

493

public Builder setLocalActivityWorkerOnly(boolean localActivityWorkerOnly);

494

495

/**

496

* Default deadlock detection timeout.

497

* @param defaultDeadlockDetectionTimeout deadlock timeout

498

* @return this builder

499

*/

500

public Builder setDefaultDeadlockDetectionTimeout(Duration defaultDeadlockDetectionTimeout);

501

502

/**

503

* Maximum fatal error count before shutdown.

504

* @param maxConcurrentWorkflowTaskPollers max pollers

505

* @return this builder

506

*/

507

public Builder setMaxConcurrentWorkflowTaskPollers(int maxConcurrentWorkflowTaskPollers);

508

509

/**

510

* Maximum concurrent activity task pollers.

511

* @param maxConcurrentActivityTaskPollers max pollers

512

* @return this builder

513

*/

514

public Builder setMaxConcurrentActivityTaskPollers(int maxConcurrentActivityTaskPollers);

515

516

/**

517

* Identity for this worker.

518

* @param identity worker identity

519

* @return this builder

520

*/

521

public Builder setIdentity(String identity);

522

523

/**

524

* Binary checksum for workflow compatibility.

525

* @param binaryChecksum binary checksum

526

* @return this builder

527

*/

528

public Builder setBinaryChecksum(String binaryChecksum);

529

530

/**

531

* Build ID for worker versioning (Experimental).

532

* @param buildId build ID

533

* @return this builder

534

*/

535

@Experimental

536

public Builder setBuildId(String buildId);

537

538

/**

539

* Use build ID for versioning (Experimental).

540

* @param useBuildIdForVersioning true to use build ID

541

* @return this builder

542

*/

543

@Experimental

544

public Builder setUseBuildIdForVersioning(boolean useBuildIdForVersioning);

545

546

/**

547

* Worker tuner for dynamic scaling (Experimental).

548

* @param workerTuner worker tuner

549

* @return this builder

550

*/

551

@Experimental

552

public Builder setWorkerTuner(WorkerTuner workerTuner);

553

554

/**

555

* Build the WorkerOptions.

556

* @return configured WorkerOptions

557

*/

558

public WorkerOptions build();

559

}

560

}

561

```

562

563

### Worker Factory Options

564

565

Options for worker factory configuration.

566

567

```java { .api }

568

/**

569

* Options for worker factory configuration.

570

*/

571

public final class WorkerFactoryOptions {

572

/**

573

* Creates new builder.

574

* @return new WorkerFactoryOptions builder

575

*/

576

public static Builder newBuilder();

577

578

/**

579

* Creates builder from existing options.

580

* @param options existing options to copy

581

* @return new builder with copied options

582

*/

583

public static Builder newBuilder(WorkerFactoryOptions options);

584

585

/**

586

* Returns default instance.

587

* @return default WorkerFactoryOptions

588

*/

589

public static WorkerFactoryOptions getDefaultInstance();

590

591

/**

592

* Builder for WorkerFactoryOptions.

593

*/

594

public static final class Builder {

595

/**

596

* Workflow host local poll thread count.

597

* @param workflowHostLocalPollThreadCount thread count

598

* @return this builder

599

*/

600

public Builder setWorkflowHostLocalPollThreadCount(int workflowHostLocalPollThreadCount);

601

602

/**

603

* Maximum fatal error count before factory shutdown.

604

* @param maxWorkflowThreadCount max thread count

605

* @return this builder

606

*/

607

public Builder setMaxWorkflowThreadCount(int maxWorkflowThreadCount);

608

609

/**

610

* Cache for sticky workflow executions.

611

* @param workflowCache workflow cache

612

* @return this builder

613

*/

614

public Builder setWorkflowCache(WorkflowCache workflowCache);

615

616

/**

617

* Disable eager workflow start.

618

* @param disableEagerWorkflowStart true to disable

619

* @return this builder

620

*/

621

public Builder setDisableEagerWorkflowStart(boolean disableEagerWorkflowStart);

622

623

/**

624

* Enable worker graceful shutdown.

625

* @param enableGracefulShutdown true to enable

626

* @return this builder

627

*/

628

public Builder setEnableGracefulShutdown(boolean enableGracefulShutdown);

629

630

/**

631

* Worker interceptors.

632

* @param workerInterceptors interceptor instances

633

* @return this builder

634

*/

635

public Builder setWorkerInterceptors(WorkerInterceptor... workerInterceptors);

636

637

/**

638

* Build the WorkerFactoryOptions.

639

* @return configured WorkerFactoryOptions

640

*/

641

public WorkerFactoryOptions build();

642

}

643

}

644

```

645

646

### Workflow Implementation Options

647

648

Options for registering workflow implementations.

649

650

```java { .api }

651

/**

652

* Options for registering workflow implementations.

653

*/

654

public final class WorkflowImplementationOptions {

655

/**

656

* Creates new builder.

657

* @return new WorkflowImplementationOptions builder

658

*/

659

public static Builder newBuilder();

660

661

/**

662

* Builder for WorkflowImplementationOptions.

663

*/

664

public static final class Builder {

665

/**

666

* Failure converter for this workflow type.

667

* @param failureConverter failure converter

668

* @return this builder

669

*/

670

public Builder setFailureConverter(FailureConverter failureConverter);

671

672

/**

673

* Data converter for this workflow type.

674

* @param dataConverter data converter

675

* @return this builder

676

*/

677

public Builder setDataConverter(DataConverter dataConverter);

678

679

/**

680

* Context propagators for this workflow type.

681

* @param contextPropagators context propagators

682

* @return this builder

683

*/

684

public Builder setContextPropagators(List<ContextPropagator> contextPropagators);

685

686

/**

687

* Workflow interceptors for this workflow type.

688

* @param workflowInterceptors workflow interceptors

689

* @return this builder

690

*/

691

public Builder setWorkflowInterceptors(WorkflowInterceptor... workflowInterceptors);

692

693

/**

694

* Default workflow method type.

695

* @param defaultWorkflowMethodType default method type

696

* @return this builder

697

*/

698

public Builder setDefaultWorkflowMethodType(Class<?> defaultWorkflowMethodType);

699

700

/**

701

* Build the WorkflowImplementationOptions.

702

* @return configured WorkflowImplementationOptions

703

*/

704

public WorkflowImplementationOptions build();

705

}

706

}

707

```

708

709

### Activity Implementation Options

710

711

Options for registering activity implementations.

712

713

```java { .api }

714

/**

715

* Options for registering activity implementations.

716

*/

717

public final class ActivityImplementationOptions {

718

/**

719

* Creates new builder.

720

* @return new ActivityImplementationOptions builder

721

*/

722

public static Builder newBuilder();

723

724

/**

725

* Builder for ActivityImplementationOptions.

726

*/

727

public static final class Builder {

728

/**

729

* Data converter for this activity type.

730

* @param dataConverter data converter

731

* @return this builder

732

*/

733

public Builder setDataConverter(DataConverter dataConverter);

734

735

/**

736

* Context propagators for this activity type.

737

* @param contextPropagators context propagators

738

* @return this builder

739

*/

740

public Builder setContextPropagators(List<ContextPropagator> contextPropagators);

741

742

/**

743

* Activity interceptors for this activity type.

744

* @param activityInterceptors activity interceptors

745

* @return this builder

746

*/

747

public Builder setActivityInterceptors(ActivityInterceptor... activityInterceptors);

748

749

/**

750

* Build the ActivityImplementationOptions.

751

* @return configured ActivityImplementationOptions

752

*/

753

public ActivityImplementationOptions build();

754

}

755

}

756

```

757

758

### Worker Tuning

759

760

Performance tuning utilities for dynamic worker scaling.

761

762

```java { .api }

763

/**

764

* Interface for dynamic worker tuning and scaling.

765

*/

766

public interface WorkerTuner {

767

/**

768

* Gets workflow slot supplier.

769

* @return slot supplier for workflows

770

*/

771

SlotSupplier<WorkflowSlotInfo> getWorkflowTaskSlotSupplier();

772

773

/**

774

* Gets activity slot supplier.

775

* @return slot supplier for activities

776

*/

777

SlotSupplier<ActivitySlotInfo> getActivityTaskSlotSupplier();

778

779

/**

780

* Gets local activity slot supplier.

781

* @return slot supplier for local activities

782

*/

783

SlotSupplier<LocalActivitySlotInfo> getLocalActivitySlotSupplier();

784

785

/**

786

* Shuts down the tuner.

787

*/

788

void shutdown();

789

790

/**

791

* Awaits tuner termination.

792

* @param timeout maximum wait time

793

* @param unit time unit

794

* @return true if terminated within timeout

795

*/

796

boolean awaitTermination(long timeout, TimeUnit unit);

797

}

798

799

/**

800

* Interface for supplying execution slots.

801

*/

802

public interface SlotSupplier<SI extends SlotInfo> {

803

/**

804

* Tries to reserve a slot.

805

* @param slotInfo slot information

806

* @return slot permit if available

807

*/

808

SlotPermit tryReserveSlot(SI slotInfo);

809

810

/**

811

* Marks a slot as used.

812

* @param slotInfo slot information

813

*/

814

void markSlotUsed(SI slotInfo);

815

816

/**

817

* Releases a slot.

818

* @param slotInfo slot information

819

*/

820

void releaseSlot(SI slotInfo);

821

822

/**

823

* Gets maximum slots available.

824

* @return maximum slot count

825

*/

826

int getMaximumSlots();

827

}

828

```

829

830

**Usage Examples:**

831

832

```java

833

public class WorkerTuningExample {

834

public void setupTunedWorker() {

835

// Create custom worker tuner

836

WorkerTuner tuner = new CustomWorkerTuner();

837

838

WorkerOptions options = WorkerOptions.newBuilder()

839

.setWorkerTuner(tuner)

840

.setMaxConcurrentWorkflowTaskExecutions(100)

841

.setMaxConcurrentActivityExecutions(200)

842

.build();

843

844

Worker worker = factory.newWorker("tuned-tasks", options);

845

worker.registerWorkflowImplementationTypes(HighThroughputWorkflowImpl.class);

846

worker.registerActivitiesImplementations(new ScalableActivitiesImpl());

847

}

848

849

public void configureHighPerformanceWorker() {

850

WorkerOptions options = WorkerOptions.newBuilder()

851

// High concurrency settings

852

.setMaxConcurrentWorkflowTaskExecutions(50)

853

.setMaxConcurrentActivityExecutions(100)

854

.setMaxConcurrentLocalActivityExecutions(200)

855

856

// Polling optimization

857

.setMaxConcurrentWorkflowTaskPollers(5)

858

.setMaxConcurrentActivityTaskPollers(10)

859

.setTaskQueuePollTimeout(Duration.ofSeconds(10))

860

861

// Performance tuning

862

.setWorkerActivationTimeout(Duration.ofSeconds(30))

863

.setDefaultWorkflowTaskStartToCloseTimeout(Duration.ofSeconds(30))

864

.setDefaultActivityTaskStartToCloseTimeout(Duration.ofMinutes(5))

865

866

// Sticky execution for better cache utilization

867

.setDisableStickyExecution(false)

868

.setStickyQueueScheduleToStartTimeout(Duration.ofSeconds(5))

869

870

.build();

871

872

Worker highPerfWorker = factory.newWorker("high-performance", options);

873

}

874

}

875

```