Storing and Retrieving State
State is stored using the StateManager's
clear methods. All of these methods require that a Scope be provided. It should be noted that the state that is stored with the Local scope is entirely different than state stored with a Cluster scope. If a Processor stores a value with the key of My Key using the
Scope.CLUSTER scope, and then attempts to retrieve the value using the
Scope.LOCAL scope, the value retrieved will be
null (unless a value was also stored with the same key using the
Scope.CLUSTER scope). Each Processor's state is stored in isolation from other Processors' state.
It follows, then, that two Processors cannot share the same state. There are, however, some circumstances in which it is very necessary to share state between two Processors of different types, or two Processors of the same type. This can be accomplished by using a Controller Service. By storing and retrieving state from a Controller Service, multiple Processors can use the same Controller Service and the state can be exposed via the Controller Service's API.