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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:17:32+00:00 2026-05-26T23:17:32+00:00

I want to chain async rest service calls and have single callback when they

  • 0

I want to chain async rest service calls and have single callback when they finished.

Is it possible to do it with guava?

  • 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-05-26T23:17:32+00:00Added an answer on May 26, 2026 at 11:17 pm

    You can use Futures.chain for chaining ListenableFutures:

    final ListeningExecutorService service1 = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(16));
    final ListeningExecutorService service2 = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(16));
    
    ListenableFuture<String> service1result = service1.submit(new Callable<String>() {
        @Override
        public String call() throws Exception {
            return "service1result";
        }
    });
    
    ListenableFuture<String> service2result = Futures.chain(service1result, new Function<String, ListenableFuture<String>>() {
        @Override
        public ListenableFuture<String> apply(final @Nullable String input) {
            return service2.submit(new Callable<String>() {
                @Override
                public String call() throws Exception {
                    return Joiner.on(" -> ").join(input, "service2result");
                }
            });
        }
    });
    
    System.out.format("Result: %s\r\n", service2result.get());
    

    Output of at the code above in the terminal:

    > run-main training.Training
    [info] Compiling 1 Java source to /home/remeniuk/projects/guava-training/target/scala-2.9.1/classes...
    [info] Running training.Training 
    Result: service1result -> service2result
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a chain of async calls, linked together using dojo.Deferred objects as async
I have a chain of asynchronous events that i want to execute, some of
want to have a Hyperlink-Button in a gridView in which I can display a
I want to create this Markov Chain in C#. I need to know if
In a Unix environment, I want to use tee on a chain of commands
I want to model a kind of FSM(Finite State Machine). I have a sequence
I have the following utility: class Worker { public void DoWorkAsync(Action callback) { Action
I want to chain the contents of two queries. Please notice I DON'T want
I want to make an transparent chain-proxy using a redirect server and chain proxy
I want to split a bezier curve into a polygonal chain with n straight

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.