我正在使用集群设置中的infinispan8.1.0最终版和Wildfly 10。
每台服务器都开始运行
C:\wildfly-10\bin\standalone.bat --server-config=standalone-ha.xml -b 10.09.139.215 -u 230.0.0.4 -Djboss.node.name=MyNode我想在分布式模式下使用Infinispan,以便拥有分布式缓存。但是对于强制要求,我需要构建一个JGroups通道来动态地从文件中读取一些属性。
这个通道对于我根据类型和名称构建群集组是必要的(例如Type1-MyCluster)。每个想要加入集群的服务器都必须使用相关的通道。
在网上浏览时,我发现了一些代码,如下所示:
public class JGroupsChannelServiceActivator implements ServiceActivator {
@Override
public void activate(ServiceActivatorContext context) {
stackName = "udp";
try {
channelServiceName = ChannelService.getServiceName(CHANNEL_NAME);
createChannel(context.getServiceTarget());
} catch (IllegalStateException e) {
log.log(Level.INFO, "channel seems to already exist, skipping creation and binding.");
}
}
void createChannel(ServiceTarget target) {
InjectedValue<ChannelFactory> channelFactory = new InjectedValue<>();
ServiceName serviceName = ChannelFactoryService.getServiceName(stackName);
ChannelService channelService = new ChannelService(CHANNEL_NAME, channelFactory);
target.addService(channelServiceName, channelService)
.addDependency(serviceName, ChannelFactory.class, channelFactory).install();
} 我已经创建了META-INF/services/....JGroupsChannelServiceActivator文件。
当我将war部署到服务器中时,操作失败,并显示以下错误:
"{\"WFLYCTL0180: Services with missing/unavailable dependencies\" => [\"jboss.jgroups.channel.clusterWatchdog is missing [jboss.jgroups.stack.udp]\"]}"我做错了什么?我怎样才能按照我需要的方式建立一个频道?我可以用什么方式告诉infinispan使用该通道进行分布式缓存?
发布于 2016-05-13 19:43:46
您找到的建议依赖于实现,并且可能会在升级过程中导致许多问题。我不建议你这么做。
让我检查一下我是否正确理解了您的问题-您需要能够手动创建一个JGroups通道,因为您为它使用了一些自定义属性。
如果是这种情况-您可以按照建议的here获取JGroups通道。但是,您随后获得了一个已经连接的JChannel实例(因此对于您的情况来说,这可能太晚了)。
不幸的是,由于Wildfly管理JChannel (集群会话、EJB等需要它),完全控制JChannel创建过程的唯一方法是使用Infinispan (库)模式。这需要将infinispan-embedded添加到您的WAR依赖项中。之后,您可以使用类似的to this test方法对其进行初始化。
https://stackoverflow.com/questions/37144684
复制相似问题