标签:http redis 多线程
目录结构
Http请求
CTI识别结果处理 CTIServiceImpl
业务客户端处理CTI平台返回的数据
1.常量
标识出来的字段为变量
RECORDDATA
=recorddata
HISTORY
=history
redis的键值
recorddata + "" + subccno
+ "" + seatId
history + "" + subccno
+ "" + seatId
+ "_" + callId
channelId
channelId- + yyyy-MM-dd-HH
2.提取content文本
3.future执行CTIServiceThread
线程
摘录创建并启动有返回值的线程步骤
- 创建Callable接口的实现类,并实现call方法,该call方法的返回值,并作为线程的执行体。
- 创建Callable实现类的实例,使用FutureTask类来包装Callable对象,该FutureTask对象封装了该Callable对象的call方法的返回值。
- 使用FutureTask对象作为Thread对象的target创建、并启动新线程。
- 调用FutureTask对象的方法来获得子线程执行结束后的返回值。
参考文档 浅谈Future
针对线程中的redis的键值变化给予说明:
- recorddata中记录着某通电话的第一句话,判断callId来等待该通电话后续所有语句,加入到history
127.0.0.1:6379> LLEN recorddata_1_5140
2113
127.0.0.1:6379> lrange recorddata_1_5140 0 1
{
"timestamp": 1507865903017,
"endtime": 1507865903017,
"userphone": "013853103458",
"starttime": 1507865903017,
"callid": "1507867604-134582",
"subccno": "vdn",
"agentid": "5140"
}
{
"timestamp": 1507865850840,
"endtime": 1507865850840,
"userphone": "013863660601",
"starttime": 1507865850840,
"callid": "1507867559-200009",
"subccno": "vdn",
"agentid": "5140"
}
- history保存着该通电话的全部语句,包括华为CTI的语句以及Mrcp直接发送的语句
127.0.0.1:6379> LRANGE history_1_7669_1507874321-138724 0 5
{
"id": "015861231023",
"talkertype": "2",
"content": "你;time=16180 16300",
"timestamp": 1507872619913,
"cmd": "",
"userphone": "015861231023",
"channelId": "8b8c1d3cafd711e7",
"historyKey": "history_1_7669_1507874321-138724",
"answer": "",
"answerType": "3"
}
{
"timestamp": 1507872619823,
"content": "幺 五 八 尾号 幺 零 二 三 的 机主 吗;time=19700 21790",
"talkertype": "1",
"id": "7669",
"userphone": "015861231023",
"cmd": "",
"channelId": "8ba904a6afd711e7",
"answer": "",
"answerType": "3"
}
{
"timestamp": 1507872616865,
"content": "喂 你好 请问 您 是;time=17440 18790",
"talkertype": "1",
"id": "7669",
"userphone": "015861231023",
"cmd": "",
"channelId": "8ba904a6afd711e7",
"answer": "",
"answerType": "3"
}
{
"timestamp": 1507872616231,
"content": "喂;time=12790 13330",
"talkertype": "2",
"id": "015861231023",
"userphone": "015861231023",
"cmd": "",
"channelId": "8b8c1d3cafd711e7",
"answer": "",
"answerType": "3"
}
{
"timestamp": 1507872606623,
"content": "喂;time=8300 8440",
"talkertype": "1",
"id": "7669",
"userphone": "015861231023",
"cmd": "",
"channelId": "8ba904a6afd711e7",
"answer": "",
"answerType": "3"
}
- channelId内容会保存7200秒,其实是利用其中的记录的historyKey字段,来使Mrcp直接发送的语句寻找到history,对结尾字段丢失的处理
127.0.0.1:6379> get 475d250cafb911e7
{
"timestamp": 1507859611630,
"content": "嗯;time=80 800",
"talkertype": "2",
"id": "15019260912",
"userphone": "15019260912",
"cmd": "",
"channelId": "475d250cafb911e7",
"historyKey": "history_1_9368_1507861321-727547",
"answer": "",
"answerType": "3"
}
- channelId- +
yyyy-MM-dd-HH
,统计每个小时channelId的个数
127.0.0.1:6379> get channelId-2017-10-10-12
8437
隐藏逻辑
- 如果获取CTI平台content内容为‘#’时,则丢掉该条记录,和mrcp一起约定
访问 防骚扰处理逻辑(四) 了解详情。
有问题欢迎咨询邮箱[1]
网友评论