XFire实现WebServices

本以为是WebServices的并发处理能力差,导致某时间点集中对WebServices发起的访问有出现访问不到的情况。
因此写了一个将客户端发起的访问时间进行错开的功能,客户端发起的访问时间是由服务器决定的,客户端首起启动时将从WebServices读取相应的发送规则,通过下边的类来修改不同客户端的发送规则,每十台机器采用一套发送规则。


package com.sise.attendance;

public class SendControl {

private static int machineNum = 0;

private static int second = 0;

private static SendControl sc = null;

private SendControl() {

}

public synchronized static SendControl getInstance() {

if (sc == null) {
sc = new SendControl();
}

return sc;
}

public synchronized void setMachineNum() {
if (machineNum == 10) {
machineNum = 0;

// 发送时间增量达到6分钟后加零
if (second == 360) {
second = 0;
}

// 当machineNum达到10台机器后便加大发送时间的增量
second += 30;

}
machineNum++;
}

public int getIncrementSecond() {
return SendControl.second;
}

public int getMachineNum() {
return SendControl.machineNum;
}
}

此类为一个单例类,然后将错开时间的设置方法进行了资源同步。
用此来错开控制端的发送时间。

但问题依然存在有数据没能发送过来,可能是网络或者交换机有丢失包的问题了。
进一步研究中。。。。

你可能感兴趣的:(360)