UNPKG

amqp-dsl

Version:

Amqp-DSL - Fluent interface for node-amqp

27 lines (21 loc) 4.64 kB
<!DOCTYPE html> <html> <head> <title>example-connection.coffee</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To &hellip; <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="example-advanced.html"> example-advanced.coffee </a> <a class="source" href="example-connection.html"> example-connection.coffee </a> <a class="source" href="example-simple.html"> example-simple.coffee </a> <a class="source" href="AmqpDsl.html"> AmqpDsl.coffee </a> <a class="source" href="AmqpExchange.html"> AmqpExchange.coffee </a> <a class="source" href="AmqpQueue.html"> AmqpQueue.coffee </a> <a class="source" href="IndexedList.html"> IndexedList.coffee </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> example-connection.coffee </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">&#182;</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="nv">AmqpDsl = </span><span class="nx">require</span> <span class="s1">&#39;amqp-dsl&#39;</span> <span class="nx">AmqpDsl</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">&#182;</a> </div> <p>First we log in, here the list of the available parameters and their default value</p> <pre><code>{ login: 'guest' password: 'guest' host: 'localhost' port: 5672 vhost: '/' } </code></pre> </td> <td class="code"> <div class="highlight"><pre> <span class="p">.</span><span class="nx">login</span><span class="p">(</span> <span class="nv">login: </span><span class="s1">&#39;user&#39;</span> <span class="nv">password: </span><span class="s1">&#39;password&#39;</span> <span class="nv">host: </span><span class="s1">&#39;localhost&#39;</span> <span class="p">)</span> </pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">&#182;</a> </div> <p>We could do something else like creating <code>queues</code> or connecting to existing <code>exchange</code> (take a look at <code>example-simple.coffee</code> for that) but for now we just want to start the connection.</p> </td> <td class="code"> <div class="highlight"><pre> <span class="p">.</span><span class="nx">connect</span><span class="p">(</span><span class="nf">(err, amqp) -&gt;</span> <span class="k">if</span> <span class="nx">err</span> <span class="k">throw</span> <span class="nx">err</span> <span class="k">return</span> </pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">&#182;</a> </div> <p><code>amqp.connections</code> == <code>[node-amqp::Connection]</code></p> </td> <td class="code"> <div class="highlight"><pre> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="s1">&#39;We are connected !&#39;</span> <span class="p">)</span> </pre></div> </td> </tr> </tbody> </table> </div> </body> </html>