vy / log4j2-redis-appender

A Log4j 2 Appender for Redis.
Apache License 2.0
33 stars 10 forks source link

Add `publish` command support #138

Closed rmarticaba closed 6 months ago

rmarticaba commented 6 months ago

Add support for publishing messages using pub / sub paradigm instead of storing them into database with rpush. It is created through configuration and tests are added to validate message reception and contents. Revert username to it's previous default value.

rmarticaba commented 6 months ago

I created this new Pull Request to add another feature we needed in my current project. We wanted to use the redis logging through Redis pub/sub protocol instead of storing the messages in database. This way we avoided polling to get new messages and could show them directly. I also set again username's default value as default through config so it keeps backwards compatibility. Please let me know what do you think of these changes.

rmarticaba commented 6 months ago

@rmarticaba, using publish was something I had in mind for quite a while too. Thanks so much for the contribution! 💯

Thanks, I think I addressed all your comments and pushed the changes. It's a nice tool and I'm glad to have been able to contribute to it.

vy commented 6 months ago

@rmarticaba, I have converted JedisTestSubscriber to a JUnit extension. This not only safely attaches a background thread to the test1, it also doesn't leak the thread2. All in all, thanks so much for the contribution. I will cut the 0.16.0 release right away.

1 Since we register the thread shutdown to a AfterEachCallback. 2 You were shutting down the executor, which signals an interrupt to worker threads. This is not enough to wake subscribe() up from its sleep:unsubscribe() needs to be called too.