Git Product home page Git Product logo

Comments (4)

shouhu avatar shouhu commented on May 21, 2024

TIM截图20190430180247
1.不知道作者是否遇到过 多线程进行发送消息的时候例如A->B->C 这种顺序发送消息 但是具体接受消息的顺序不是这个顺序 那样的话解析的时候就会出错 比如C->B->A 这种顺序返回 这种情况是否有好的方案解决?

from nettychat.

FreddyChen avatar FreddyChen commented on May 21, 2024

TIM截图20190430175740
1.发送失败是否也需要返回给应用层
2.如果发送的时候发现连接失败 也就是心跳机制一直再重连 但是就是发送一瞬间连接断掉 这个时候直接暴力返回是否不好?是否再发送的时候判断连接是否挂掉 然后做重连操作?

首先,非常感谢您提出的问题。
1.如果channel不为空,也就是长连接正常的话,消息发送失败会返回给应用层,详见MsgTimeoutTask.java,但channel为空的话,也就是长连接已断开或者没连上,这个时候可以加上返回给应用层的逻辑。
2.虽然这种情况不常见,但确实是一个问题,后续会优化,再次感谢您的意见。

from nettychat.

FreddyChen avatar FreddyChen commented on May 21, 2024

TIM截图20190430180247
1.不知道作者是否遇到过 多线程进行发送消息的时候例如A->B->C 这种顺序发送消息 但是具体接受消息的顺序不是这个顺序 那样的话解析的时候就会出错 比如C->B->A 这种顺序返回 这种情况是否有好的方案解决?

这种情况我遇到不少,虽然不是经常出现,但网络情况不稳定的话,出现的概率也并不低。我观察过微信,也会有这种问题出现,但出现的概率比较低。正常情况下,不会出现这种情况。而且,消息顺序,不是太重要的,比如发送方发送A-B-C三条消息,接收方收到的顺序是C-B-A或B-C-A之类的,应该没有太大的问题,如果真的要解决的话,我个人觉得,用消息队列来处理应该可以,就是发送的时候,先把消息放到队列里,再从队列里取出,如果发送成功,就从队列中移除,如果不成功,就指定一个重试周期,但不能太长,不然会影响后面的消息的发送,如果一个重试周期还是发送不成功的话,可以放到队列的末尾,或者移除掉,通知应用层手动重发。如果您有更好的方案,也麻烦告诉我哈,一起学习。

from nettychat.

shouhu avatar shouhu commented on May 21, 2024

其实我的意思是 如果多线程消息返回顺序错误 会导致相应的线程回调出问题 例如一个回调期待的是PersonEntity 但是由于错乱 返回了PersonAEntity 这样会出现问题 之前我也没好的办法解决 就使用串行来解决 跟你说的消息队列是同一种方案

from nettychat.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.