Skip to content

Commit 6f4621d

Browse files
Update readme for multi namespace support (#2416)
Update readme for multi namespace support
1 parent a2455af commit 6f4621d

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

temporal-spring-boot-autoconfigure/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,4 +256,61 @@ public class Test {
256256
}
257257
```
258258

259+
# Running Multiple Name Space (experimental)
259260

261+
Along with the root namespace, you can configure multiple non-root namespaces in the application.yml file. Different namespaces can have different configurations including but not limited to different connection options, registered workflows/activities, data converters etc.
262+
263+
```yml
264+
spring.temporal:
265+
namespaces:
266+
- namespace: assign
267+
alias: assign
268+
workers-auto-discovery:
269+
packages: com.component.temporal.assign
270+
workers:
271+
- task-queue: global
272+
- namespace: unassign
273+
alias: unassign
274+
workers-auto-discovery:
275+
packages: com.component.temporal.unassign
276+
workers:
277+
- task-queue: global
278+
```
279+
280+
## Customization
281+
282+
All customization points for the root namespace also exist for the non-root namespaces. To specify for a particular
283+
namespace users just need to append the alias/namespace to the bean.
284+
285+
```java
286+
// TemporalOptionsCustomizer type beans must start with the namespace/alias you defined and end with function class
287+
// name you want to customizer and concat Customizer as the bean name.
288+
@Bean
289+
TemporalOptionsCustomizer<WorkflowServiceStubsOptions.Builder> assignWorkflowServiceStubsCustomizer() {
290+
return builder -> builder.setKeepAliveTime(Duration.ofHours(1));
291+
}
292+
293+
// Data converter is also supported
294+
@Bean
295+
DataConverter assignDataConverter() {
296+
return DataConverter.getDefaultInstance();
297+
}
298+
```
299+
300+
## Injecting
301+
302+
If you want to autowire different `WorkflowClient` instances from different namespaces, you can use the `@Resource`
303+
annotation with the bean name corresponding to the namespace alias + `WorkflowClient`:
304+
305+
```java
306+
// temporalWorkflowClient is the primary and rootNamespace bean.
307+
@Resource
308+
WorkflowClient workflowClient;
309+
310+
// Bean name here corresponds to the namespace/alias + Simple Class Name
311+
@Resource(name = "assignWorkflowClient")
312+
private WorkflowClient assignWorkflowClient;
313+
314+
@Resource(name = "unassignWorkflowClient")
315+
private WorkflowClient unassignWorkflowClient;
316+
```

0 commit comments

Comments
 (0)