コード例 #1
0
 /**
  * @return ProcessType
  */
 public function processType()
 {
     if (is_null($this->processType)) {
         $this->processType = ProcessType::fromString($this->payload['process_type']);
     }
     return $this->processType;
 }
コード例 #2
0
 /**
  * @test
  */
 function it_can_be_reconstituted_with_a_task_list()
 {
     $task1 = TaskId::generate();
     $task2 = TaskId::generate();
     $process = Process::withTaskList([$task1, $task2], ProcessId::generate(), ProcessType::linearMessaging());
     $this->assertTrue($task1->equals($process->tasks()[0]));
     $this->assertTrue($task2->equals($process->tasks()[1]));
     $this->assertTrue(ProcessType::linearMessaging()->equals($process->type()));
 }
コード例 #3
0
 /**
  * @param ProcessType $other
  * @return bool
  */
 public function equals(ProcessType $other)
 {
     return $this->toString() === $other->toString();
 }
コード例 #4
0
 /**
  * Determine the required process type based on given message and the message handler which will receive the message.
  *
  * @param Message $message
  * @param MessageHandler $messageHandler
  * @return ProcessType
  * @throws Workflow\Exception\MessageIsNotManageable
  */
 private function determineProcessType(Message $message, MessageHandler $messageHandler)
 {
     if ($messageHandler->canHandleMessage($message)) {
         if ($message->processingMetadata()->shouldCollectionBeSplitIntoChunks()) {
             $processType = ProcessType::parallelChunk();
         } else {
             $processType = ProcessType::linearMessaging();
         }
     } else {
         //We create the error before trying the foreach alternative to provide the client with the original error message
         //if the alternative fails too.
         $originalError = MessageIsNotManageable::byMessageHandler($messageHandler, $message);
         //Check if we can use a foreach process to avoid the rejection of the message
         if ($this->isForeachProcessPossible($message, $messageHandler)) {
             $processType = ProcessType::parallelForeach();
         } else {
             throw $originalError;
         }
     }
     return $processType;
 }
コード例 #5
0
 /**
  * @test
  */
 function it_is_equal_to_a_similar_type()
 {
     $type1 = ProcessType::parallelChunk();
     $type2 = ProcessType::parallelChunk();
     $this->assertTrue($type1->equals($type2));
 }