I am using both go-SDK and java-SDK. I find they 2 are handling signals differently.
In golang, if I add a receive callback to the selector and do not call the selector. select, the callback will not be called and the signals are unhandled.
testSelector.Select(ctx) // this is required for the AddReceive to be called, merely register the callback does not help
func createTestSelector(ctx workflow.Context) workflow.Selector {
logger := workflow.GetLogger(ctx)
submitSelector := workflow.NewSelector(ctx)
submitChannel := workflow.GetSignalChannel(ctx, SINGALCHANNEL_TEST)
submitSelector.AddReceive(submitChannel, func(ch workflow.ReceiveChannel, more bool) {
var val string
isChClosed := ch.Receive(ctx, &val)
logger.Debug("[test] received:", val, isChClosed)
})
return submitSelector
}
But in java, a simple @ SignalMethod suffices to handle the signals.
So why does golang add another level of requirement for signal handling?