Skip to content

(feat) O3-5064: Implement thread-safe session registry and REST endpoints for Drools sessions - #3

Open
UjjawalPrabhat wants to merge 1 commit into
openmrs:mainfrom
UjjawalPrabhat:feat/O3-5064-session-registry
Open

UjjawalPrabhat wants to merge 1 commit into
openmrs:mainfrom
UjjawalPrabhat:feat/O3-5064-session-registry

Conversation

@UjjawalPrabhat

@UjjawalPrabhat UjjawalPrabhat commented Jan 16, 2026

Copy link
Copy Markdown

Summary

Implements a thread-safe session registry for Drools auto-start sessions, enabling REST-based querying of existing stateful sessions as requested in O3-5064.

Key Changes

New Components:

  • SessionRegistry - Interface for session management (register, checkout, exists, remove)
  • SessionRegistryImpl - Thread-safe implementation using ConcurrentHashMap + per-session ReentrantLock
  • SessionLease - AutoCloseable wrapper for thread-safe session checkout
  • SessionRegistryTest - 16 comprehensive tests

Service Integration:

  • Added SessionRegistry as private field in DroolsEngineServiceImpl (service encapsulation)
  • Added 3 service methods: registerAutoStartSession(), checkOutAutoStartSession(), isSessionRegistered()
  • Modified requestSession() to check registry for auto-start sessions before creating new ones

Module Startup:

  • DroolsEngineRunner now registers auto-start sessions after creation via registerAutoStartSession()

How It Works?

Startup: Auto-start sessions created → fired → registered in registry
REST Request: Check if auto-start + registered → reuse from registry (thread-safe) OR create new session

Related Issue

O3-5064

Related PR

@UjjawalPrabhat

Copy link
Copy Markdown
Author

@ibacher @samuelmale Could you please review this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant