File tree 1 file changed +14
-4
lines changed
stocker/src/main/java/org/camunda/bpm/demo/stocker 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change 26
26
import org .slf4j .LoggerFactory ;
27
27
import org .springframework .beans .factory .annotation .Autowired ;
28
28
import org .springframework .stereotype .Component ;
29
+ import static org .camunda .bpm .engine .variable .Variables .*;
29
30
30
31
/**
31
32
* @author Daniel Meyer
@@ -46,15 +47,24 @@ protected void registerWorker() {
46
47
registration = camundaClient .registerWorker ()
47
48
.lockTime (120 )
48
49
.topicName ("reserveOrderItems" )
50
+ .variableNames ("order" )
49
51
.worker (new Worker () {
50
52
public void doWork (TaskContext taskContext ) {
51
- JsonValue orderValue = taskContext .getVariableTyped ("reserveOrderItems" );
52
53
53
- SpinList <SpinJsonNode > orderItems = orderValue .getValue ()
54
- .prop ("orderItems" ).elements ();
54
+ JsonValue orderValue = taskContext .getVariable ("order" );
55
+ if (orderValue == null ) {
56
+ taskContext .taskFailed ("Variable 'order' does not exist." );
57
+ }
58
+ else {
59
+ SpinJsonNode orderData = orderValue .getValue ();
60
+
61
+ SpinList <SpinJsonNode > orderItems = orderData .prop ("orderItems" ).elements ();
55
62
56
- for (SpinJsonNode orderItem : orderItems ) {
63
+ for (SpinJsonNode orderItem : orderItems ) {
64
+ orderItem .prop ("reserved" , true );
65
+ }
57
66
67
+ taskContext .complete (createVariables ().putValue ("order" , orderValue ));
58
68
}
59
69
60
70
}
You can’t perform that action at this time.
0 commit comments