亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Home WeChat Applet WeChat Development WeChat public platform development: request message deduplication

WeChat public platform development: request message deduplication

Feb 27, 2017 pm 01:34 PM

In order to ensure the arrival rate of information request messages, the WeChat server will send the same request message (RequestMessage) multiple times if it does not receive the response message (ResponseMessage) in time. All text content including MsgId, etc. are consistent.

This mechanism ensures the success rate of message reply in situations such as poor network conditions. However, sometimes due to server load and the request process itself taking several seconds to complete, multiple repeated messages Instead, it becomes a burden on the server and may even affect business and data.

In response to this situation, the SDK has added a deduplication setting. You only need to add a sentence when using MessageHandler:

messageHandler.OmitRepeatedMessage = true;//啟用消息去重功能
/// <summary>
 /// 最簡化的處理流程(不加密)
 /// </summary>
 [HttpPost]
 [ActionName("MiniPost")]
 public ActionResult MiniPost(string signature, string timestamp, string nonce, string echostr)
 {
     if (!CheckSignature.Check(signature, timestamp, nonce, Token))
     {
         return new WeixinResult("參數(shù)錯誤!");//v0.8+
     }
 
     var messageHandler = new CustomMessageHandler(Request.InputStream, null, 10);
 
     messageHandler.OmitRepeatedMessage = true;//啟用消息去重功能
 
     messageHandler.Execute();//執(zhí)行微信處理過程
 
     return new FixWeixinBugWeixinResult(messageHandler);
 }

The principle of deduplication is through the context of the current user. Determine whether the MsgId of the current request message and the previous request message are consistent. If they are consistent, the downward execution will be terminated.

File: Senparc.Weixin.MessageHandlers.MessageHandler.cs

public virtual void OnExecuting()
{
    if (OmitRepeatedMessage && CurrentMessageContext.RequestMessages.Count > 1)
    {
        var lastMessage = CurrentMessageContext.RequestMessages[CurrentMessageContext.RequestMessages.Count - 2];
        if (lastMessage.MsgId != 0 && lastMessage.MsgId == RequestMessage.MsgId)
        {
            CancelExcute = true;//重復(fù)消息,取消執(zhí)行
        }
    }
}


For more WeChat public platform development: Request message deduplication related articles, please pay attention to PHP Chinese net!


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1488
72