Register activities dynamically with worker

My worker is running ( I have registered 1 workflow and 3 activities before starting worker) Now while executing workflow I want to create a activity at runtime and want it to be processed by the same worker ( but since i am spawning the activity at runtime I havent registered this activity with worker before starting ) So can the same worker process the newly spawnned activity?

Which SDK are yo using?

I am using golang SDK

Is there a way to achieve this @tihomir. I am using java SDK

For Java you can use DynamicActivity, sample here.
I don’t think equivalent exists in Go SDK at this time, see open issue here.

For reference, let’s say i have activity type 1, which makes a HTTP call and I have an another activity which performs sqlquery that I have defined after the worker has started, How do I make the dynamic activity execute these activity types depending on the input type that is passed?

I am using the dynamic dsl workflow example that you have shared in the previous discussion as example. Looking to update that example with dynamic activities execution.

Similar to DynamicWorkflow, you can register only a single activity impl that implements DynamicActivity (per worker).
Yes, you could get the activity type via:
Activity.getExecutionContext().getInfo().getActivityType();
and perform different operations per type.

Is this the way(or similar) to perform different operations based on the type?

@Override
    public Object execute(EncodedValues args) {
        String activityType = Activity.getExecutionContext().getInfo().getActivityType();
        log.info("Executing dynamic activity: {}", activityType);
        try {
            if (activityType = "httpcall") {
                //// Logic to execute the http activity
            }else if(activityType = "sqlquery"){
                //// Logic to execute the sql activity
            }else {
                return null;
            }
        } catch (Exception e) {
            return null;
        }
    }

Yes, that should be ok, probably should use .equals or == for String comparison.

Got it. But the problem that I am looking at is if I add a new activityType later(called fetchData), after the worker has started, is there a way to call that activity using temporal without modifying the DynamicActivity execute function?

is there a way to call that activity using temporal without modifying the DynamicActivity execute function

Where is the code that executes the fetch activity? You can change activity code without breaking workflow determinism, would have to restart your workers tho for changes to be picked up.

Checking for an option to load the new code/jar dynamically into the application jvm.

Checking for an option to load the new code/jar dynamically into the application jvm.

I think this is dependent on your impl, frameworks used, deployment strategies etc, not specifically with Temporal itself. Maybe there are some others in community that have done something similar that could share.