<!--Content built using /OpenForum/Javascript/PageBuilder/default-page.builder.js 0.0.7 Gloomy November builder and renderer DefaultRenderer v1.08 2021 Covid release-->
<!-- Generated by Page Block Editor v 0.0.1 -->
<div class='row'><p><!--Content built using /OpenForum/Javascript/PageBuilder/default-page.build.js 0.0.6 July Storm builder and renderer DefaultRenderer v1.07 2021 Covid free release-->
<ol><li> Edit page.js</li>
<li> Add the message queue javascript library</li>
<xmp class="panel" of-exclude="true">OpenForum.loadScript("/OpenForum/MessageQueue/MessageQueue.js");</xmp>
<li> Set up queue polling</li>
<xmp class="panel" of-exclude="true">
var queueName = "my-queue-name";
var queue;

OpenForum.init = function() {
  queue = new MessageQueue(queueName);

  timer = setInterval( queue.pull , 1000 );
};
</xmp>
<li> Create a queue processor</li>
<xmp class="panel" of-exclude="true">
var queueName = "my-queue-name";
var queue;

OpenForum.init = function() {
  queue = new MessageQueue(queueName);

  queue.processMessages = function(messages) {
    for(var i=0; i< messages.length; i++) {
          processMessage(messages<a href="/OpenForum/Editor?pageName=/OpenForumDocumentation/CookBook/AddAQueueServiceToAPage/i"target="editor" style="color: red" title="The page /OpenForum/Editor?pageName=/OpenForumDocumentation/CookBook/AddAQueueServiceToAPage/i does not exist. Click to create it.">i</a>);
    }
  };

  timer = setInterval( queue.pull , 1000 );
};

functioon processMessage(message) {
//do something with the message
}

</xmp></ol></p>
<br/>
</div>

