本文へ移動
cccskills
無料GitHub で公開

saksflyt

Expert knowledge of the saksflyt saga pattern implementation in melosys-api. Use when: (1) Debugging or modifying process flows (Prosessinstans, ProsessType, ProsessSteg), (2) Understanding async step execution and locking mechanisms (låsReferanse), (3) Investigating race conditions, OptimisticLockingException, or entity overwrites, (4) Moving event listeners to saga steps to avoid sync/async conflicts, (5) Adding new process types or steps, (6) Deciding whether to use @DynamicUpdate on entities.

日本語の概要は準備中です。原文の説明を表示しています。

インストール方法を見る

含まれるファイル(7)

  • SKILL.md5.8 KB
  • references/anti-patterns.md17.2 KB
  • references/architecture.md12.3 KB
  • references/concurrency.md12.9 KB
  • references/flow-definitions.md11.5 KB
  • references/patterns.md12.0 KB
  • references/stale-reference-problem.md10.5 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Saksflyt Saga Pattern

The saksflyt and saksflyt-api modules implement a saga pattern for orchestrating multi-step business processes asynchronously in melosys-api.

Quick Reference

Module Structure

saksflyt-api/    # Interfaces, domain classes, and service facade
├── ProsessinstansService.java   # Entry point for creating sagas
├── domain/
│   ├── Prosessinstans.kt        # Saga state entity
│   ├── ProsessType.java         # ~45 process type definitions
│   ├── ProsessSteg.java         # ~70 step definitions
│   ├── ProsessStatus.java       # KLAR, UNDER_BEHANDLING, PÅ_VENT, FERDIG, FEILET
│   ├── ProsessDataKey.java      # Data keys stored in saga
│   └── LåsReferanse*.kt         # Concurrency control

saksflyt/        # Execution engine and step implementations
├── ProsessinstansBehandler.java     # Main saga orchestrator
├── ProsessinstansOpprettetListener  # Event listener, starts sagas
├── ProsessinstansFerdigListener.kt  # Releases waiting sagas
├── ProsessinstansBehandlerDelegate.kt  # Locking logic
├── prosessflyt/
│   ├── ProsessFlyt.kt               # Flow definition (steps list)
│   └── ProsessflytDefinisjon.kt     # All flow mappings
└── steg/                            # Step implementations
    ├── StegBehandler.java           # Step interface
    ├── medl/                        # MEDL integration steps
    ├── sed/                         # SED/EESSI steps
    ├── brev/                        # Letter sending steps
    └── ...

Creating a New Saga

// In any service class, inject ProsessinstansService.
// Real signature (see ProsessinstansService.java) takes the full parameter list:
prosessinstansService.opprettProsessinstansIverksettVedtakEos(
    behandling, behandlingsresultatType, fritekst, fritekstSed,
    mottakerinstitusjoner, arbeidsgiverSkalHaKopi);

Step Implementation Pattern

@Component
public class MyStep implements StegBehandler {
    @Override
    public ProsessSteg inngangsSteg() {
        return ProsessSteg.MY_STEP;
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRES_NEW)  // Each step has own transaction
    public void utfør(Prosessinstans prosessinstans) {
        // Access data: prosessinstans.getData(ProsessDataKey.SOME_KEY)
        // Access behandling: prosessinstans.getBehandling()
        // Do work...
    }
}

Key Concepts

ConceptDescription
ProsessinstansSaga state - tracks type, status, current step, data
ProsessTypeDefines which saga to run (e.g., IVERKSETT_VEDTAK_EOS)
ProsessFlytOrdered list of steps for a process type
ProsessStegIndividual step in a flow
StegBehandlerStep implementation (one per ProsessSteg)
låsReferanseConcurrency lock key (e.g., RINA case ID)

Execution Flow

  1. Create: ProsessinstansService creates Prosessinstans, publishes ProsessinstansOpprettetEvent
  2. Queue Check: ProsessinstansOpprettetListener checks if saga should wait (låsReferanse) - BEFORE_COMMIT
  3. Execute: ProsessinstansBehandler.behandleProsessinstansNå() runs steps in sequence - AFTER_COMMIT (dispatched via ProsessinstansDispatcher; ProsessinstansBehandlerDelegate.behandleProsessinstans() does the på-vent check and delegates here)
  4. Complete/Fail: Status set to FERDIG or FEILET, ProsessinstansFerdigEvent published
  5. Release: ProsessinstansFerdigListener starts next waiting saga with same lock group

