Final Class Yiisoft\Queue\Message\GenericMessage
| Inheritance | Yiisoft\Queue\Message\GenericMessage » Yiisoft\Queue\Message\Message |
|---|---|
| Implements | Yiisoft\Queue\Message\MessageInterface |
A general-purpose immutable {@see MessageInterface} implementation that holds a message type and its payload data.
Prefer creating custom message classes that better express your domain.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Queue\Message\GenericMessage | |
| fromData() | Creates a new message instance from the given type and payload data. | Yiisoft\Queue\Message\GenericMessage |
| getData() | Returns the message payload data. | Yiisoft\Queue\Message\GenericMessage |
| getMetadata() | Yiisoft\Queue\Message\Message | |
| getType() | Returns the message type used to resolve the handler. | Yiisoft\Queue\Message\GenericMessage |
| withMetadata() | Yiisoft\Queue\Message\Message |
Method Details
| public mixed __construct ( string $type, mixed $data ) | ||
| $type | string |
A message type used to resolve the handler. |
| $data | mixed |
Message payload data. |
public function __construct(
private readonly string $type,
private readonly mixed $data,
) {}
Creates a new message instance from the given type and payload data.
| public static Yiisoft\Queue\Message\MessageInterface fromData ( string $type, mixed $data ) | ||
| $type | string |
A message type used to resolve the handler. |
| $data | mixed |
Message payload data. |
| return | Yiisoft\Queue\Message\MessageInterface |
The created message instance. |
|---|---|---|
public static function fromData(string $type, mixed $data): MessageInterface
{
return new self($type, $data);
}
Returns the message payload data.
| public mixed getData ( ) |
public function getData(): mixed
{
return $this->data;
}
Defined in: Yiisoft\Queue\Message\Message::getMetadata()
| public array getMetadata ( ) |
final public function getMetadata(): array
{
return $this->metadata;
}
Returns the message type used to resolve the handler.
| public string getType ( ) |
public function getType(): string
{
return $this->type;
}
Defined in: Yiisoft\Queue\Message\Message::withMetadata()
| public static withMetadata ( array $metadata ) | ||
| $metadata | array | |
final public function withMetadata(array $metadata): static
{
$new = clone $this;
$new->metadata = $metadata;
return $new;
}
Signup or Login in order to comment.