server.xml
<property name="sequnceHandlerType">5</property>
<property name="sequenceHanlderClass">io.mycat.route.sequence.handler.HttpIncrSequenceHandler</property>
sequenceHanlderClass是自定义全局序列号加载类
io.mycat.route.sequence.handler.HttpIncrSequenceHandler的配置
sequence_http_conf.properties
url = http://localhost:8067/
post请求的url
form的内容
prefixName: GLOBAL
count: 0
limit: -1
当count大于limit时候,才会请求服务器
count初始值为0
limiy初始值为-1
响应格式为1,2
1的位置是当前的count
2是limit的值
post实现代码
OkHttpClient client = new OkHttpClient.Builder()
.build();
RequestBody body = new FormBody.Builder()
.add("prefixName", prefixName)
.add("count",Long.toString(count))
.add("limit", Long.toString(limit))
.build();
Request request = new Request.Builder()
.url(url)
.post(body)
.build();
final Call call = client.newCall(request);
服务端响应参考代码
需要实现根据post的信息返回自定义响应
package cn.lightfish.describer;
import io.vertx.core.MultiMap;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;
import java.util.concurrent.atomic.AtomicLong;
public class Test2 {
public static void main(String[] args) {
AtomicLong count = new AtomicLong(0);
int batch = 5;
Vertx vertx = Vertx.vertx();
HttpServer httpServer = vertx.createHttpServer();
httpServer.requestHandler(httpServerRequest -> {
httpServerRequest.setExpectMultipart(true);
httpServerRequest.endHandler(event -> {
MultiMap entries = httpServerRequest.formAttributes();
System.out.println(entries);
long limit = count.addAndGet(5);
httpServerRequest.response().setChunked(true).end(limit - batch + "," + limit);
});
}).listen(8067);
}
}