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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:13:40+00:00 2026-06-13T06:13:40+00:00

I have the following design: There is a Task which extends TimerTask and it

  • 0

I have the following design:

There is a Task which extends TimerTask and it is scheduled to run every minute.
This Task will try to take items from a central queue (as a single consumer) and write their representation into a file.

Additionally, there are multiple producers which put items into the central queue from time to time.

I am interested that each time the Task is executed (run() method executed) it will extract all the items from the queue if there are items, if there are no items do nothing.

Producers should sleep on the Queue if it is full.

My Solution for this problem is:

Create ExtractTask which extends TimerTask.
ExtractTask will contain a BlockingQueue.
Each producer will receive a reference to the queue instance by executing method getQueue().
Producers will execute BlockingQueue.put() method.
The consumer will execute BlockingQueue.poll() method inside run().

Can you suggest a better design? does my design contain any problematic scenario cases? any synchronization problems this design may encounter?

  • 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-13T06:13:41+00:00Added an answer on June 13, 2026 at 6:13 am

    I would:

    • keep the queues separated from the tasks in your design,
    • inject the queues instead of doing a lookup,
    • use a SchedulerService instead of a TimerTask

    Other than that you’ve got it.

    If you’re willing to risk a dependency on Spring you should look into Spring Integration. All the components you describe are in there. You could also solve the problem using many other frameworks, like Camel or Akka; my main point here is to not maintain this code yourself if you don’t absolutely have to.

    Disclaimer: I’m somewhat biased about Spring Integration

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

Sidebar

Related Questions

Is there any name for the following DB table design: Basically we have generic
I have a following design function crudDataTable() { this.addEditFormContainerSelector = ''; this.paginationType = full_numbers;
I have the following tables in an SQL DB Vehicles, RepairCharges, TowCharges, There will
I have the following design I am required to markup, the layout of which
I have to find a design decision for the following task: I have a
I'm facing the following design issue: There will be several prepared SQL statements where
I have the following database design: Employee Table: Username, Name, DivisionCode Division Table: SapCode,
I have the following database design: Employee Table: Username, Name Quiz Table: QuizID, Title,
I am creating an App with following design: I have a UITableView with custom
I am in need of some guidance for the following design. I have a

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.