Hi all, I have noticed something strange when registrating activity with a worker. If I have a class structure with the following structure:
- CommonActivity interface with method getName
- ActivityInterface1 extends CommonActivity. This interface is annotated with @ActivityInterface and has method doWork1() that is annotated with @ActivityMethod
- ActivityInterface2 extends CommonActivity. This interface is annotated with @ActivityInterface and has method doWork2() that is annotated with @ActivityMethod
When I register those activities with a worker
yourWorker.registerActivitiesImplementations(new ActivityInterface1Imp(), new ActivityInterface2Impl() );
I get error
Exception in thread "main" io.temporal.worker.TypeAlreadyRegisteredException: "GetName" activity type is already registered with the worker
at io.temporal.internal.activity.ActivityTaskHandlerImpl.registerActivityImplementation(ActivityTaskHandlerImpl.java:168)
at io.temporal.internal.activity.ActivityTaskHandlerImpl.registerActivityImplementations(ActivityTaskHandlerImpl.java:107)
at io.temporal.internal.worker.SyncActivityWorker.registerActivityImplementations(SyncActivityWorker.java:90)
at io.temporal.worker.Worker.registerActivitiesImplementations(Worker.java:364)
at
The reason for this is that in class ActivityTaskHandlerImpl when the activities are registered the code gets ALL of the activities methods, not just the ones annotated with @ActivityMethod and since for both activities I have a common interface with a method the CommonActivity method is tried to be added as an activity.
The code doing this is
Class<?> cls = activity.getClass();
POJOActivityImplMetadata activityImplMetadata = POJOActivityImplMetadata.newInstance(cls);
for (POJOActivityMethodMetadata activityMetadata :
activityImplMetadata.getActivityMethods()) {
String typeName = activityMetadata.getActivityTypeName();
if (activities.containsKey(typeName)) {
throw new TypeAlreadyRegisteredException(
typeName, "\"" + typeName + "\" activity type is already registered with the worker");
}
Is there a reason why ALL of the activity methods are considered as if they are annotated with @ActivityMethod? Do you think this is a bug?
Is there a place where I can report this ti the temporal team for investigation?
Thanks you,
Svet