• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Shut down RMI Registry

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I started up a RMI registry using the following:



Is there a reliable way to shutdown this registry (without exiting the program)? I check the API of both registry and LocateRegistry and can not find a suitable method call.
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unbind the server (Registry.unbind) and unexport the objects (UnicastRemoteObject.unexportObject()).
 
Kelly Wood
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Registry.unbind() takes a String argument, which is the name of the object to unbind from the registry.

I am looking for a way to close the registry (i.e. stop it from listening on port 1099, like close() on ServerSocket).
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The registry itself is a remote objet. Unexport the registry and its done.

 
Kelly Wood
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried your suggestion, but I still see port 2500 (the registry port I configured) in listening state.
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The port will not be release until the application has exited. And that, my friend, cannot be changed, as far as I understand.

However, the registry will no longer accept method requests (like bind, list or lookup).

Likewise, after unexportObject, you can create another registry listening on the same port and there will be no problem, as long as you do it on the same JVM that originaly created the registry that you unexported.

The thing is, not other Socket in this or other JVM will accept connections to a port previously used by the RMIRegistry until you exit the application that created the registry.

The port number can be reused by the RMIRegistry after you have unexported the registry object, but it can never be reused for other purposes other than the RMIRegistry.

What is exactly what you need to do that you need to get that port back?
 
Kelly Wood
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I m working on a server application that will start up a rmi registry and bind an object to it. It also allows the user to change the rmi registry port on the UI, and has a function to stop the registry. In the stop function, it will cleanup any resource that the server was using. If it is not possible to free up the rmi registry port, then it will not make sense to provide a stop server function.
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, Kelly Wood, that might no be easy to do then. Now if you think it over, there are no servers that actually do that. All servers are configured to start with a port, if you change the port, you have to restart your server.
 
it's a teeny, tiny, wafer thin ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic