Nested Activity Invocation

Hi everyone,
Just came across one scenario while integrating with temporal for one of the feature. In this scenario I invoked an activity function for which param is coming from another activity invocation.
For ex.:

String res = utilityActivity.ignoreException(
    () -> subscriptionActivity.chargeUser(Customer customer), "failure");

Here “utilityActivity” is handled on queue = “utilityQueue” and “subscriptionActivity” is handled on queue = “subscriptionQueue”.
While executing this I received some kind of serialisation exception but when I executed the following it worked:

String res = ignoreException(
    () -> subscriptionActivity.chargeUser(Customer customer), "failure");

All I did was to put the “ignoreException” function in the workflow class itself(which I do not want to do I want that in my workflow I should only be calling different activities).

Hi @maxim,
Can you please help here?

Seems that the return of the subscriptionActivity.chargeUser cannot be serialized/deserialized into the functional interface that seems to be the input to your utilityActivity.ignoreException activity method. When used as activity, there is an extra step of serializing/deserializing activity input parameters.

Would it be possible to change the utilityActivity.ignoreException input to like type String or Object type that works with the default Json data converter?

Basically what I want to achieve here is I have some activity that could throw exception for which I am using Activity.wrap(ex). But in the workflow I do not want to write try and catch that’s why I wrote some generic exception handler as an activity task and passed functional argument and default value in case even after all the retries exception persists.

This code passes a function pointer (lambda) as an activity argument. Serialization of functions is not supported. Activities should be used to communicate with external world. So having error handling logic there doesn’t really make sense. So just run it inside the workflow code.

Thanks @maxim and @tihomir .

1 Like