You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm dealing with an application that emits application events in response to WebSocket messages. Those are published on Tomcat's handler threads (for example, tomcat-handler-9) and never captured by PublishedEvents. If I ensure that the same code runs on the same thread as the test, PublishedEvents captures them.
While Modulith's documentation does not say much about threading, #116 suggests that PublishedEvents can only capture events emitted by the same thread the test runs on and its descendants. Seemingly, Tomcat's handler threads in a @SpringBootTest are not descendants of the test thread. The same seems to be true for @Scheduled. With an Executor, it seems to depend on when and where the task is submitted. For example, events submitted in a construtor are not captured while those submitted in a method directly invoked from the test are.
Is my interpretation of the situation correct? If so, is this an expected (or desired) limitation of PublishedEvents? Is there a recommended workaround?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm dealing with an application that emits application events in response to WebSocket messages. Those are published on Tomcat's handler threads (for example,
tomcat-handler-9
) and never captured byPublishedEvents
. If I ensure that the same code runs on the same thread as the test,PublishedEvents
captures them.While Modulith's documentation does not say much about threading, #116 suggests that
PublishedEvents
can only capture events emitted by the same thread the test runs on and its descendants. Seemingly, Tomcat's handler threads in a@SpringBootTest
are not descendants of the test thread. The same seems to be true for@Scheduled
. With anExecutor
, it seems to depend on when and where the task is submitted. For example, events submitted in a construtor are not captured while those submitted in a method directly invoked from the test are.Is my interpretation of the situation correct? If so, is this an expected (or desired) limitation of
PublishedEvents
? Is there a recommended workaround?Beta Was this translation helpful? Give feedback.
All reactions