{"record":{"id":"2ee3c972c9d894f7","repo":"abpframework/abp","slug":"the-background-job-args-type-duplicatetype-fulln","errorCode":null,"errorMessage":"The background job args type '{duplicateType.FullName}' is already assigned to a dedicated worker. Each job type can be handled by only one dedicated worker.","messagePattern":"The background job args type '(.+?)' is already assigned to a dedicated worker\\. Each job type can be handled by only one dedicated worker\\.","errorType":"exception","errorClass":"AbpException","httpStatus":null,"severity":"error","filePath":"framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/AbpBackgroundJobWorkerOptions.cs","lineNumber":137,"sourceCode":"        CleanupDistributedLockName = \"AbpBackgroundJobCleanup\";\n    }\n\n    /// <summary>\n    /// Adds a dedicated worker that processes only the given job argument types.\n    /// </summary>\n    /// <param name=\"lockName\">A unique distributed lock name for this worker.</param>\n    /// <param name=\"jobArgsTypes\">The job argument types handled exclusively by this worker.</param>\n    public AbpBackgroundJobWorkerOptions AddDedicatedWorker(string lockName, params Type[] jobArgsTypes)\n    {\n        Check.NotNullOrEmpty(jobArgsTypes, nameof(jobArgsTypes));\n\n        var configuration = new BackgroundJobWorkerConfiguration(lockName, jobArgsTypes.Distinct().ToArray());\n\n        var duplicateType = configuration.JobArgsTypes.FirstOrDefault(\n            type => WorkerConfigurations.Any(c => c.JobArgsTypes.Contains(type)));\n        if (duplicateType != null)\n        {\n            throw new AbpException(\n                $\"The background job args type '{duplicateType.FullName}' is already assigned to a dedicated worker. \" +\n                $\"Each job type can be handled by only one dedicated worker.\");\n        }\n\n        if (lockName == DistributedLockName || WorkerConfigurations.Any(c => c.LockName == lockName))\n        {\n            throw new AbpException(\n                $\"The distributed lock name '{lockName}' is already used by another background job worker. \" +\n                $\"Each worker must have a unique lock name.\");\n        }\n\n        WorkerConfigurations.Add(configuration);\n        return this;\n    }\n\n    public AbpBackgroundJobWorkerOptions AddDedicatedWorker<TArgs>(string lockName)\n    {\n        return AddDedicatedWorker(lockName, typeof(TArgs));","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/AbpBackgroundJobWorkerOptions.cs#L119-L155","documentation":"Thrown by AbpBackgroundJobWorkerOptions.AddDedicatedWorker when one of the supplied jobArgsTypes is already part of an existing BackgroundJobWorkerConfiguration in WorkerConfigurations. The dedicated-worker model requires each job args type to be owned by exactly one worker, so a duplicate is rejected with the offending type's FullName.","triggerScenarios":"Calling AddDedicatedWorker(lockName, typeof(SomeJobArgs)) (or the generic overloads) where SomeJobArgs was already passed to a previous AddDedicatedWorker call.","commonSituations":"Two modules/hosts each register a dedicated worker for the same job args type; refactoring split one worker into two but left overlapping types; copy-paste of AddDedicatedWorker calls; a shared job type reused across feature modules.","solutions":["Assign each job args type to only one dedicated worker; remove the duplicate registration.","If two workers must handle related jobs, split them into distinct args types.","Inspect all AddDedicatedWorker call sites and confirm each type appears in exactly one.","Consolidate the overlapping types into a single worker configuration."],"exampleFix":"// before\noptions.AddDedicatedWorker(\"worker-a\", typeof(EmailJobArgs));\noptions.AddDedicatedWorker(\"worker-b\", typeof(EmailJobArgs)); // throws duplicate\n// after\noptions.AddDedicatedWorker(\"worker-a\", typeof(EmailJobArgs));\noptions.AddDedicatedWorker(\"worker-b\", typeof(SmsJobArgs));","handlingStrategy":"validation","validationCode":"var existing = options.WorkerConfigurations.SelectMany(c => c.JobArgsTypes);\nvar duplicates = jobArgsTypes.Where(t => existing.Contains(t)).ToList();\nif (duplicates.Any()) { /* don't call AddDedicatedWorker for these */ }","typeGuard":"null","tryCatchPattern":"try { options.AddDedicatedWorker(lockName, types); }\ncatch (AbpException ex) when (ex.Message.Contains(\"already assigned to a dedicated worker\"))\n{ /* merge into existing worker or drop duplicate types */ }","preventionTips":["Register each job args type with exactly one worker.","Centralize dedicated-worker registration to a single composition root.","Use distinct args types per feature to avoid cross-collisions.","Unit-test configuration startup to catch duplicates early."],"tags":["background-jobs","abp","configuration","dedicated-worker","duplicate"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}