harwind

harwind

Event handling in java

I’m developing a web-based application that uses Java servlets to make RPC calls.
I’m searching for a solid technique to dispatch and handle server events. With a PHP application, I’m used to using Symfony’s EventDispatcher class to add event listeners and dispatch events, but I’m having trouble finding something analogous in Java because much of what I can find is about dealing with UI events, and I want to listen for and fire events on the server.

I’d also like the actual event handling to happen asynchronously on a separate thread or something, so that an API call to handle adding a payment can do what’s necessary, fire an event, and return immediately, even if the event triggers some more time-consuming stuff like sending emails or contacting a partner to inform them of the new balance.

Is it better to just write my own event interfaces, ExecutorService/Runnable, and Observer or Publish/Subscribe patterns? Or are there existing libraries (or built-in features I’m not aware of) that can handle some of this for me?
Thanks!

Where Next?

Popular General Dev topics Top

AstonJ
Looking at @siddhant3030’s photo from the Do you blog? thread, do you cover your computer or phone camera as a security precaution? Wha...
New
AstonJ
What do you think needs fixing in the digital / computer science sphere?
New
Exadra37
I am a Linux user since 2012, more or less, and I always use Ubuntu on my computers, and my last 2 laptops have been used Thinkpads, wher...
New
jamiedumont
This is all going to be a bit hand-wavey and straight off the top of my head, so bear with me, but it’s a thought/debate that’s been ratt...
New
DevotionGeo
I hate having mandatory semicolons in a language, no matter how beautiful the language is otherwise. What about you?
New
Exadra37
Kubernetes is everywhere. Transactional apps, video streaming services and machine learning workloads are finding a home on this ever-gro...
New
jaeyson
Not trying to add more mess here but, reddit has ELI5 but i wanted to know if it’s okay to ask Elixir-specific (or outside of it) in a si...
New
jaeyson
Hi all, does anybody tried Shankar Devy’s Phoenix Inside Out book series? Also, will there be a big difference (aside from context prior...
New
New
OvermindDL1
Maybe we need a thread of hosting providers we like and for what reasons. I personally like OVH, they are a very low level host (they re...
New

Other popular topics Top

ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
Exadra37
Please tell us what is your preferred monitor setup for programming(not gaming) and why you have chosen it. Does your monitor have eye p...
New
Margaret
Hello content creators! Happy new year. What tech topics do you think will be the focus of 2021? My vote for one topic is ethics in tech...
New
AstonJ
If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issu...
New
Margaret
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
1139 25582 756
New
PragmaticBookshelf
Author Spotlight James Stanier @jstanier James Stanier, author of Effective Remote Work , discusses how to rethink the office as we e...
New
PragmaticBookshelf
Author Spotlight Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
husaindevelop
Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
New
AnfaengerAlex
Hello, I’m a beginner in Android development and I’m facing an issue with my project setup. In my build.gradle.kts file, I have the foll...
New
Fl4m3Ph03n1x
Background Lately I am in a quest to find a good quality TTS ai generation tool to run locally in order to create audio for some videos I...
New