Пример #1
0
/** @var CInteropSender $sender */
$sender = CMbObject::loadFromGuid($actor_guid);
$sender->loadRefGroup();
$sender->loadRefsExchangesSources();
$delete_file = $sender->_delete_file;
/** @var CExchangeSource $source */
$source = reset($sender->_ref_exchanges_sources);
if (!$source->active) {
    return;
}
$path = $source->getFullPath($source->_path);
$filename_excludes = "{$path}/mb_excludes.txt";
// Initialisation d'un fichier de verrou de 240 secondes
$lock = new CMbMutex("dispatch-files-{$sender->_guid}");
// On tente de verrouiller
if (!$lock->lock(240)) {
    return;
}
$count = $source->_limit = CAppUI::conf("eai max_files_to_process");
$files = array();
try {
    $files = $source->receive();
} catch (CMbException $e) {
    CCronJobLog::$log = $e->getMessage();
    $e->stepAjax();
}
$fileextension = $source->fileextension;
$fileextension_write_end = $source->fileextension_write_end;
$files_excludes = array();
if (file_exists($filename_excludes)) {
    $files_excludes = array_map('trim', file($filename_excludes));
 case "stall":
     CAppUI::stepAjax("test_mutex-acquired", UI_MSG_OK, $mutex->acquire($duration));
     sleep(5);
     $mutex->release();
     break;
 case "die":
     CAppUI::stepAjax("test_mutex-acquired", UI_MSG_OK, $mutex->acquire($duration));
     sleep(5);
     CApp::rip();
     break;
 case "run":
     CAppUI::stepAjax("test_mutex-acquired", UI_MSG_OK, $mutex->acquire($duration));
     $mutex->release();
     break;
 case "lock":
     $locked_aquired = $mutex->lock($duration);
     if ($locked_aquired) {
         CAppUI::stepAjax("test_mutex-lock_aquired", UI_MSG_OK);
         sleep(5);
         $mutex->release();
     } else {
         CAppUI::stepAjax("test_mutex-already_locked", UI_MSG_WARNING);
     }
     break;
 case "dummy":
     // Nothing to do
     CAppUI::stepAjax("test_mutex-dummy", UI_MSG_OK);
     break;
 default:
     CAppUI::stepAjax("test_mutex-fail", UI_MSG_WARNING, $action);
     return;