Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8897957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:29:09+00:00 2026-06-15T00:29:09+00:00

I am trying to develop a system which will be based on processing certain

  • 0

I am trying to develop a system which will be based on processing certain events and generating data. Each event will contain (possibly) several different fields and each listener will process some or them. I have the following two approaches in mind

  1. Within the event generation class, I will register multiple event listeners, each listening for one particular value of a specific field of the event, for instance:

    public class MicroListener implements Listener {
    
    public void processEvent(Event e){
        if(e.getName().equals(registeredName)) { ... }
    }
    

This is tempting, as processing is done within the object itself, and there is no centralised processing of events, rather allowing each object to process the information. The disadvantage, possibly fatal, is the fact that each event (out of a couple of hundred thousand) will have to be broadcast to all listeners, while only tiny fraction will actually do sth with it. It will probably generate a great performance hit in the long run…

  1. A centralised listener, which will listen and act upon all events, and delegate processing to the corresponding event processors, for instance:

     public class CentralListener implements Listener {
    
        Map<String, Processor> processorsByName;
    
        public void processEvent(Event e){
            processorsByName.get(e.getName()).process(e);
        }
    }
    

This would be faster, but it would require separate maps or collections of processors for any other part of the event e.g. processor that checks event ID etc. This is not the case in approach 1. as we would simply generate another set of listeners and register them with the event generation class.

What do you guys think about any of these? Do they make sense or would you rather advise for sth totally different?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:29:11+00:00Added an answer on June 15, 2026 at 12:29 am

    This is a common design decision, and I don’t think there is a generic answer that is correct for all (or even most) cases. I could list the various trade-offs in either approach, but they are probably obvious. At a high level I would favor whatever design best fits the conceptual model (and doesn’t create a mess of extraneous classes) before I would consider the possible performance implications.

    If performance was of utmost concern, then a centralized controller using a large switch/case block switching on integer event ids would probably be fastest. …and also the least flexible/maintainable over time.

    You might want to review the Guava project’s EventBus. It uses annotations to register event listeners and provides a very clean api for this type of event broadcasting/subscribing. The event subscribers are notified according to the type of event they declare in their method signature. It’s quite slick and saves a lot of boilerplate. I don’t know how well it would scale to thousands of event types, but unlike some similar libraries, the event bus is not global. You can create different event bus instances to separate event processing when it makes sense to do so.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to develop a system that will allow users to update local, offline
I am trying develop a basic referrer system to my Django website, system will
I am trying to develop an application which will record voice and plot a
I am trying to develop a small app BusTracker which will list down a
I'm trying to develop an anti-cheating system. The system will work by identifying applications
I was trying to develop an interface and that interface will contain static class
I am trying to develop a plugin system, which provides a interface to load
I am trying to develop a software which will take a keyboard input, consume
I'm trying to develop a program that takes requests for data which is stored
I'm trying to develop a system maintenance screen for my application in which I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.