Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable add/remove of multiple ConnectionListeners per Connection #861

Merged
merged 1 commit into from
Mar 20, 2023

Conversation

davidmcote
Copy link
Contributor

@davidmcote davidmcote commented Mar 20, 2023

This patch addresses #860.

Late and multiple bindings of ConnectionListeners to Connections enable business logic to listen for events without needing to construct their own Connection object.

This benefits applications which separate their NATS Connection factory from their business logic, but whose business logic's resource's lifecycle are coupled to the state of NATS Connection's. Eg: They wish to clean up on connection CLOSED events without polling or passing around a separate observable mechanism.

Signed-off-by: David Cote <davidmcote@gmail.com>
@davidmcote
Copy link
Contributor Author

davidmcote commented Mar 20, 2023

FYI: I couldn't seem to get a clean test run on my system before setting out to develop this patch.

My testing here focused on ensuring ConnectionListenerTest remained 100% passing.

Is it typical to see a subset of the unit test suite failing intermittently with issues launching nats-server processes?

java.lang.IllegalStateException: Failed to run [nats-server --config /var/folders/37/vq3x8fg51gvfmm3y8mn92tjc0000gn/T/nats_java_test5680736364639790246.conf -js]
	at nats.io.NatsServerRunner.<init>(NatsServerRunner.java:411)
	at nats.io.NatsServerRunner.<init>(NatsServerRunner.java:106)
	at io.nats.client.NatsTestServer.<init>(NatsTestServer.java:46)
	at io.nats.client.utils.TestBase.runInServer(TestBase.java:100)
	at io.nats.client.utils.TestBase.runInJsServer(TestBase.java:88)
	at io.nats.client.impl.JetStreamGeneralTests.testMoreCreateSubscriptionErrors(JetStreamGeneralTests.java:903)
. . .

@scottf
Copy link
Contributor

scottf commented Mar 20, 2023

Is it typical to see a subset of the unit test suite failing intermittently with issues launching nats-server processes?

Yes. We could verify the server is ready I suppose...

Copy link
Contributor

@scottf scottf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@scottf scottf merged commit 443968f into nats-io:main Mar 20, 2023
@davidmcote davidmcote deleted the multiple-connection-listeners branch March 20, 2023 14:42
@davidmcote
Copy link
Contributor Author

Thanks for the review Scott :)

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.

None yet

2 participants