I tried to find a way to access the property of a signal within the default signal handler activity:
– Input of the activity is a parameter “signal” of type “AnySignal”.
– I know the specific type of the signal is “MySignal”, which has a property “message”.
– I thus tried to cast AnySignal to MySignal and to access the property on the casted object.
– However the cast doesn’t seem to work – the payload is empty.
Any other suggestions?
Another solution for your problem is that you define a second default handler with your concrete signal type as first parameter. This signal handler will be called instead of the more general signal handler with signal type AnySignal. In this case you do not need a cast. You can look at the attached model.
On the other hand the casting works for me.
log(“Info”, “Signal”, “Type”, signal.typeOf());
log(“Info”, “Signal”, “Content”, signal.classToXML().transcodeToString(“utf-8”));
log(“Info”, “Event”, “Content”, event.classToXML().transcodeToString(“utf-8”));
set mysignal = cast(signal);
log(“Info”, “Signal”, “Payload”, mysignal.payload);
The model is attached. The default signal handler is called if you create the object and then send the signal step1 twice.
If you send a signal which is not used in the state diagram then the default signal handler is not called. You can test this with error or restart. The reason for this is that the model compiler generates for each used signal an entry for the E2E Runtime.
Thank you. I also saw the flaw in the original attempt now:
The signal payload in the described example is itself of type “Any” (it’s a signal originally created by the BPMN importer). Therefore I’d need another cast to successfully access the original signal’s payload.
You must be logged in to reply to this topic.