是否可以执行随机切换来在请求之间分散负载,类似于在Scala中这样做?我找不到任何关于如何在Java中做到这一点的资源。
示例代码:
public static final ChainBuilder teacherCreateAssignmentsSetup = group("teacherCreatesAssignmentsSetup").on(
exec(sessionSetSessionVariable)
.exec(session -> session.set("teacherRefId", getUniqueIdFromTokenSub(session)))
.exec(createEdCtsAssignment)
.exec(session -> {
log.info("assignment is :" + session.getString("studentsAssignment"));
return session;
})
.randomSwitch(
50.0 -> exec(nextRequest),
50.0 -> exec(anotherRequest)
)
);
1条答案
按热度按时间g6ll5ycj1#
您需要创建WithWeight数组。