Critical: The AFTER_COMMIT Misconception

Misconception: "Since the saga starts AFTER_COMMIT, it sees committed data."

Reality: AFTER_COMMIT guarantees DB commit, NOT fresh Java objects.

The saga receives the same Java object from the HTTP transaction. The behandling inside is a detached entity with potentially stale data. See stale-reference-problem.md.

Common Pitfalls

The sync/async split at transaction boundaries causes race conditions:

IssueSymptomSolution
Stale object referenceSilent corruptionReload Prosessinstans in AFTER_COMMIT
Event listener + saga conflictOptimisticLockingExceptionMove listener to saga step
Entity loaded across TXSilent data corruptionAdd @DynamicUpdate to entity
@Lob in equals/hashCodeUnstable Set membershipUse id-based equals

See Anti-Patterns and stale-reference-problem.md for details.

Detailed Documentation

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

Expert knowledge of Altinn A1 application processing for posted workers in melosys-api. Use when: (1) Understanding Altinn søknad/skjema processing, (2) Debugging MedlemskapArbeidEOS form mapping, (3) Understanding SoeknadMapper transformations, (4) Investigating posted worker application issues, (5) Understanding the MOTTAK_SOKNAD_ALTINN saga flow.

日本語の概要は準備中です。原文の説明を表示しています。

navikt/melosys-api22026年10月21日 更新

Expert knowledge of Employer/Employment integration (EREG/AAREG) in melosys-api. Use when: (1) Working with organization data from EREG (Enhetsregisteret), (2) Working with employment data from AAREG (Arbeidsforhold), (3) Understanding employer/organization lookup, (4) Debugging employer or employment issues, (5) Understanding the mapping between register data and domain models. Triggers: orgnummer, arbeidsforhold, EREG, AAREG, Enhetsregisteret, registeropplysninger, ansettelsesperiode, saksopplysning.

日本語の概要は準備中です。原文の説明を表示しています。

navikt/melosys-api22026年10月21日 更新

Modular monolith architecture overview for melosys-api. Use when needing to understand module structure, dependencies between modules, where to place new code, or when changes in one module might affect others. Triggers: "architecture", "module dependencies", "where should I put", "which modules", "dependency graph".

日本語の概要は準備中です。原文の説明を表示しています。

navikt/melosys-api22026年10月21日 更新

Expert knowledge of Behandling (case treatment) domain in melosys-api. Use when: (1) Understanding the behandling lifecycle and status transitions, (2) Debugging issues with behandling creation, status changes, or closure, (3) Understanding relationships between Fagsak, Behandling, and Behandlingsresultat, (4) Investigating why a behandling is stuck or has wrong status, (5) Understanding Behandlingstyper, Behandlingstema, Behandlingsstatus enums, (6) Debugging journalføring or SED-triggered behandling creation, (7) Understanding behandling creation via saksflyt sagas.

日本語の概要は準備中です。原文の説明を表示しています。

navikt/melosys-api22026年10月21日 更新

Expert knowledge of Behandlingsresultat (treatment result) domain in melosys-api. Use when: (1) Understanding result types and their meaning (FASTSATT_LOVVALGSLAND, MEDLEM_I_FOLKETRYGDEN, etc.), (2) Working with periods - Lovvalgsperiode, Medlemskapsperiode, Anmodningsperiode, Utpekingsperiode, (3) Debugging vedtak/decision metadata, criteria evaluation, or social insurance charges, (4) Understanding EU/EEA coordination logic and Article 16 exception handling, (5) Working with trygdeavgift (social insurance charge) calculations.

日本語の概要は準備中です。原文の説明を表示しています。

navikt/melosys-api22026年10月21日 更新

brev

無料

Expert knowledge of Brev (letter generation) in melosys-api. Use when: (1) Producing letters and decision documents (vedtaksbrev), (2) Understanding Dokgen templates and mapping, (3) Configuring letter recipients and distribution, (4) Debugging letter generation issues, (5) Adding new letter types or templates.

日本語の概要は準備中です。原文の説明を表示しています。

navikt/melosys-api22026年10月21日 更新

navikt のスキルをすべて見る

このスキルの問題を報告する