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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:48:08+00:00 2026-06-15T01:48:08+00:00

I need to run a task inside a RMI service and it needs an

  • 0

I need to run a task inside a RMI service and it needs an event listener implemented for it. Right now when I pass the EventListener over RMI it does execute the call however the callback method of the Listener is not being invoked and it remains in the wait state. How should I get this to work?

public class MyEventListener implements Serializable, ABCEventListener {

    private static final long serialVersionUID = -4686421592620210489L;
    private boolean registrationCompleted = false;

    public boolean getRegistrationCompleted(){
        return registrationCompleted;
    }
    @Override
    public void onSomethingDiscovered(Agent agent) {            
        System.out.println("Added agent "+agent.toString()+" to the set \n");

    }

    @Override
    public void onDiscoveryComplete() {
        this.registrationCompleted = true;
        System.out.println("Discovery process completed. \n");
    }
}

Here is where I pass the eventlistener to the RMI service ‘ds’

MyEventListener myEL = new MyEventListener();
ds.discoverAsync(val, myEL);
waitForRegistration();
.
.
    private void waitForRegistration() {

    try{
    while(!dcev.getRegistrationCompleted()){
        System.out.println("Please wait...");
        Thread.sleep(15000);
    }
    }catch(InterruptedException e){
        logger.error("InterruptedException raised while waiting for registration",e);
        e.printStackTrace();
    }

}
  • 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-15T01:48:09+00:00Added an answer on June 15, 2026 at 1:48 am

    The problem is that because your event listener is serializable the data fields of your event listener get sent across the wire and a new object created on the server side. The method is called on this copy of your event listener. This makes perfect sense for data objects, but for the likes of event listeners doesn’t work as you want your client code to get the call.

    I believe you can make this work if your event listener extends RemoteObject. If you do this, instead of your object being copied, it will be exposed as an RMI service when you call the server. The server instead of getting a copy of your object, will get a proxy to your event listener. The call to the event listener will result in an RMI call in the reverse direction to call your event listener.

    See Passing Remote Objects in the RMI guide for more details.

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

Sidebar

Related Questions

I need to run a task in CruiseControl .NET before checking for modification in
I have a rake task I need to run as a daily job on
In my Cocoa application I need to run a task that uses unstable unfixable
I need to run a periodic task in an Android application. I currently use
I'm making a task-based program that needs to have plugins. Tasks need to have
I need to write a shell script to run as a cron task, or
My site is hosted on Heroku, I need to run a task once a
I've got some crazy task, that sounds like mission impossible. I need to pass
I need to run a task every hour on the hour (00:00, 01:00, 02:00,
I have a cpu intensive task that I need to run on the client.

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.