Problems with HA singleton service on JBoss 7.1.1
by IK81
Dear all,
I've been playing around with the HA singleton service of JBoss AS7. I
took the example in
https://access.redhat.com/site/documentation/en-US/JBoss_Enterprise_Appli...
as a basis and use a EJB Singleton to start and stop the HA singleton
service.
Starting the service works fine, I also tested the fail-over behaviour
between different nodes. However, I encountered some strange behaviour
when it is up to stop the service:
- When I shutdown the server, the service is properly stopped and the
corresponding method stop() method is executed
- When I undeploy the app the PreDestroy method of the EJB singleton is
executed and I try to stop the HA singleton service as in the example.
However, it seems that the service is already in the REMOVED state and
unfortunately, the stop method of the singleton service is never
executed. So I have no possibility to clean up the resources that are
claimed by the service (TCP socket connection). This is not the
behaviour I'd expect
The code of the EJB singleton for service starting/stopping is as
follows:
@Singleton
@Startup
public class ServiceInstaller {
private static final Logger LOGGER =
LoggerFactory.getLogger(ServiceInstaller.class);
@PostConstruct
public void init() {
LOGGER.info("Starting singleton");
SimpleService service = new SimpleService();
SingletonService<String> singleton = new
SingletonService<String>(service, SimpleService.SINGLETON_SERVICE_NAME);
ServiceController<String> controller =
singleton.build(CurrentServiceContainer.getServiceContainer())
.addDependency(ServerEnvironmentService.SERVICE_NAME,
ServerEnvironment.class, service.getEnvInjector())
.install();
ServiceListener<String> listener = new
NotifyingServiceListener<String>();
controller.addListener(listener);
controller.setMode(ServiceController.Mode.ACTIVE);
LOGGER.info("Singleton started");
}
@PreDestroy
public void destroy() {
LOGGER.info("Destroying singleton");
ServiceController<?> controller =
CurrentServiceContainer.getServiceContainer().getRequiredService(SimpleService.SINGLETON_SERVICE_NAME);
controller.setMode(ServiceController.Mode.REMOVE);
LOGGER.info("Singleton destroyed");
}
private static class NotifyingServiceListener<T> extends
AbstractServiceListener<T> {
@Override
public void transition(ServiceController<? extends T>
controller, Transition transition) {
LOGGER.info("Change state from " +
transition.getBefore().toString() + " to " +
transition.getAfter().toString());
}
}
}
I've tested this using JBoss 7.1.1 and the standalone-ha.xml
configuration.
Another weird issue is that, if I redeploy the app after I've deployed
it, the deployment fails. The log shows me that the service with the
same name is already registered. However, I have not found a possibility
to unregister such a service.
Any suggestions? Is this a bug in JBoss?
Thanks,
Ingo
11 years, 3 months
Problems with HA singleton service on JBoss 7.1.1
by IK81
Dear all,
I've been playing around with the HA singleton service of JBoss AS7. I
took the example in
https://access.redhat.com/site/documentation/en-US/JBoss_Enterprise_Appli...
as a basis and use a EJB Singleton to start and stop the HA singleton
service.
Starting the service works fine, I also tested the fail-over behaviour
between different nodes. However, I encountered some strange behaviour
when it is up to stop the service:
- When I shutdown the server, the service is properly stopped and the
corresponding method stop() method is executed
- When I undeploy the app the PreDestroy method of the EJB singleton is
executed and I try to stop the HA singleton service as in the example.
However, it seems that the service is already in the REMOVED state and
unfortunately, the stop method of the singleton service is never
executed. So I have no possibility to clean up the resources that are
claimed by the service (TCP socket connection). This is not the
behaviour I'd expect
The code of the EJB singleton for service starting/stopping is as
follows:
@Singleton
@Startup
public class ServiceInstaller {
private static final Logger LOGGER =
LoggerFactory.getLogger(ServiceInstaller.class);
@PostConstruct
public void init() {
LOGGER.info("Starting singleton");
SimpleService service = new SimpleService();
SingletonService<String> singleton = new
SingletonService<String>(service, SimpleService.SINGLETON_SERVICE_NAME);
ServiceController<String> controller =
singleton.build(CurrentServiceContainer.getServiceContainer())
.addDependency(ServerEnvironmentService.SERVICE_NAME,
ServerEnvironment.class, service.getEnvInjector())
.install();
ServiceListener<String> listener = new
NotifyingServiceListener<String>();
controller.addListener(listener);
controller.setMode(ServiceController.Mode.ACTIVE);
LOGGER.info("Singleton started");
}
@PreDestroy
public void destroy() {
LOGGER.info("Destroying singleton");
ServiceController<?> controller =
CurrentServiceContainer.getServiceContainer().getRequiredService(SimpleService.SINGLETON_SERVICE_NAME);
controller.setMode(ServiceController.Mode.REMOVE);
LOGGER.info("Singleton destroyed");
}
private static class NotifyingServiceListener<T> extends
AbstractServiceListener<T> {
@Override
public void transition(ServiceController<? extends T> controller,
Transition transition) {
LOGGER.info("Change state from " +
transition.getBefore().toString() + " to " +
transition.getAfter().toString());
}
}
}
I've tested this using JBoss 7.1.1 and the standalone-ha.xml
configuration.
Another weird issue is that, if I redeploy the app after I've deployed
it, the deployment fails. The log shows me that the service with the
same name is already registered. However, I have not found a possibility
to unregister such a service.
Any suggestions? Is this a bug in JBoss?
Thanks,
Ingo
11 years, 3 months
how to increase session timeout for application deployed on jboss as 7.1.1
by Rishi Sheokand
Hi,
I have not set any <session-timeout> in my application. It is set only to
default I guess and after some 1 hour or less time it expires. I tried to
set it into web.xml of my application but it does not work for me.
Here I request you to please guide me how can I set a session timeout
to any specified time in my application. My understanding is that whatever
be the session timeout would be set in any server configuration file,
web.xml of the application is the file that finally override all
configuration and set the time put in its <session-timeout> tag, as in the
below example it shall set a session timeout of 2 minutes.
<session-config>
<session-timeout>2</session-timeout>
</session-config>
But it is not working in my case, it still remains about 1 hour.
Looking forward,
Rishi
11 years, 4 months