This is not supported. The invocation of workflows and activities is essentially RPC. Even if we decided to support them, Java makes it practically impossible as there is no runtime information about generic types. And this information is needed for deserialization of the payloads.
ok thanks,
As a workaround wondering if you would recommend using something like JsonNode?
E.g
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
@WorkflowInterface
public interface HelloWorkflow {
@WorkflowMethod
<T> int execute(JsonNode jsonNode, TypeReference<T> typeReference)
}
public interface HelloWorkflowImpl implements HelloWorkflow {
@Override
public <T> int execute(JsonNode jsonNode, TypeReference<T> typeReference) {
final T value = getValue(jsonNode, typeReference);
// do something
}
public <T> T getValue(JsonNode jsonNode, TypeReference<T> typeReference) {
try {
return objectMapper.readValue(
jsonNode.toString(), typeReference);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
}
Now while calling workflow I can convert pojo to JsonNode
e.g
Class Employee<T> {
T getValue();
}
JsonNode employeeJsonNode = convert(employee);
execute(employeeJsonNode, new TypeReference<Employee<Finance>>() {})
What is the business problem you are trying to solve? Workflow client and workflow definitions live in different processes. What is the benefit of generics here?