# Message Channel

![](https://1452285857-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmAUnBnyZgZuLF2eWLn%2Fuploads%2Fgit-blob-89f538be698c8b752bd8178e8c71e5a3aaf2f624%2Fmessage-channel-connection.svg?alt=media)

*`Message channel`*&#x61;bstracts communication between components. It does allow for sending and receiving messages.\
A message channel may follow either point-to-point or publish-subscribe semantics.\
With a point-to-point channel, only one consumer can receive each message sent to the channel.\
Publish-subscribe channels, broadcast each message to all subscribers on the channel.

```php
interface MessageChannel
{
    /**
     * Send message to this channel
     */
    public function send(Message $message): void;
}
```

*`Pollable channels`* extends Message Channels with capability of buffering Messages within a queue. The advantage of buffering is that it allows for throttling the inbound messages and preventing of message loss.

```php
interface PollableChannel extends MessageChannel
{
    /**
     * Receive a message from this channel.
     * Return the next available {@see \Ecotone\Messaging\Message} or {@see null} if interrupted.
     */
    public function receive(): ?Message;

    /**
     * Receive with timeout
     * Tries to receive message till time out passes
     */
    public function receiveWithTimeout(int $timeoutInMilliseconds): ?Message;
}
```
