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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:33:44+00:00 2026-06-14T02:33:44+00:00

Given a FooService with read and write operations backed by a repository , I

  • 0

Given a FooService with read and write operations backed by a repository, I want to provide an asynchronous variant of it to be used in a Spring REST web service (potentially using Akka as it’s already a candidate for other problems…).

So far I have the verbose and somewhat clunky variant

class AsyncFooService extends FooService {

    private final ExecutorService executor = Executors.newCachedThreadPool();
    private final FooService delegate = ...

    @Override
    public void writeSomeThing(Obj o) {
        executor.submit(new Runnable() {
           @Override
           public void run() {
               delegate.writeSomeThing(o);
           }
        });
    }

    // repeat same override & executor semantics for all write* routines
}

What other good variants are there in achieveing asynchronous operations to the service?

To limit the scope, let’s not directly consider Proxies as they don’t provide a solution in themselves.

  • 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-14T02:33:45+00:00Added an answer on June 14, 2026 at 2:33 am

    First off I think there is a typo in your code – you’re calling the same writeSomeThing() method from within the run() creating infinite loop?

    Aside from this, I think this is pretty much how would you do it in plain Java – using Executors. More verbose for sure, but you could move this code to the proxy/interceptor to your sync implementation, which would submit task to executor and return control to the caller, therefore leaving sync implementation free of this non functional logic. Then you could either call sync implementation directly to get sync behavior or call proxy to get async, or perhaps proxy cold handle both depending on the parameters etc.

    If you want less coding to do and having enough flexibility there are certainly options available – beside Akka, which you already mentioned, you could look at Apache Camel’s SEDA queues or to any lightweight messaging solution which would let you to post tasks to the work queues for processing outside of your main thread.

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

Sidebar

Related Questions

Given that the web application doesn't have su privileges, I'd like to execute a
Given a certain date, I want to set the value of a cell with
Given that an input String may be specified as follows: read(xpath(‘...’)) or xpath(‘...’) or
Given a document collection in Text::DocumentCollection in Perl, I want to calculate the cosine
Given a list of items, I want to create a function to check if
I have a WCF web service project, say FooService.vbproj with a FooService.svc endpoint. Its
Given a list of States, as in USA States, I am trying to write
We use scheduled tasks in a Spring web application to send reminders, daily digests,
Given this method to work on a HTML page in a webbrowser: bool semaphoreForDocCompletedEvent;
Given an NSMutableArray of dynamic CGPoint s, what is the fastest and most efficient

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.