本文介绍了Salesforce / PHP - 批量出站消息(SOAP),超时问题 - 请参阅更新#2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Salesforce可以在1封SOAP消息中发送最多100个请求。在发送此类型的Bulk Ooutbound消息请求时,我的PHP脚本完成执行,但SF无法接受用于清除Salesforce端消息队列的ACK。查看出站消息日志(监视),我看到所有处于挂起状态的消息,其中包含传递失败原因java.net.SocketTimeoutException:read timed out。如果我的脚本已完成执行,为什么会出现此错误?

Salesforce can send up to 100 requests inside 1 SOAP message. While sending this type of Bulk Ooutbound message request my PHP script finishes executing but SF fails to accept the ACK used to clear the message queue on the Salesforce side of things. Looking at the Outbound message log (monitoring) I see all the messages in a pending state with the Delivery Failure Reason "java.net.SocketTimeoutException: Read timed out". If my script has finished execution, why do I get this error?

我尝试过这些方法来增加服务器上的执行时间,因为我无法访问Salesforce端:

I have tried these methods to increase the execution time on my server as I have no access on the Salesforce side:


  • set_time_limit(0); //在脚本中

  • max_execution_time = 360;每个脚本的最长执行时间,以秒为单位

  • max_input_time = 360;每个脚本可用于解析请求数据的最长时间

  • memory_limit = 32M;脚本可能占用的最大内存量

  • set_time_limit(0); // in the script
  • max_execution_time = 360 ; Maximum execution time of each script, in seconds
  • max_input_time = 360 ; Maximum amount of time each script may spend parsing request data
  • memory_limit = 32M ; Maximum amount of memory a script may consume

我使用高设置进行测试。

I used the high settings just for testing.

有什么想法为什么没有将ACK交付给Salesforce?

Any thoughts as to why this is failing the ACK delivery back to Salesforce?

以下是一些代码:
这就是我的看法接受并发送即将发送的SOAP请求的ACK文件

Here is some of the code:This is how I accept and send the ACK file for the imcoming SOAP request

$data = 'php://input';
$content = file_get_contents($data);

if($content) {
    respond('true');
} else {
    respond('false');
}

回复功能

function respond($tf) {
    $ACK = <<<ACK
<?xml version = "1.0" encoding = "utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <notifications xmlns="http://soap.sforce.com/2005/09/outbound">
            <Ack>$tf</Ack>
        </notifications>
    </soapenv:Body>
</soapenv:Envelope>
ACK;

    print trim($ACK); 
}

这些是我在包含在使用数据的脚本中的通用脚本对于特定的工作流程。我可以处理大约25个请求(这是在1个SOAP响应中)但是一旦我查看,我在Salesforce队列中得到了超时错误。 50个请求通常需要我的PHP脚本86.77秒。

These are in a generic script that I include into the script that uses the data for a specific workflow. I can process about 25 requests (That are in 1 SOAP response) but once I go over that I get the timeout error in the Salesforce queue. for 50 requests is usually takes my PHP script 86.77 seconds.

可能是Apache吗? PHP?

Could it be Apache? PHP?

我还测试过只接受100个请求SOAP响应,只是接受并发送队列清除的ACK,所以我知道这是我自己的事情。

I have also tested just accepting the 100 request SOAP response and just accepting and sending the ACK the queue clears out, so I know it's on my side of things.

我在apache日志中没有显示错误,脚本运行正常。

I show no errors in the apache log, the script runs fine.

我确实在Salesforce上找到了一些信息网站但仍然没有运气。这是。

I did find some info on the Salesforce site but still no luck. Here is the link.

我也在使用PHP Toolkit 11(来自Salesforce)。

Also I'm using the PHP Toolkit 11 (From Salesforce).

感谢您对此有任何见解,
--Phill

Thanks for any insight into this,--Phill

更新:

如果我收到收到的消息并打印回复,那么不管我之后做了什么,都应该先发生这种情况吗?还是等待我的流程完成然后打印响应?

If I receive the incoming message and print the response, should this happen first regardless if I do anything else after? Or does it wait for my process to finish and then print the response?

更新#2:

好吧我想我有问题:
PHP使用单一线程处理方法,并且在线程完成它的处理之前不会发回ACK文件。有没有办法使这成为一个多线程进程?
线程#1 - 接受传入的SOAP请求并发回ACK
线程#2 - 处理SOAP请求

okay I think I have the problem:PHP uses the single thread processing approach and will not send back the ACK file until the thread has completed it's processing. Is there a way to make this a mutli thread process?Thread #1 - accept the incoming SOAP request and send back the ACKThread #2 - Process the SOAP request

我知道我可以打破它就像一个DB表或平面文件,但有没有办法实现这一点而不这样做?

I know I could break it up into like a DB table or flat file, but is there a way to accomplish this without doing that?

我将尝试关闭套接字后提交确认并继续处理,交叉我的手指它将起作用。

I'm going to try to close the socket after the ACK submission and continue the processing, cross my fingers it will work.

推荐答案

所以我所做的是:


  1. 接受所有传入的OBM,将它们解析为数据库

  2. 执行此操作时,将运行一个进程在后台(实际上我把它发送到后台,所以脚本可以结束)

  3. 发回ACK文件

通过接受原始数据,解析到字段并将其插入到数据库中相当快。然后我发出一个Linux命令行命令,该命令也发送处理脚本以在后台运行。然后我将ACK文件发送到SF,脚本在指定的时间内结束。将脚本过程分成两个单独的阶段是很麻烦的,但它可以工作。

By just accepting the raw data, parsing into fields and inserting it into a DB is fairly quick. Then I issue a Linux Command Line command that also send the processing script to run in the background. Then I send the ACK file to SF and the script ends within the allotted time. It is cumbersome to split the script process into two separate stages but it works.

这篇关于Salesforce / PHP - 批量出站消息(SOAP),超时问题 - 请参阅更新#2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 08:07