Changing WorkflowMethod param type

Hi there I would like to change the worfklow method and activity method param type.

I have a couple of questions

Question 1
My understanding is that if I have something like this

@WorkflowMethod
fun myWorkflowMethod(foo: UUID)

it is is safe to change the signature to

@WorkflowMethod
fun myWorkflowMethod(foo: UUID, myWorkflowStruct: Input)

where Input is a struct/class similar to { foo: UUID, }

Is this correct and the recommend approach?

Question 2

After all workflows have migrated to using my updated signature, Can I remove the first “foo” param entirely or would that break backwards compatibility

Do the answer to the above two change for activity methods?

Hi @Abhishek_Sharma1

I think if you add a new parameter it will be converted to null during replay, so your code has to be backward compatible. Note from our doc that “we strongly recommend that objects are used as parameters, so that the object’s individual fields may be altered without breaking the signature of the Workflow.”

After all workflows have migrated to using my updated signature, Can I remove the first “foo” param entirely or would that break backwards compatibility

You can if you don’t query closed workflows (which will make workers replay those workflows)

I would test any change with workflow.replay first Develop code that durably executes - Java SDK dev guide | Learn Temporal

Do the answer to the above two change for activity methods?

Activity inputs are not deserialized for completed/failed activities, only the output.

For pending activities, the new parameter will be converted to null, so your code has to be backward compatible. I think this thread can be helpful too Non Determinism

Antonio.

It will break backwards compatibility as only adding and removing arguments at the end of the argument list is backwards compatible.