<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: lalit292929</title>
    <description>The latest articles on DEV Community by lalit292929 (@outspoken_dev).</description>
    <link>https://dev.to/outspoken_dev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F245358%2F969261a2-c947-449e-8f5c-bfe48be8c511.png</url>
      <title>DEV Community: lalit292929</title>
      <link>https://dev.to/outspoken_dev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/outspoken_dev"/>
    <language>en</language>
    <item>
      <title>RabbitMQ with Nodejs Part 2</title>
      <dc:creator>lalit292929</dc:creator>
      <pubDate>Tue, 02 Feb 2021 14:38:01 +0000</pubDate>
      <link>https://dev.to/outspoken_dev/rabbitmq-with-nodejs-part-2-1ibm</link>
      <guid>https://dev.to/outspoken_dev/rabbitmq-with-nodejs-part-2-1ibm</guid>
      <description>&lt;p&gt;In the &lt;a href="https://dev.to/outspoken_dev/rabbitmq-with-nodejs-part-1-3n98"&gt;previous post&lt;/a&gt;, We had our introduction with the message broker and rabbitmq, In this post, we will discuss the first component ie. Connection&lt;/p&gt;

&lt;h2&gt;
  
  
  Connection
&lt;/h2&gt;

&lt;p&gt;Below are the few properties which will help us to understand the connection to rabbitmq &lt;br&gt;
    1. One client library connection uses a single TCP connection. In order for a client to successfully connect with a message broker.&lt;br&gt;
    2. Connections should not be opened by the client for each individual operation.&lt;br&gt;
    3. Once the client connects successfully, it can publish and consume messages.&lt;br&gt;
    4. When the connection is no longer needed, it should be closed to save on resources.&lt;/p&gt;
&lt;h2&gt;
  
  
  Lifecycle:
&lt;/h2&gt;

&lt;p&gt;Below are the major lifecycle component of a connection with the message broker ( RabbitMQ )&lt;br&gt;
    1. Application configures the client library to use a certain connection endpoint (e.g. hostname and port)&lt;br&gt;
    2. The library resolves the hostname to one or more IP addresses&lt;br&gt;
    3. The library opens a TCP connection to the target IP address and port&lt;br&gt;
    4. After the server has accepted the TCP connection, a protocol-specific negotiation procedure is performed&lt;br&gt;
    5. The server then authenticates the client&lt;br&gt;
    6. The client now can perform operations, each of which involves an authorization check by the server.&lt;br&gt;
    7. Once the requirement is completed, a connection is closed.&lt;/p&gt;
&lt;h3&gt;
  
  
  Example Code to establish a connection in nodejs application
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const amqp = require('amqplib');
const connection = await amqp.connect('amqp://localhost');
// your application logic
connection.close();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Logging and Monitoring:
&lt;/h2&gt;

&lt;p&gt;RabbitMQ logs all inbound client connections that send at least 1 byte of data. Connections that are opened without any activity will not be logged. This is to prevent TCP load balancer health checks from flooding the logs.&lt;/p&gt;

&lt;p&gt;Successful authentication, clean and unexpected connection closure will also be logged.&lt;/p&gt;
&lt;h2&gt;
  
  
  Interface :
&lt;/h2&gt;

&lt;p&gt;The following interface of a connection is provided to us by &lt;br&gt;
&lt;a href="https://www.npmjs.com/package/amqplib"&gt;amqplib module&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    close(): Promise&amp;lt;void&amp;gt;;
    createChannel(): Promise&amp;lt;Channel&amp;gt;;
    createConfirmChannel(): Promise&amp;lt;ConfirmChannel&amp;gt;;
    connection: {
        serverProperties: ServerProperties;
    };
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Read More -&amp;gt; &lt;a href="https://www.rabbitmq.com/connections.html"&gt;https://www.rabbitmq.com/connections.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: I am writing for the first time and will highly appreciate any feedback or suggestions.&lt;br&gt;
Find me on &lt;a href="https://www.linkedin.com/in/lalit292929/"&gt;Linkedin&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>rabbitmq</category>
      <category>programming</category>
    </item>
    <item>
      <title>RabbitMQ with Nodejs Part 1</title>
      <dc:creator>lalit292929</dc:creator>
      <pubDate>Mon, 01 Feb 2021 16:46:56 +0000</pubDate>
      <link>https://dev.to/outspoken_dev/rabbitmq-with-nodejs-part-1-3n98</link>
      <guid>https://dev.to/outspoken_dev/rabbitmq-with-nodejs-part-1-3n98</guid>
      <description>&lt;p&gt;Hi all,&lt;br&gt;
Before moving on to RabbitMQ and its example in Nodejs, let us first understand what is a message broker.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is a Message Broker?
&lt;/h1&gt;

&lt;p&gt;A message broker is a software that enables multiple applications to exchange information. The message broker does this by doing multiple things in itself which includes&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Getting a new message from an application ie. Publisher&lt;/li&gt;
&lt;li&gt;Routing the messages to the queue(s) as per the message's metadata&lt;/li&gt;
&lt;li&gt;Maintaining multiple queues for different types of messages&lt;/li&gt;
&lt;li&gt;Facilitating applications (Consumers) of subscribing to these queues and receiving relevant messages&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  What is Rabbit MQ?
&lt;/h1&gt;

&lt;p&gt;According to Wikipedia, RabbitMQ is an open-source message-broker software that originally implemented the Advanced Message Queuing Protocol and has since been extended with a plug-in architecture to support Streaming Text Oriented Messaging Protocol, MQ Telemetry Transport, and other protocols.&lt;br&gt;
It is an open-source message broker that we can use to make our applications communicate using various messaging protocols.&lt;/p&gt;

&lt;p&gt;Before starting with the implementation, We should know some of its components which will help us to understand how it works internally and is this the right software for our use case:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Connection&lt;/li&gt;
&lt;li&gt;Channel&lt;/li&gt;
&lt;li&gt;Exchange&lt;/li&gt;
&lt;li&gt;Queue&lt;/li&gt;
&lt;li&gt;Publisher&lt;/li&gt;
&lt;li&gt;Consumer&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We will start with the basic theory of the above mentioned components along with their implementation using Nodejs. &lt;/p&gt;

&lt;p&gt;Note: I am writing for the first time and will highly appreciate any feedback or suggestions.&lt;br&gt;
Find me on &lt;a href="https://www.linkedin.com/in/lalit292929/"&gt;Linkedin&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/outspoken_dev/rabbitmq-with-nodejs-part-2-1ibm"&gt;Part 2&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>rabbitmq</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
