Skip to content

fix: remove spurious routing dependency from JooqDslContextMiddleware - #176

Merged
kawasima merged 2 commits into
developfrom
feature/issue-171-remove-routing-dep
Apr 17, 2026
Merged

fix: remove spurious routing dependency from JooqDslContextMiddleware#176
kawasima merged 2 commits into
developfrom
feature/issue-171-remove-routing-dep

Conversation

@kawasima

Copy link
Copy Markdown
Collaborator

Summary

  • Removes dependencies = {"routing"} from @Middleware on JooqDslContextMiddleware
  • The handle() method has no dependency on routing — it only stores a DSLContext in request extensions
  • The annotation was incorrectly copied from JooqTransactionMiddleware, which genuinely needs routing

Impact

Allows JooqDslContextMiddleware to be used in FaaS environments (e.g. AWS Lambda via enkan-faas) where RoutingMiddleware is absent. The spurious dependency caused the middleware stack validator to reject a valid configuration.

Test plan

  • mvn test -pl enkan-component-jooq -am passes

closes #171

The routing dependency was copied from JooqTransactionMiddleware but
is not needed here — the middleware only stores a DSLContext in the
request extensions. Removing it allows the middleware to be used in
FaaS environments where RoutingMiddleware is absent.

closes #171
…eated failures

The previous design used a single monitor thread (ZThread.start) that handled
both phase 1 (connection attempt) and phase 2 (disconnect detection after
successful connect). The thread called ZEvent.recv() in blocking mode; closing
the monitor socket from connect() did not unblock the recv(), so the thread
outlived each failed attempt and accumulated across retries.

Root cause: jeromq PAIR/inproc sockets do not unblock a blocking recv() when
the peer socket is closed, so the monitor thread never exited on the failure
path, and ctx.close() in handler.close() was needed to finally terminate it —
causing the ZMQException(ETERM) noise in the CI log and making repeated
connect() calls unreliable under timing pressure.

Fix: split the two phases.
- Phase 1 (connection attempt): removed the monitor entirely. The existing
  CONNECT_TIMEOUT_MS poller loop already handles the failure case correctly.
- Phase 2 (disconnect detection): start a dedicated monitor thread *after* the
  completer handshake succeeds, monitoring only DISCONNECTED/CLOSED events on
  the confirmed connection.

Each monitor thread now has a clean lifecycle: it starts only on success and
exits either on DISCONNECTED (calls close()) or on ETERM (ctx.close()).
No shared monitor socket ownership races remain.
@kawasima
kawasima merged commit f58136f into develop Apr 17, 2026
1 check passed
@kawasima
kawasima deleted the feature/issue-171-remove-routing-dep branch April 17, 2026 05:59
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