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

  • SEARCH
  • Home
  • 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 118281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:28:12+00:00 2026-05-11T03:28:12+00:00

I am creating a set of widgets in Java that decodes and displays messages

  • 0

I am creating a set of widgets in Java that decodes and displays messages received at a serial interface.

The message type is defined by a unique identifier. Each widget is only interested in a particular identifier.

How to I program the application in a way to distribute the messages correctly to the relevant widgets?

  • 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. 2026-05-11T03:28:12+00:00Added an answer on May 11, 2026 at 3:28 am

    If this is for a single app (i.e. a main and couple of threads), JMS is overkill.

    The basics of this is a simple queue (of which Java has several good ones, BlockingQueue waving its hand in the back over there).

    The serial port reads its data, formats a some relevant message object, and dumps it on a central Message Queue. This can be as simple as a BlockingQueue singleton.

    Next, you’ll need a queue listener/dispatcher.

    This is a separate thread that sits on the queue, waiting for messages.

    When it gets a message it then dispatches it to the waiting ‘widgets’.

    How it ‘knows’ what widgets get what is up to you.

    It can be a simple registration scheme:

    String messageType = 'XYZ'; MyMessageListener listener = new MyMessageListener(); EventQueueFactory.registerListener(messageType, listener); 

    Then you can do something like:

    public void registerListener(String type, MessageListener listener) {     List<MessageListener> listeners = registrationMap.get(type);     if (listeners == null) {         listeneres = new ArrayList<MessageListener>();         registrationMap.put(type, listeners);     }     listeners.add(listener); }  public void dispatchMessage(Message msg) {     List<MessageListener> listeners = registrationMap.get(type);     if (listeners != null) {         for(MessageListener listener : listeners) {             listener.send(msg);         }     } } 

    Also, if you’re using Swing, it has a whole suite of Java Bean property listeners and what not that you could leverage as well.

    That’s the heart of it. That should give you enough rope to keep you in trouble.

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

Sidebar

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.