-
1. Re: Wildfly 10 singleton jar issue
ctomc Jun 20, 2016 9:43 AM (in response to divey.gupta07)you are probably looking for
<artifactId>wildfly-clustering-singleton-api</artifactId>
-
2. Re: Wildfly 10 singleton jar issue
pferraro Jun 20, 2016 3:40 PM (in response to divey.gupta07)You shouldn't need to add *any* dependencies to your manifest. The singleton API module is added to the deployment classpath automatically.
Can you post your code that creates your singleton service?
-
3. Re: Wildfly 10 singleton jar issue
divey.gupta07 Jun 20, 2016 5:17 PM (in response to ctomc)<artifactId>wildfly-clustering-singleton-api</artifactId>
It worked for me.
Thanks.
I am using the below code.
public static final ServiceName SINGLETON_SERVICE_NAME = ServiceName.JBOSS.append("ha", "singleton");
private static final String CONTAINER_NAME = "server";
private static final String CACHE_NAME = "default";
@Override
public void activate(ServiceActivatorContext context) throws ServiceRegistryException {
int quorum = 1;
InjectedValue<ServerEnvironment> env = new InjectedValue<>();
SingletonServiceClient srv = new SingletonServiceClient(env);
ServiceController<?> factoryService = context.getServiceRegistry().getRequiredService(SingletonServiceName.BUILDER.getServiceName(CONTAINER_NAME, CACHE_NAME));
SingletonServiceBuilderFactory factory = (SingletonServiceBuilderFactory) factoryService.getValue();
SingletonElectionPolicy policy = new SimpleSingletonElectionPolicy(0);
factory.createSingletonServiceBuilder(SINGLETON_SERVICE_NAME, srv)
.requireQuorum(quorum)
.electionPolicy(policy)
.build(new DelegatingServiceContainer(context.getServiceTarget(), context.getServiceRegistry()))
.addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, env)
.setInitialMode(ServiceController.Mode.ACTIVE)
.install();
}