Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

As a user, I want to register interceptors for service task workers so I can add cross-cutting concerns without replacing the delivery layer

Aperta
#278 5 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@emaarco ci sta già lavorando.

Dal 12/3/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Type: question
Scenario

I want to add cross-cutting concerns (logging, APM/OpenTelemetry tracing, auditing)
around every service task worker execution without having to replace the entire ExternalServiceTaskDelivery
bean or rely on Spring AOP (which cannot easily access TaskInformation and variables).

The library supports two registration paths:

  1. Annotation-based (@ProcessEngineWorker) via process-engine-worker
  2. Manual — directly calling TaskSubscriptionApi.subscribeForTask(SubscribeForTaskCmd(..., action: TaskHandler))

A solution must cover both paths.

Current Behaviour

There is no first-class interceptor concept. To intercept worker execution, users must either:

  • Replace the entire ExternalServiceTaskDelivery bean (large surface area, error-prone, engine-specific)
  • Use Spring AOP (hard or impossible to access TaskInformation + variables + topic name)
  • Implement a custom ParameterResolutionStrategy or ResultResolutionStrategy (worker-lib only, no lifecycle hooks)
Wanted Behaviour

A ServiceTaskInterceptor interface that allows users to register one or more Spring beans to be applied
around every service task execution — regardless of whether the subscription was created via
@ProcessEngineWorker or via a manual subscribeForTask() call.

Proposed API:

fun interface ServiceTaskInterceptor {
  fun intercept(context: ServiceTaskInterceptorContext, chain: ServiceTaskInterceptorChain)
}

data class ServiceTaskInterceptorContext(
  val taskInformation: TaskInformation,
  val payload: Map<String, Any?>,
  val taskDescriptionKey: String?,
  val taskType: TaskType
)

fun interface ServiceTaskInterceptorChain {
  fun proceed()
}

Example logging interceptor:

@Component
class LoggingServiceTaskInterceptor : ServiceTaskInterceptor {
  private val log = LoggerFactory.getLogger(this::class.java)
  override fun intercept(ctx: ServiceTaskInterceptorContext, chain: ServiceTaskInterceptorChain) {
    log.info("Executing [{}] with {} variables", ctx.taskDescriptionKey, ctx.payload.size)
    chain.proceed()
    log.info("Completed [{}]", ctx.taskDesclingKey)
  }
}

The right interception point is inside AbstractTaskSubscriptionApiImpl.subscribeForTask() — wrapping the
action TaskHandler before storing the TaskSubscriptionHandle. This makes it transparent to all delivery
implementations (pull or push) and covers both registration paths automatically. Interceptors are ordered
via @Order/Ordered. When no interceptors are registered, behaviour is identical to today (zero overhead).

Possible Workarounds
  • Provide a custom ExternalServiceTaskDelivery bean (engine-specific, complex, replaces entire delivery layer)
  • Spring AOP on @ProcessEngineWorker methods (does not work for manual TaskHandler registrations; TaskInformation and variables are not directly accessible as method parameters in all cases)
  • Custom ParameterResolutionStrategy (worker-lib only, no pre/post hooks around the actual execution)
Lingua principale
Kotlin
Stelle
25
Fork
5
Merge medio
2g 18h
PR unite (30g)
8

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bpm-crafters/process-engine-api

Tutte le issue di bpm-crafters/process-engine-api

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.