src/PublisherLocator/HeaderPublisherLocator.php
public function getPublisherForMessage(Message $message)
    {
        $attributes = $message->getAttributes();
        if (!isset($attributes['headers']) || !isset($attributes['headers'][$this->headerName])) {
            throw MissingPublisherException::noHeaderInMessage($message, $this->headerName);
        }

        $value = $attributes['headers'][$this->headerName];
        foreach ($this->valueMap as $hash => $values) {
            if (!in_array($value, $values, true)) {
                continue;
            }

            return $this->publishers[$hash];
        }

        throw MissingPublisherException::noKnownPublisherFor($message);
    }
public function getPublisherForMessage(Message $message)
    {
        $attributes = $message->getAttributes();
        if (!isset($attributes['headers']) || !isset($attributes['headers'][$this->headerName])) {
            throw MissingPublisherException::noHeaderInMessage($message, $this->headerName);
        }

        $value = $attributes['headers'][$this->headerName];
        foreach ($this->valueMap as $hash => $values) {
            if (!in_array($value, $values, true)) {
                continue;
            }

            return $this->publishers[$hash];
        }

        throw MissingPublisherException::noKnownPublisherFor($message);
    }
Retrieves the publisher for a specified message

@param Message $message

@return Publisher

@throws MissingPublisherException