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 8754141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:33:50+00:00 2026-06-13T13:33:50+00:00

I had to create a message Listener (for some jms topic) in a stand

  • 0

I had to create a message Listener (for some jms topic) in a stand alone application.
Since each message I receive has to do some processing.

This behavior delaying my whole performance.

So I decided to create kind of POOL to my message listeners. (as in MDB’S in ejb’s).

I started using Executor class(Java) this way:

import java.util.concurrent.Executor;
import java.util.concurrent.Executors; 

    private Executor threadPool = Executors.newCachedThreadPool();
    @Override
    public void onMessage(final Message msg)
    {
        Runnable t = new Runnable()
        {
            public void run()
            {
                execute(msg);
                log.trace(received messge");
            }
        };
        threadPool.execute(t);
    }

public void execute(Message msg)
{
   // do some long running process)
}

In this way I make sure my application wont stuck from one message to another while processing by creating separate Thread for each execution.

I would like to have your suggestions by your experience..
is that kind if implementation might cause any future problems? on what should I pay attention(I know concurrency is an issue)?

  • 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-13T13:33:50+00:00Added an answer on June 13, 2026 at 1:33 pm

    This is JMS, why don’t you just pool MDBs? You can then avoid having a separate thread pool. Also unprocessed items aren’t lost if you shut down the application in the meantime.

    Make sure you understand the difference between cached and fixed thread pool (see: Java newCachedThreadPool() versus newFixedThreadPool). It may or may not be what you want. I typically go for fixed thread pool as I want to know the maximum number of open threads in advance.

    One small thing: put logging before you process the message (as well), so that you can easily tell for how long it was processed. If you used fixed pool, knowing how long it was queued is also valuable.

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

Sidebar

Related Questions

I'm having some odd log messages come up when I create an sms message
OK, here is how to re-create the problem had: Create a new project, using
So I had to create this splash page in a very short amount of
If I had to create a content inventory for a website that doesn't have
For this assignment I had to create my own string class. I initially wrote
So basically the assignment was we had to create a doubly linked list that's
In order to automate unit tests on TeamCity I had to create a test
I had a constraint in a table CREATE TABLE USERSAPPLICATIONS ( USERID NUMBER NOT
I've had a need to create an encrypted volume on my mac for the
I recently had an idea to create my own String class to make using

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.