public function attach(MessageInterface $message)
{
// force handling the timer tasks now
$this->synchronized(function (MessageQueue $self, MessageInterface $m) {
// create a unique identifier for the priority
$priority = $this->uniqueWorkerName($m->getPriority());
// load the worker for the message's priority
if (isset($self->workers[$priority])) {
// attach the message
$self->messages[$m->getMessageId()] = $m;
// store the job-ID and the PK of the message => necessary to load the message later
$jobWrapper = new \stdClass();
$jobWrapper->jobId = $m->getMessageId();
$jobWrapper->messageId = $m->getMessageId();
// attach the job to the worker
$self->workers[$priority]->attach($jobWrapper);
}
}, $this, $message);
}