title: Custom Magento 2 Messages Only Show On /checkout/cart/ Page
body: <p>I am trying to write a simple extension that utilises the <code>\Magento\Framework\Message\ManagerInterface</code> to add a custom success message on all pages. I have built this observer:</p>
  
  <pre><code>&lt;?php
  namespace Revolution\MessageCentre\Observer;
  use Magento\Framework\Event\ObserverInterface;
  
  class ControllerActionPredispathObserver implements ObserverInterface
  {
      /**
       * @var \Magento\Framework\App\RequestInterface
       */
      protected $request;
  
      /**
       * @var \Magento\Framework\Message\ManagerInterface
       */
      protected $messageManager;
  
      /**
       * @param \Magento\Framework\App\RequestInterface $request
       * @param \Magento\Framework\Message\ManagerInterface $messageManager
       */
      public function __construct(
          \Magento\Framework\App\RequestInterface $request,
          \Magento\Framework\Message\ManagerInterface $messageManager
      ) {
          $this-&gt;request = $request;
          $this-&gt;messageManager = $messageManager;
      }
  
      /**
       * Pre-dispatch frontend controller action
       *
       * @param \Magento\Framework\Event\Observer $observer
       * @return void
       */
      public function execute(\Magento\Framework\Event\Observer $observer)
      {
          $requestParams = $this-&gt;request-&gt;getParams();
  
          $this-&gt;messageManager-&gt;addSuccessMessage(__('This is a success message'));
      }
  }
  </code></pre>
  
  <p>The observer listens on frontend controller action predispatch. Here is the <code>etc/frontend/events.xml</code>:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"&gt;
      &lt;event name="controller_action_predispatch"&gt;
          &lt;observer name="revolution_messagecentre_controller_action_predispatch" instance="MyNamespace\MessageCentre\Observer\ControllerActionPredispathObserver" shared="false" /&gt;
      &lt;/event&gt;
  &lt;/config&gt;
  </code></pre>
  
  <p>It works fine as it adds the success message on the <code>/checkout/cart/</code> page, however it only appears on this page. I can see in the network panel of Chrome and in the source that the <code>magento/module-theme/view/frontend/templates/messages.phtml</code> is appearing on pages like the product page, but it is empty, no messages are coming through here. Why? I have done a comprehensive nuke of all caches, tried again with browser cache disabled but still no messages. What triggers the actual rendering of the messages, and why is this missing from all pages except the cart? Thanks in advance!</p>