Documentation

Activity extends Facade
in package

FinalYes
Tags
template-extends

Facade<ActivityContextInterface>

Table of Contents

Methods

doNotCompleteOnReturn()  : void
Marks the activity as incomplete for asynchronous completion.
getHeartbeatDetails()  : mixed
Returns the payload passed into the last heartbeat.
getInfo()  : ActivityInfo
Returns information about current activity execution.
getInput()  : ValuesInterface
Returns activity execution input arguments.
hasHeartbeatDetails()  : bool
Check if the heartbeat's first argument has been passed.
heartbeat()  : void
Use to notify workflow that activity execution is alive.

Methods

doNotCompleteOnReturn()

Marks the activity as incomplete for asynchronous completion.

public static doNotCompleteOnReturn() : void

If this method is called during an activity execution then activity is not going to complete when its method returns. It is expected to be completed asynchronously using ActivityCompletionClientInterface::complete().

Tags
throws
OutOfContextException

in the absence of the activity execution context.

getHeartbeatDetails()

Returns the payload passed into the last heartbeat.

public static getHeartbeatDetails([Type|string|ReflectionType|ReflectionClass|null $type = null ]) : mixed

This method retrieves the payload that was passed into the last call of the Activity::heartbeat() method.

Parameters
$type : Type|string|ReflectionType|ReflectionClass|null = null
Tags
throws
OutOfContextException

in the absence of the activity execution context.

getInput()

Returns activity execution input arguments.

public static getInput() : ValuesInterface

The data is equivalent to what is passed to the activity method handler.

 #[ActivityMethod]
 public function activityMethod(int $first, string $second)
 {
     $arguments = Activity::getInput();

     Assert::assertTrue($first,  $arguments->getValue(0, Type::TYPE_INT));
     Assert::assertTrue($second, $arguments->getValue(1, Type::TYPE_STRING));
 }
Tags
throws
OutOfContextException

in the absence of the activity execution context.

Return values
ValuesInterface

hasHeartbeatDetails()

Check if the heartbeat's first argument has been passed.

public static hasHeartbeatDetails() : bool

This method returns true if the first argument has been passed to the Activity::heartbeat() method.

Tags
throws
OutOfContextException

in the absence of the activity execution context.

Return values
bool

heartbeat()

Use to notify workflow that activity execution is alive.

public static heartbeat(mixed $details) : void
 public function activityMethod()
 {
     // An example method of deferred request
     $query = $this->db->query('SELECT * FROM table WHERE 1=1');

     // Wait for response
     while (!$query->isCompleted()) {
         Activity::heartbeat('Waiting for activity response');
     }

     // Returns response of deferred request
     return $query->getResult();
 }
Parameters
$details : mixed

In case of activity timeout details are returned as a field of the exception thrown.

Tags
throws
OutOfContextException

in the absence of the activity execution context.


        
On this page

Search results