使用分片队列
This commit is contained in:
parent
fdc37c8ad1
commit
2f33c62e6e
|
@ -2,6 +2,7 @@ package com.iot.modbus_rtcp.netty;
|
||||||
|
|
||||||
import com.iot.modbus_rtcp.dto.CommandTypeComparable;
|
import com.iot.modbus_rtcp.dto.CommandTypeComparable;
|
||||||
import com.iot.modbus_rtcp.dto.ModbusCommandDto;
|
import com.iot.modbus_rtcp.dto.ModbusCommandDto;
|
||||||
|
import com.iot.modbus_rtcp.utils.HexUtil;
|
||||||
import io.netty.channel.ChannelPromise;
|
import io.netty.channel.ChannelPromise;
|
||||||
import io.netty.channel.socket.SocketChannel;
|
import io.netty.channel.socket.SocketChannel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
@ -140,6 +141,7 @@ public class SyncPriorityChannel implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCollectQueue() {
|
public void setCollectQueue() {
|
||||||
this.collectQueue = "/modbus/device/" + this.identifier + "/collect";
|
// this.collectQueue = "/modbus/device/" + this.identifier + "/collect";
|
||||||
|
this.collectQueue = "/modbus/collect/" + HexUtil.hashPartition(this.identifier, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,10 @@ public class HexUtil {
|
||||||
return sb.toString().trim().toUpperCase();
|
return sb.toString().trim().toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int hashPartition(String key, int partition) {
|
||||||
|
return key.hashCode() % partition;
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println(hexStringToBytes("0D"));
|
System.out.println(hexStringToBytes("0D"));
|
||||||
System.out.println(new byte[]{(byte) Integer.parseInt("0D", 16)});
|
System.out.println(new byte[]{(byte) Integer.parseInt("0D", 16)});
|
||||||
|
|
Loading…
Reference in New Issue