Closed iohao closed 2 months ago
相关文档 - 解决协议碎片 (yuque.com)
广播:单个、List,伪代码如下
public void testRangeBroadcaster(FlowContext flowContext) {
// ------------ object ------------
// 广播 object
DemoBroadcastMessage message = new DemoBroadcastMessage();
message.msg = "helloBroadcast --- 1";
RangeBroadcaster.of(flowContext)
.setResponseMessage(cmdInfo, message);
// 广播 object list
List<DemoBroadcastMessage> messageList = List.of(message);
RangeBroadcaster.of(flowContext)
.setResponseMessageList(cmdInfo, messageList);
// ------------ int ------------
// 广播 int
int intValue = 1;
RangeBroadcaster.of(flowContext)
.setResponseMessage(cmdInfo, intValue);
// 广播 int list
List<Integer> intValueList = List.of(1, 2);
RangeBroadcaster.of(flowContext)
.setResponseMessageIntList(cmdInfo, intValueList);
// ------------ long ------------
// 广播 long
long longValue = 1L;
RangeBroadcaster.of(flowContext)
.setResponseMessage(cmdInfo, longValue);
// 广播 long list
List<Long> longValueList = List.of(1L, 2L);
RangeBroadcaster.of(flowContext)
.setResponseMessageLongList(cmdInfo, longValueList);
// ------------ String ------------
// 广播 String
String stringValue = "1";
RangeBroadcaster.of(flowContext)
.setResponseMessage(cmdInfo, stringValue);
// 广播 String list
List<String> stringValueList = List.of("1L", "2L");
RangeBroadcaster.of(flowContext)
.setResponseMessageStringList(cmdInfo, stringValueList);
// ------------ boolean ------------
// 广播 boolean
boolean boolValue = true;
RangeBroadcaster.of(flowContext)
.setResponseMessage(cmdInfo, boolValue);
// 广播 boolean list
List<Boolean> boolValueList = List.of(true, false);
RangeBroadcaster.of(flowContext)
.setResponseMessageBoolList(cmdInfo, boolValueList);
}
那请问 新增这个范围内广播功能之后, BroadcastContext broadcastContext = BrokerClientHelper.getBroadcastContext(); 支持自动装箱/拆箱吗
那请问 新增这个范围内广播功能之后, BroadcastContext broadcastContext = BrokerClientHelper.getBroadcastContext(); 支持自动装箱/拆箱吗
不会,BroadcastContext 是基础接口,不做更多额外的操作。如有需要,开发者可以自行封装一层。
这里的 RangeBroadcast 就相当是封装了一层,内部用的还是 BroadcastContext。
新增功能的使用场景
简化协议碎片的使用,将提供多个重载
相关文档 - 解决协议碎片 (yuque.com)