Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions ProcessMaker/Console/Commands/Consumer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace ProcessMaker\Console\Commands;

use Exception;
use Illuminate\Console\Command;
use ProcessMaker\Facades\MessageBrokerService;

class Consumer extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'processmaker:consumer';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Run the consumer worker for the configured broker messages.';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*/
public function handle()
{
try {
MessageBrokerService::worker();
} catch (Exception $e) {
$this->warn($e->getMessage());
}
}
}
186 changes: 186 additions & 0 deletions ProcessMaker/Contracts/WorkflowManagerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
<?php

namespace ProcessMaker\Contracts;

use ProcessMaker\Models\Process as Definitions;
use ProcessMaker\Models\ProcessRequestToken as Token;
use ProcessMaker\Nayra\Contracts\Bpmn\BoundaryEventInterface;
use ProcessMaker\Nayra\Contracts\Bpmn\EntityInterface;
use ProcessMaker\Nayra\Contracts\Bpmn\EventDefinitionInterface;
use ProcessMaker\Nayra\Contracts\Bpmn\ProcessInterface;
use ProcessMaker\Nayra\Contracts\Bpmn\ScriptTaskInterface;
use ProcessMaker\Nayra\Contracts\Bpmn\ServiceTaskInterface;
use ProcessMaker\Nayra\Contracts\Bpmn\StartEventInterface;
use ProcessMaker\Nayra\Contracts\Bpmn\ThrowEventInterface;
use ProcessMaker\Nayra\Contracts\Bpmn\TokenInterface;
use ProcessMaker\Nayra\Contracts\Engine\ExecutionInstanceInterface;

interface WorkflowManagerInterface
{
/**
* Complete a task.
*
* @param Definitions $definitions
* @param ExecutionInstanceInterface $instance
* @param TokenInterface $token
* @param array $data
*
* @return void
*/
public function completeTask(Definitions $definitions, ExecutionInstanceInterface $instance, TokenInterface $token, array $data);

/**
* Complete a catch event
*
* @param Definitions $definitions
* @param ExecutionInstanceInterface $instance
* @param TokenInterface $token
* @param array $data
*
* @return void
*/
public function completeCatchEvent(Definitions $definitions, ExecutionInstanceInterface $instance, TokenInterface $token, array $data);

/**
* Trigger a boundary event
*
* @param Definitions $definitions
* @param ExecutionInstanceInterface $instance
* @param TokenInterface $token
* @param BoundaryEventInterface $boundaryEvent
* @param array $data
*
* @return void
*/
public function triggerBoundaryEvent(Definitions $definitions, ExecutionInstanceInterface $instance, TokenInterface $token, BoundaryEventInterface $boundaryEvent, array $data);

/**
* Trigger an start event and return the instance.
*
* @param Definitions $definitions
* @param StartEventInterface $event
*
* @return \ProcessMaker\Models\ProcessRequest
*/
public function triggerStartEvent(Definitions $definitions, StartEventInterface $event, array $data);

/**
* Start a process instance.
*
* @param Definitions $definitions
* @param ProcessInterface $process
* @param array $data
*
* @return \ProcessMaker\Models\ProcessRequest
*/
public function callProcess(Definitions $definitions, ProcessInterface $process, array $data);

/**
* Run a script task.
*
* @param ScriptTaskInterface $scriptTask
* @param Token $token
*/
public function runScripTask(ScriptTaskInterface $scriptTask, Token $token);

/**
* Run a service task.
*
* @param ServiceTaskInterface $serviceTask
* @param Token $token
*/
public function runServiceTask(ServiceTaskInterface $serviceTask, Token $token);

/**
* Catch a signal event.
*
* @param ServiceTaskInterface $serviceTask
* @param Token $token
* @deprecated 4.0.15 Use WorkflowManager::throwSignalEventDefinition()
*/
public function catchSignalEvent(ThrowEventInterface $source = null, EventDefinitionInterface $sourceEventDefinition, TokenInterface $token);

/**
* Throw a signal event.
*
* @param EventDefinitionInterface $sourceEventDefinition
* @param Token $token
*/
public function throwSignalEventDefinition(EventDefinitionInterface $sourceEventDefinition, TokenInterface $token);

/**
* Throw a signal event by id (signalRef).
*
* @param string $signalRef
* @param array $data
* @param array $exclude
*/
public function throwSignalEvent($signalRef, array $data = [], array $exclude = []);

/**
* Catch a signal event.
*
* @param EventDefinitionInterface $sourceEventDefinition
* @param Token $token
*/
public function throwMessageEvent($instanceId, $elementId, $messageRef, array $payload = []);

/**
* Attach validation event
*
* @param callable $callback
* @return void
*/
public function onDataValidation($callback);

/**
* Validate data
*
* @param array $data
* @param Definitions $Definitions
* @param EntityInterface $element
*
* @return void
*/
public function validateData(array $data, Definitions $Definitions, EntityInterface $element);

/**
* Run a process and returns its data
*
* @param Definitions $definitions
* @param string $startId
* @param array $data
*
* @return array
*/
public function runProcess(Definitions $definitions, $startId, array $data);

/**
* Check if service task implementation exists
*
* @param string $implementation
*
* @return bool
*/
public function registerServiceImplementation($implementation, $class);

/**
* Check if service task implementation exists
*
* @param string $implementation
*
* @return bool
*/
public function existsServiceImplementation($implementation);

/**
* Run the service task implementation
* @param string $implementation
* @param array $dat
* @param array $config
* @param string $tokenId
*
* @return mixed
*/
public function runServiceImplementation($implementation, array $data, array $config, $tokenId = '');
}
21 changes: 21 additions & 0 deletions ProcessMaker/Facades/MessageBrokerService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace ProcessMaker\Facades;

use Illuminate\Support\Facades\Facade;
use ProcessMaker\Nayra\MessageBrokers\ServiceInterface;

/**
* @method static void connect()
* @method static void disconnect()
* @method static void sendMessage(string $subject, string $collaborationId, mixed $body)
* @method static string receiveMessage(string $queueName)
* @method static void worker()
*/
class MessageBrokerService extends Facade
{
protected static function getFacadeAccessor()
{
return ServiceInterface::class;
}
}
Loading