Re: Detect & re-register in Rmi Server

Niclas Hedhman <[email protected]> Fri, 27 Mar 2009 12:46:31 +0800
Newsgroups gmane.comp.java.sun.rmi
Message-ID <[email protected]>
I suggest that you create the Registry inside the server JVM.

LocateRegistry.createRegistry()

If that is not a viable option, then I think you need to regularly do
a list() on the Registry instance and see if the service is still
there. If missing, then bind it again.

Cheers
Niclas

On Thu, Mar 26, 2009 at 6:56 PM, PawanModi <[email protected]> wrote:
> Hi,
> I am running rmi registry in separate console. My application is register=
ing
> an URL in RMI server. Now I am stopping rmi registry & restarting it agai=
n.
> Now rmi registry is a new process & all previous registration entries are
> gone. So my application has to re-register.
>
> How my application can detect that rmi server is stopped & restarted so t=
hat
> I can re-register it again?
> Any help?
> Here is my code where I am registering
>
>
> public void initializeExternalManagementInterface(String serviceURL)
> {
> =A0 =A0 =A0 =A0mbeanServer =3D MBeanServerFactory.createMBeanServer();
>
> =A0 =A0 =A0 =A0String domain =3D m_mbeanServer.getDefaultDomain();
>
> =A0 =A0 =A0 =A0String mbeanObjectNameStr =3D domain + ":type=3D" +
> EXTERNAL_MBEAN_CLASS_NAME + ",index=3D1";
>
> =A0 =A0 =A0 =A0objectName =3D =A0ObjectName.getInstance(mbeanObjectNameSt=
r);
>
> =A0 =A0 =A0 =A0Attribute serviceURLAttribute =3D new Attribute("ServiceUR=
L",
> serviceURL);
>
> =A0 =A0 =A0 =A0m_mbeanServer.setAttribute(m_mbeanObjectName, serviceURLAt=
tribute);
> =A0}
>
> public void startManagementInterface(String jmxServiceURL, String
> mbeanClassName)
> =A0 =A0{
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0env.put(RMIConnectorServer.JNDI_REBIND_ATT=
RIBUTE,"true");
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0JMXServiceURL p_jmxServiceURL =3D new JMXS=
erviceURL(jmxServiceURL);
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0LoggerManager.getLogger().info("Starting J=
MX Server: " +
> p_jmxServiceURL);
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0m_mbeanServerConnector =3D
> JMXConnectorServerFactory.newJMXConnectorServer(p_jmxServiceURL, env,
> m_mbeanServer);
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0m_mbeanServerConnector.start();
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0LoggerManager.getLogger().info("THE MANAGE=
MENT INTERFACE STARTED
> FOR SERVICE URL :" + jmxServiceURL);
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0m_jmxConnector =3D JMXConnectorFactory.con=
nect(p_jmxServiceURL,
> null);
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0m_mbeanConnection =3D m_jmxConnector.getMB=
eanServerConnection();
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0String domain =3D m_mbeanConnection.getDef=
aultDomain();
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0m_mbeanObjectName =3D new ObjectName(domai=
n + ":type=3D" +
> mbeanClassName + ",index=3D1");
>
> =A0 =A0 =A0 =A0}
>
> --
> View this message in context: http://www.nabble.com/Detect---re-register-=
in-Rmi-Server-tp22719692p22719692.html
> Sent from the Java - RMI mailing list archive at Nabble.com.
>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
> To unsubscribe, send email to [email protected] and include in the bo=
dy
> of the message "signoff RMI-USERS". =A0For general help, send email to
> [email protected] and include in the body of the message "help".
>
> For a list of frequently asked RMI questions please refer to:
> http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html
>
> To view past RMI-USERS postings, please see:
> http://archives.java.sun.com/archives/rmi-users.html
>



--=20
--
Niclas Hedhman, Software Developer
http://www.qi4j.org - New Energy for Java

I  live here; http://tinyurl.com/2qq9er
I  work here; http://tinyurl.com/2ymelc
I relax here; http://tinyurl.com/2cgsug

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff RMI-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

For a list of frequently asked RMI questions please refer to:
http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html

To view past RMI-USERS postings, please see:
http://archives.java.sun.com/archives/rmi-users.html