You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/develop/php/message-passing.mdx
+83Lines changed: 83 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,9 @@ keywords:
8
8
- signals
9
9
- queries
10
10
- updates
11
+
- dynamic signals
12
+
- dynamic queries
13
+
- dynamic updates
11
14
tags:
12
15
- Workflows
13
16
- Messages
@@ -839,3 +842,83 @@ When working with Queries, you may encounter these errors:
839
842
840
843
-**The handler caused the Workflow Task to fail.**
841
844
This would happen, for example, if the Query handler blocks the thread for too long without yielding.
845
+
846
+
## Dynamic components {#dynamic-handler}
847
+
848
+
Temporal supports Dynamic Queries, Signals, and Updates.
849
+
These are unnamed handlers that are invoked if no other statically defined handler with the given name exists.
850
+
851
+
Dynamic Handlers provide flexibility to handle cases where the names of Queries, Signals, or Updates aren't known at run time.
852
+
853
+
:::caution
854
+
855
+
Dynamic Handlers should be used judiciously as a fallback mechanism rather than the primary approach.
856
+
Overusing them can lead to maintainability and debugging issues down the line.
857
+
858
+
Instead, Signals, or Queries should be defined statically whenever possible, with clear names that indicate their purpose.
859
+
Use static definitions as the primary way of structuring your Workflows.
860
+
861
+
Reserve Dynamic Handlers for cases where the handler names are not known at development time and need to be looked up dynamically at runtime.
862
+
They are meant to handle edge cases and act as a catch-all, not as the main way of invoking logic.
863
+
864
+
:::
865
+
866
+
### How to set a Dynamic Query {#set-a-dynamic-query}
867
+
868
+
A Dynamic Query in Temporal is a Query method that is invoked dynamically at runtime if no other Query with the same name is registered.
869
+
Use [`Workflow::registerDynamicQuery()`](https://php.temporal.io/classes/Temporal-Workflow.html#method_registerDynamicQuery) to set a dynamic Query handler.
870
+
871
+
The Query Handler parameters must accept a `string` name and [`ValuesInterface`](https://php.temporal.io/classes/Temporal-DataConverter-ValuesInterface.html) for the arguments.
### How to set a Dynamic Signal {#set-a-dynamic-signal}
884
+
885
+
A Dynamic Signal in Temporal is a Signal that is invoked dynamically at runtime if no other Signal with the same input is registered.
886
+
Use [`Workflow::registerDynamicSignal()`](https://php.temporal.io/classes/Temporal-Workflow.html#method_registerDynamicSignal) to set a dynamic Signal handler.
887
+
888
+
The Signal Handler parameters must accept a `string` name and [`ValuesInterface`](https://php.temporal.io/classes/Temporal-DataConverter-ValuesInterface.html) for the arguments.
### How to set a Dynamic Update {#set-a-dynamic-update}
901
+
902
+
A Dynamic Update in Temporal is an Update that is invoked dynamically at runtime if no other Update with the same input is registered.
903
+
Use [`Workflow::registerDynamicUpdate()`](https://php.temporal.io/classes/Temporal-Workflow.html#method_registerDynamicUpdate) to set a dynamic Update handler.
904
+
905
+
The method accepts two arguments:
906
+
907
+
- Update Handler
908
+
- Update Validator (optional) that should throw an exception if the validation fails
909
+
910
+
Both the Handler and the Validator must accept a `string` name and [`ValuesInterface`](https://php.temporal.io/classes/Temporal-DataConverter-ValuesInterface.html) for the arguments.
0 commit comments