I’m trying to specify my workflow and activity method param as predefined proto type. For example
@WorkflowInterface
SampleWorkflow {
@WorkflowMethod
void run(SampleProtoRequest request);
}
My attempt was that I implemented a ProtoPayloadConverter and compose it with the GsonJsonPayloadConverter to a highlevel data converter which is similar to GsonJsonPayloadDataConverter.
However, it looks like Temporal is still trying to cast Java string into my proto class (SampleProtoRequest). In this case, I wonder what is the right way to make Temporal workflow & activity aware of my proto based param?
Here is the stacktrace I get:
{
“payloads”: [
{
“metadata”: {
“encoding”: “json”
},
“data”: “{detailMessage:class java.lang.String cannot be cast to class snapchat.reach.schema.ReachAggregationRequest (java.lang.String is in module java.base of loader \u0027bootstrap\u0027; snapchat.reach.schema.ReachAggregationRequest is in unnamed module of loader \u0027app\u0027),stackTrace:snapchat.reach.aggregator.temporal.DailyReachAggregationWorkflowImpl.run(DailyReachAggregationWorkflowImpl.java:13)\njava.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\njava.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\njava.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\njava.base/java.lang.reflect.Method.invoke(Method.java:566)\nio.temporal.internal.sync.POJOWorkflowImplementationFactory$POJOWorkflowImplementation$RootWorkflowInvocationInterceptor.execute(POJOWorkflowImplementationFactory.java:283)\nio.temporal.common.interceptors.BaseWorkflowInvoker.execute(BaseWorkflowInvoker.java:39)\nio.temporal.internal.sync.POJOWorkflowImplementationFactory$POJOWorkflowImplementation.execute(POJOWorkflowImplementationFactory.java:247)\nio.temporal.internal.sync.WorkflowExecuteRunnable.run(WorkflowExecuteRunnable.java:52)\nio.temporal.internal.sync.SyncWorkflow.lambda$start$0(SyncWorkflow.java:117)\nio.temporal.internal.sync.CancellationScopeImpl.run(CancellationScopeImpl.java:104)\nio.temporal.internal.sync.WorkflowThreadImpl$RunnableWrapper.run(WorkflowThreadImpl.java:106)\njava.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)\njava.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)\njava.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\njava.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\njava.base/java.lang.Thread.run(Thread.java:834)\n,suppressedExceptions:,class:java.lang.ClassCastException}”
}
]
}
It looks like Temporal is still parsing the message using the default GsonJsonPayloadConverter.
Thanks,
Bill