小编DCa*_*lho的帖子

迁移/创建HA-Singleton到jboss 7

我一直在jboss中使用deploy-hasingleton文件夹作为6,这允许我创建一个单例bean,用于控制来自集群节点的业务信息请求.这些方法是同步的,以便控制节点之间的并发性(相同的数据不能在不同的节点中).

现在我正在迁移到Jboss 7,并且由于那个deploy-hasingleton文件夹消失了,我一直在关注官方的例子:

问题是这些例子太简单了,我无法理解我可以放置业务逻辑方法的位置.所以我尝试将该逻辑放在SingletonService中,它实现了:Service,MyInterface

我已经将getValue方法修改为以下内容:

@Override
    public MyInterface getValue() throws IllegalStateException,
            IllegalArgumentException {

        return this;
    }
Run Code Online (Sandbox Code Playgroud)

在客户端:

@Override
    public List<Long> myMeth(Long arg1, int arg2) {
        LOGGER.log("loadGroups() is called()");
        ServiceController<?> service = CurrentServiceContainer.getServiceContainer().getService(
                GroupDistributorService.SINGLETON_SERVICE_NAME);

        if (service != null) {
            return ((MyInterface ) service.getValue()).getMyMethod(arg1, arg2);
        } else {
            throw new IllegalStateException("Service '" + GroupDistributorService.SINGLETON_SERVICE_NAME + "' not found!");
        }
    }
Run Code Online (Sandbox Code Playgroud)

我怀疑这是正确的做法.其次,这似乎适用于包含主单例服务的节点.但是在其他节点中,它在调用单例服务时会锁定,并且会出现超时.

migration singleton jboss java-ee jboss7.x

8
推荐指数
1
解决办法
1757
查看次数

标签 统计

java-ee ×1

jboss ×1

jboss7.x ×1

migration ×1

singleton ×1