tag:blogger.com,1999:blog-29994561220626030292024-03-12T23:12:51.288-07:00Development SolutionsThoughts on C#, .NET, programming, software development and productivity. Tips and tricks to solve various programming problems.Niranjan Singhhttp://www.blogger.com/profile/10098432252247322623noreply@blogger.comBlogger342110tag:blogger.com,1999:blog-2999456122062603029.post-59647757404447820172024-03-01T01:18:00.000-08:002024-03-12T23:12:19.226-07:00Leveraging RabbitMQ with C# and .NET: A Comprehensive Guide<p> <span face="-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"" style="color: #24292f;">In today's interconnected world, efficient data transfer between applications is crucial for smooth operations. Whether it's processing large volumes of requests or orchestrating tasks across distributed systems, having a reliable message broker is essential. RabbitMQ, an open-source message broker, provides a robust solution for building scalable and decoupled applications.</span></p><div class="markdown-heading" dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; position: relative;"><h2 class="heading-element" dir="auto" style="border-bottom: 1px solid var(--borderColor-muted, var(--color-border-muted)); box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600); line-height: 1.25; margin-bottom: 16px; margin-top: 24px; padding-bottom: 0.3em;" tabindex="-1"><span style="font-size: small;">Introduction</span></h2><a aria-label="Permalink: Introduction" class="anchor-element" href="https://github.com/niranjankala/niranjankala.github.io/blob/master/_posts/2024-03-01-leveraging-rabbitmq-with-c-and-net-a-comprehensive-guide.md#introduction" id="user-content-introduction" style="align-items: center; border-radius: 6px; box-sizing: border-box; display: flex; height: 28px; justify-content: center; left: -28px; margin: auto; opacity: 0; position: absolute; text-underline-offset: 0.2rem; top: 16.6042px; transform: translateY(calc(-50% - 0.3rem)); width: 28px;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div><p dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; margin-bottom: 16px; margin-top: 0px;">This comprehensive guide will explore leveraging RabbitMQ with C# and .NET to build resilient and flexible messaging systems. From installation to advanced message routing techniques, we'll cover everything you need to know to get started with RabbitMQ.</p><div class="markdown-heading" dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; position: relative;"><h2 class="heading-element" dir="auto" style="border-bottom: 1px solid var(--borderColor-muted, var(--color-border-muted)); box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600); line-height: 1.25; margin-bottom: 16px; margin-top: 24px; padding-bottom: 0.3em;" tabindex="-1"><span style="font-size: small;">Overview of RabbitMQ</span></h2><a aria-label="Permalink: Overview of RabbitMQ" class="anchor-element" href="https://github.com/niranjankala/niranjankala.github.io/blob/master/_posts/2024-03-01-leveraging-rabbitmq-with-c-and-net-a-comprehensive-guide.md#overview-of-rabbitmq" id="user-content-overview-of-rabbitmq" style="align-items: center; border-radius: 6px; box-sizing: border-box; display: flex; height: 28px; justify-content: center; left: -28px; margin: auto; opacity: 0; position: absolute; text-underline-offset: 0.2rem; top: 16.6042px; transform: translateY(calc(-50% - 0.3rem)); width: 28px;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div><p dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; margin-bottom: 16px; margin-top: 0px;">RabbitMQ is a powerful message broker that facilitates communication between different components of an application. It implements the Advanced Message Queuing Protocol (AMQP), providing a standardized way for applications to exchange messages. With RabbitMQ, you can decouple your application components, making them more resilient to failures and more accessible to scale.</p><div class="markdown-heading" dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; position: relative;"><h3 class="heading-element" dir="auto" style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600); line-height: 1.25; margin-bottom: 16px; margin-top: 24px;" tabindex="-1"><span style="font-size: small;">Why RabbitMQ?</span></h3><a aria-label="Permalink: Why RabbitMQ?" class="anchor-element" href="https://github.com/niranjankala/niranjankala.github.io/blob/master/_posts/2024-03-01-leveraging-rabbitmq-with-c-and-net-a-comprehensive-guide.md#why-rabbitmq" id="user-content-why-rabbitmq" style="align-items: center; border-radius: 6px; box-sizing: border-box; display: flex; height: 28px; justify-content: center; left: -28px; margin: auto; opacity: 0; position: absolute; text-underline-offset: 0.2rem; top: 10.9375px; transform: translateY(-50%); width: 28px;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div><ul dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; margin-bottom: 16px; margin-top: 0px; padding-left: 2em;"><li style="box-sizing: border-box;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Cross-platform Compatibility:</span> RabbitMQ runs on multiple platforms, including Windows and Linux, making it suitable for various environments.</li><li style="box-sizing: border-box; margin-top: 0.25em;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Language Agnostic:</span> It supports multiple programming languages, allowing you to build applications in your language of choice.</li><li style="box-sizing: border-box; margin-top: 0.25em;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Persistence Options:</span> RabbitMQ offers in-memory and disk-based message storage options, giving you flexibility in managing message durability.</li><li style="box-sizing: border-box; margin-top: 0.25em;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Scalability:</span> With support for clustering and high availability, RabbitMQ can handle large volumes of messages and scale horizontally as your application grows.</li></ul><div class="markdown-heading" dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; position: relative;"><h2 class="heading-element" dir="auto" style="border-bottom: 1px solid var(--borderColor-muted, var(--color-border-muted)); box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600); line-height: 1.25; margin-bottom: 16px; margin-top: 24px; padding-bottom: 0.3em;" tabindex="-1"><span style="font-size: small;">Installation and Setup</span></h2><a aria-label="Permalink: Installation and Setup" class="anchor-element" href="https://github.com/niranjankala/niranjankala.github.io/blob/master/_posts/2024-03-01-leveraging-rabbitmq-with-c-and-net-a-comprehensive-guide.md#installation-and-setup" id="user-content-installation-and-setup" style="align-items: center; border-radius: 6px; box-sizing: border-box; display: flex; height: 28px; justify-content: center; left: -28px; margin: auto; opacity: 0; position: absolute; text-underline-offset: 0.2rem; top: 16.6042px; transform: translateY(calc(-50% - 0.3rem)); width: 28px;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div><div class="markdown-heading" dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; position: relative;"><h3 class="heading-element" dir="auto" style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600); line-height: 1.25; margin-bottom: 16px; margin-top: 24px;" tabindex="-1"><span style="font-size: small;">Step 1: Installing Erlang Runtime and RabbitMQ Server</span></h3><a aria-label="Permalink: Step 1: Installing Erlang Runtime and RabbitMQ Server" class="anchor-element" href="https://github.com/niranjankala/niranjankala.github.io/blob/master/_posts/2024-03-01-leveraging-rabbitmq-with-c-and-net-a-comprehensive-guide.md#step-1-installing-erlang-runtime-and-rabbitmq-server" id="user-content-step-1-installing-erlang-runtime-and-rabbitmq-server" style="align-items: center; border-radius: 6px; box-sizing: border-box; display: flex; height: 28px; justify-content: center; left: -28px; margin: auto; opacity: 0; position: absolute; text-underline-offset: 0.2rem; top: 10.9375px; transform: translateY(-50%); width: 28px;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div><p dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; margin-bottom: 16px; margin-top: 0px;">Before using RabbitMQ, we need to install the Erlang runtime and RabbitMQ server. Follow these steps to install RabbitMQ on your system:</p><ol dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; margin-bottom: 16px; margin-top: 0px; padding-left: 2em;"><li style="box-sizing: border-box;">Download the latest Erlang runtime from <a href="http://www.erlang.org/download.html" rel="nofollow" style="box-sizing: border-box; text-underline-offset: 0.2rem;">erlang.org</a> and install it on your machine.</li><li style="box-sizing: border-box; margin-top: 0.25em;">Download the latest RabbitMQ server release from <a href="http://www.rabbitmq.com/server.html" rel="nofollow" style="box-sizing: border-box; text-underline-offset: 0.2rem;">rabbitmq.com</a> and unzip the folder to a location on your hard drive. <br /><br /><a href="https://blogger.googleusercontent.com/img/a/AVvXsEh5e135d2_TOHk68XopAKTQHCJqFsxEMeVr-vAA6VHhTyAxyoHqkMFKEbT249uVum6Jh0EyJbxVw8fgQj7pJNKzVfZ-dGDvjlK5XTWYtspbAvO86m3isN_GFdFG0R7AMezBof0QdpveGBhR_wv9vkamlUNvRoAgyfXExtZ_99VqGY0u__kRV-wgwmGjnhZl" style="font-family: "Times New Roman"; margin-left: 1em; margin-right: 1em; text-align: center;"><img alt="" data-original-height="781" data-original-width="1417" height="352" src="https://blogger.googleusercontent.com/img/a/AVvXsEh5e135d2_TOHk68XopAKTQHCJqFsxEMeVr-vAA6VHhTyAxyoHqkMFKEbT249uVum6Jh0EyJbxVw8fgQj7pJNKzVfZ-dGDvjlK5XTWYtspbAvO86m3isN_GFdFG0R7AMezBof0QdpveGBhR_wv9vkamlUNvRoAgyfXExtZ_99VqGY0u__kRV-wgwmGjnhZl=w640-h352" width="640" /></a></li><li style="box-sizing: border-box; margin-top: 0.25em;">Set the <code style="border-radius: 6px; box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; margin: 0px; padding: 0.2em 0.4em; white-space-collapse: break-spaces;">ERLANG_HOME</code> environment variable to the Erlang installation directory. For example:<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" style="box-sizing: border-box; display: flex; justify-content: space-between; margin-bottom: 16px; overflow: auto; position: relative;"><pre style="border-radius: 6px; box-sizing: border-box; color: var(--fgColor-default, var(--color-fg-default)); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; line-height: 1.45; margin-bottom: 0px; margin-top: 0px; min-height: 52px; overflow-wrap: normal; overflow: auto; padding: 16px; word-break: normal;">setx ERLANG_HOME <span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-pds" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span>C:\Program Files\erl10.6<span class="pl-pds" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span></pre><div class="zeroclipboard-container" style="animation: auto ease 0s 1 normal none running none; box-sizing: border-box;"><clipboard-copy aria-label="Copy" class="ClipboardButton btn btn-invisible js-clipboard-copy m-2 p-0 tooltipped-no-delay d-flex flex-justify-center flex-items-center" data-copy-feedback="Copied!" data-tooltip-direction="w" role="button" style="align-items: center; appearance: none; border-radius: 6px; border: 0px; box-shadow: none; box-sizing: border-box; color: var(--fgColor-accent, var(--color-accent-fg)); cursor: pointer; display: flex; font-weight: var(--base-text-weight-medium, 500); height: var(--control-small-size, 28px); justify-content: center; line-height: 20px; margin: var(--base-size-8, 8px) !important; padding: 0px; position: relative; text-wrap: nowrap; transition: color 80ms cubic-bezier(0.33, 1, 0.68, 1) 0s, background-color 0s ease 0s, box-shadow 0s ease 0s, border-color 0s ease 0s; user-select: none; vertical-align: middle; width: var(--control-small-size, 28px);" tabindex="0" value="setx ERLANG_HOME "C:\Program Files\erl10.6""><svg aria-hidden="true" class="octicon octicon-copy js-clipboard-copy-icon" data-view-component="true" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg></clipboard-copy></div></div></li><li style="box-sizing: border-box; margin-top: 0.25em;">Install RabbitMQ as a Windows service by running the following commands in a console:<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" style="box-sizing: border-box; display: flex; justify-content: space-between; margin-bottom: 16px; overflow: auto; position: relative;"><pre style="border-radius: 6px; box-sizing: border-box; color: var(--fgColor-default, var(--color-fg-default)); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; line-height: 1.45; margin-bottom: 0px; margin-top: 0px; min-height: 52px; overflow-wrap: normal; overflow: auto; padding: 16px; word-break: normal;">rabbitmq-service /install
rabbitmq-service /enable
rabbitmq-service /start</pre><div class="zeroclipboard-container" style="animation: auto ease 0s 1 normal none running none; box-sizing: border-box;"><clipboard-copy aria-label="Copy" class="ClipboardButton btn btn-invisible js-clipboard-copy m-2 p-0 tooltipped-no-delay d-flex flex-justify-center flex-items-center" data-copy-feedback="Copied!" data-tooltip-direction="w" role="button" style="align-items: center; appearance: none; border-radius: 6px; border: 0px; box-shadow: none; box-sizing: border-box; color: var(--fgColor-accent, var(--color-accent-fg)); cursor: pointer; display: flex; font-weight: var(--base-text-weight-medium, 500); height: var(--control-small-size, 28px); justify-content: center; line-height: 20px; margin: var(--base-size-8, 8px) !important; padding: 0px; position: relative; text-wrap: nowrap; transition: color 80ms cubic-bezier(0.33, 1, 0.68, 1) 0s, background-color 0s ease 0s, box-shadow 0s ease 0s, border-color 0s ease 0s; user-select: none; vertical-align: middle; width: var(--control-small-size, 28px);" tabindex="0" value="rabbitmq-service /install
rabbitmq-service /enable
rabbitmq-service /start"><svg aria-hidden="true" class="octicon octicon-copy js-clipboard-copy-icon" data-view-component="true" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg></clipboard-copy></div></div></li></ol><div class="markdown-heading" dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; position: relative;"><h3 class="heading-element" dir="auto" style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600); line-height: 1.25; margin-bottom: 16px; margin-top: 24px;" tabindex="-1"><span style="font-size: small;">Step 2: Configuring RabbitMQ</span></h3><a aria-label="Permalink: Step 2: Configuring RabbitMQ" class="anchor-element" href="https://github.com/niranjankala/niranjankala.github.io/blob/master/_posts/2024-03-01-leveraging-rabbitmq-with-c-and-net-a-comprehensive-guide.md#step-2-configuring-rabbitmq" id="user-content-step-2-configuring-rabbitmq" style="align-items: center; border-radius: 6px; box-sizing: border-box; display: flex; height: 28px; justify-content: center; left: -28px; margin: auto; opacity: 0; position: absolute; text-underline-offset: 0.2rem; top: 10.9375px; transform: translateY(-50%); width: 28px;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div><p dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; margin-bottom: 16px; margin-top: 0px;">After installing RabbitMQ, you can use the <code style="border-radius: 6px; box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; margin: 0px; padding: 0.2em 0.4em; white-space-collapse: break-spaces;">rabbitmqctl</code> command-line tool to manage the server. Start by ensuring that the server is running:</p><div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" style="box-sizing: border-box; color: #24292f; display: flex; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; justify-content: space-between; margin-bottom: 16px; overflow: auto; position: relative;"><pre style="border-radius: 6px; box-sizing: border-box; color: var(--fgColor-default, var(--color-fg-default)); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; line-height: 1.45; margin-bottom: 0px; margin-top: 0px; min-height: 52px; overflow-wrap: normal; overflow: auto; padding: 16px; word-break: normal;">rabbitmqctl status</pre><div class="zeroclipboard-container" style="animation: auto ease 0s 1 normal none running none; box-sizing: border-box;"><clipboard-copy aria-label="Copy" class="ClipboardButton btn btn-invisible js-clipboard-copy m-2 p-0 tooltipped-no-delay d-flex flex-justify-center flex-items-center" data-copy-feedback="Copied!" data-tooltip-direction="w" role="button" style="align-items: center; appearance: none; border-radius: 6px; border: 0px; box-shadow: none; box-sizing: border-box; color: var(--fgColor-accent, var(--color-accent-fg)); cursor: pointer; display: flex; font-weight: var(--base-text-weight-medium, 500); height: var(--control-small-size, 28px); justify-content: center; line-height: 20px; margin: var(--base-size-8, 8px) !important; padding: 0px; position: relative; text-wrap: nowrap; transition: color 80ms cubic-bezier(0.33, 1, 0.68, 1) 0s, background-color 0s ease 0s, box-shadow 0s ease 0s, border-color 0s ease 0s; user-select: none; vertical-align: middle; width: var(--control-small-size, 28px);" tabindex="0" value="rabbitmqctl status"><svg aria-hidden="true" class="octicon octicon-copy js-clipboard-copy-icon" data-view-component="true" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg></clipboard-copy></div></div><p dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; margin-bottom: 16px; margin-top: 0px;">You can secure your RabbitMQ instance by creating a new user with limited permissions and removing the default guest user:</p><div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" style="box-sizing: border-box; color: #24292f; display: flex; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; justify-content: space-between; margin-bottom: 16px; overflow: auto; position: relative;"><pre style="border-radius: 6px; box-sizing: border-box; color: var(--fgColor-default, var(--color-fg-default)); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; line-height: 1.45; margin-bottom: 0px; margin-top: 0px; min-height: 52px; overflow-wrap: normal; overflow: auto; padding: 16px; word-break: normal;">rabbitmqctl add_user myuser mypassword
rabbitmqctl set_permissions myuser <span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-pds" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span>.*<span class="pl-pds" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span> <span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-pds" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span>.*<span class="pl-pds" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span> <span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-pds" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span>.*<span class="pl-pds" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span>
rabbitmqctl delete_user guest</pre><div class="zeroclipboard-container" style="animation: auto ease 0s 1 normal none running none; box-sizing: border-box;"><clipboard-copy aria-label="Copy" class="ClipboardButton btn btn-invisible js-clipboard-copy m-2 p-0 tooltipped-no-delay d-flex flex-justify-center flex-items-center" data-copy-feedback="Copied!" data-tooltip-direction="w" role="button" style="align-items: center; appearance: none; border-radius: 6px; border: 0px; box-shadow: none; box-sizing: border-box; color: var(--fgColor-accent, var(--color-accent-fg)); cursor: pointer; display: flex; font-weight: var(--base-text-weight-medium, 500); height: var(--control-small-size, 28px); justify-content: center; line-height: 20px; margin: var(--base-size-8, 8px) !important; padding: 0px; position: relative; text-wrap: nowrap; transition: color 80ms cubic-bezier(0.33, 1, 0.68, 1) 0s, background-color 0s ease 0s, box-shadow 0s ease 0s, border-color 0s ease 0s; user-select: none; vertical-align: middle; width: var(--control-small-size, 28px);" tabindex="0" value="rabbitmqctl add_user myuser mypassword
rabbitmqctl set_permissions myuser ".*" ".*" ".*"
rabbitmqctl delete_user guest"><svg aria-hidden="true" class="octicon octicon-copy js-clipboard-copy-icon" data-view-component="true" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg></clipboard-copy></div></div><div class="markdown-heading" dir="auto" style="box-sizing: border-box; position: relative;"><h2 class="heading-element" dir="auto" style="border-bottom: 1px solid var(--borderColor-muted, var(--color-border-muted)); box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-weight: var(--base-text-weight-semibold, 600); line-height: 1.25; margin-bottom: 16px; margin-top: 24px; padding-bottom: 0.3em;" tabindex="-1"><span style="font-size: small;">Accessing RabbitMQ </span></h2><h2 class="heading-element" dir="auto" style="border-bottom: 1px solid var(--borderColor-muted, var(--color-border-muted)); box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600); line-height: 1.25; margin-bottom: 16px; margin-top: 24px; padding-bottom: 0.3em;" tabindex="-1"><span style="font-size: small;"><div class="markdown-heading" dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-weight: 400; position: relative;"><a aria-label="Permalink: Working with RabbitMQ in .NET" class="anchor-element" href="https://github.com/niranjankala/niranjankala.github.io/blob/master/_posts/2024-03-01-leveraging-rabbitmq-with-c-and-net-a-comprehensive-guide.md#working-with-rabbitmq-in-net" id="user-content-working-with-rabbitmq-in-net" style="align-items: center; border-radius: 6px; box-sizing: border-box; display: flex; height: 28px; justify-content: center; left: -28px; margin: auto; opacity: 0; position: absolute; text-underline-offset: 0.2rem; top: 16.6042px; transform: translateY(calc(-50% - 0.3rem)); width: 28px;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;"><span style="color: #24292f; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><span style="font-weight: 400;">RabbitMQ Enable Web Management Plugin</span></span></p><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;"><span style="color: #24292f; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><span style="font-weight: 400;">To enable a RabbitMQ web management plugin on Windows, we need to start the RabbitMQ Command Prompt with administrator privileges, enter the command “rabbitmq-plugins enable rabbitmq_management,” and execute it.</span></span></p><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;"><span style="color: #24292f; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"></span></p><div class="separator" style="clear: both; text-align: center;"><span style="color: #24292f; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4BAmInL1IZvDC-cL15b1WJ8RQku2YSBg-5wyuwO8rkeoliNJuGp6rP-ZQkgBuWjOQfrjHRlEl35P7d67VQ5gpVXw1JAfiRF788J_lkesSUUStLmspUyKwVZos2ooEx0yIzjRQEbwGkpWaNBUTTkYU_TD1zstB7Q3KyNwUNi-rNAwHSigOYcOIH6U6Xtnc/s1212/RabbitMQ%20Command%20Prompt.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1212" data-original-width="1210" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4BAmInL1IZvDC-cL15b1WJ8RQku2YSBg-5wyuwO8rkeoliNJuGp6rP-ZQkgBuWjOQfrjHRlEl35P7d67VQ5gpVXw1JAfiRF788J_lkesSUUStLmspUyKwVZos2ooEx0yIzjRQEbwGkpWaNBUTTkYU_TD1zstB7Q3KyNwUNi-rNAwHSigOYcOIH6U6Xtnc/w399-h400/RabbitMQ%20Command%20Prompt.png" width="399" /></a></span></div><span style="color: #24292f; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><br /></span><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;"><span style="color: #24292f; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><span style="font-weight: 400;"> </span></span><span style="color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-weight: 400;">After executing the above web management command, the web management plugins will be enabled, and the enabled list will be shown.</span></p><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;"><span style="color: #24292f; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"></span></p><div class="separator" style="clear: both; text-align: center;"><span style="color: #24292f; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5FXGbyCQFJGK5GVzT97BSR9X8_1_C31BNdHB4XDg_JhdBQ92S2yW_c6UT3TzOngtI5AMV0adL2nLwoNFW_ftQ34d6NkP8Xi66AjgL_ISb_bZA2zBxbCGqzgIlU1MZ0mIRLUDl-EtdBtHIG6r-N89u7iWReE-5AuBWFPNUBuZu1Wf5nazT4MkHN7A3m9Xp/s1350/RabbitMQ_Enable_Management_Plugins.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="766" data-original-width="1350" height="365" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5FXGbyCQFJGK5GVzT97BSR9X8_1_C31BNdHB4XDg_JhdBQ92S2yW_c6UT3TzOngtI5AMV0adL2nLwoNFW_ftQ34d6NkP8Xi66AjgL_ISb_bZA2zBxbCGqzgIlU1MZ0mIRLUDl-EtdBtHIG6r-N89u7iWReE-5AuBWFPNUBuZu1Wf5nazT4MkHN7A3m9Xp/w640-h365/RabbitMQ_Enable_Management_Plugins.png" width="640" /></a></span></div><p></p><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;"><span style="color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-weight: 400;">After starting the RabbitMQ Web Management Plugin, enter the following URL in your browser and click 'enter' to open the web management plugin.</span></p><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;"><span style="color: #24292f; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><span style="font-weight: 400;">http://localhost:15672</span></span></p><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;"><span style="color: #24292f; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><span style="font-weight: 400;">After opening the localhost URL in the browser, it will ask you for credentials to access the web management plugin.</span></span></p><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 0px;"><span style="color: #24292f; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><span style="font-weight: 400;">To access the RabbitMQ web management dashboard, use the default username and password “guest” (Username: “guest” | Password: “guest”).</span><br /><br /></span></p><div class="separator" style="clear: both; text-align: center;"><span style="color: #24292f; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiI5VbfwH048HS6_OXQvpC6cjfhuJ-8fOCgLHlGiaT-Zy93fFQabZ9PDD8KtjX-KttBRVJgWfpUVZTrx912yjF6jOXyk3KX1WdG8QVd0tukmcP9GL8goLhRuq7BbNS3KEFWhrdYcA6L6omrrtQiNPRvpzIATZ4xT0QGTbTbxy2B7XCVeltQMhmsyHrGA3Ds/s1423/RabbitMQ_Web_Management_Login.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="709" data-original-width="1423" height="318" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiI5VbfwH048HS6_OXQvpC6cjfhuJ-8fOCgLHlGiaT-Zy93fFQabZ9PDD8KtjX-KttBRVJgWfpUVZTrx912yjF6jOXyk3KX1WdG8QVd0tukmcP9GL8goLhRuq7BbNS3KEFWhrdYcA6L6omrrtQiNPRvpzIATZ4xT0QGTbTbxy2B7XCVeltQMhmsyHrGA3Ds/w640-h318/RabbitMQ_Web_Management_Login.png" width="640" /></a><br /><br /></span></div><br style="color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";" /><span style="color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-weight: 400;">After logging in with the default credentials, you will see an overview screen.<br /><br /></span><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyWYZVWMIQhdtKZY2YZ9WcKLI8tsCDxeLNZ7ywlgZsTAE_qWIbdvYRR0Lefv7NPI3e1gL5_oFPBanPpU_EwP3D0rjsiHRJK7LZSkgYmAX7h0856NkyGPN__KnKGHasCWCVvgtdvnwgSYdaOfz3jGE0xOsHu3O590Kxv7CJ-OXjG7yF0iuG0GO_skAcKkQ1/s2101/RabbitMQ_Web_Management_Dashboard.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1414" data-original-width="2101" height="430" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyWYZVWMIQhdtKZY2YZ9WcKLI8tsCDxeLNZ7ywlgZsTAE_qWIbdvYRR0Lefv7NPI3e1gL5_oFPBanPpU_EwP3D0rjsiHRJK7LZSkgYmAX7h0856NkyGPN__KnKGHasCWCVvgtdvnwgSYdaOfz3jGE0xOsHu3O590Kxv7CJ-OXjG7yF0iuG0GO_skAcKkQ1/w640-h430/RabbitMQ_Web_Management_Dashboard.png" width="640" /></a></div><br /><p></p></span></h2><h2 class="heading-element" dir="auto" style="border-bottom: 1px solid var(--borderColor-muted, var(--color-border-muted)); box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-weight: var(--base-text-weight-semibold, 600); line-height: 1.25; margin-bottom: 16px; margin-top: 24px; padding-bottom: 0.3em;" tabindex="-1"><span style="font-size: small;">Working with RabbitMQ in .NET</span></h2><a aria-label="Permalink: Working with RabbitMQ in .NET" class="anchor-element" href="https://github.com/niranjankala/niranjankala.github.io/blob/master/_posts/2024-03-01-leveraging-rabbitmq-with-c-and-net-a-comprehensive-guide.md#working-with-rabbitmq-in-net" id="user-content-working-with-rabbitmq-in-net" style="align-items: center; border-radius: 6px; box-sizing: border-box; color: #24292f; display: flex; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; height: 28px; justify-content: center; left: -28px; margin: auto; opacity: 0; position: absolute; text-underline-offset: 0.2rem; top: 16.6042px; transform: translateY(calc(-50% - 0.3rem)); width: 28px;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div><p dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; margin-bottom: 16px; margin-top: 0px;">Let's integrate RabbitMQ with our .NET applications using the RabbitMQ .NET client library and C#.</p><div class="markdown-heading" dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; position: relative;"><h3 class="heading-element" dir="auto" style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600); line-height: 1.25; margin-bottom: 16px; margin-top: 24px;" tabindex="-1"><span style="font-size: small;">Setting up RabbitMQ Connection</span></h3><a aria-label="Permalink: Setting up RabbitMQ Connection" class="anchor-element" href="https://github.com/niranjankala/niranjankala.github.io/blob/master/_posts/2024-03-01-leveraging-rabbitmq-with-c-and-net-a-comprehensive-guide.md#setting-up-rabbitmq-connection" id="user-content-setting-up-rabbitmq-connection" style="align-items: center; border-radius: 6px; box-sizing: border-box; display: flex; height: 28px; justify-content: center; left: -28px; margin: auto; opacity: 0; position: absolute; text-underline-offset: 0.2rem; top: 10.9375px; transform: translateY(-50%); width: 28px;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div><p dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; margin-bottom: 16px; margin-top: 0px;">To establish a connection to RabbitMQ from a .NET application, we'll need to configure a connection factory:</p><div class="highlight highlight-source-cs notranslate position-relative overflow-auto" dir="auto" style="box-sizing: border-box; color: #24292f; display: flex; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; justify-content: space-between; margin-bottom: 16px; overflow: auto; position: relative;"><pre style="border-radius: 6px; box-sizing: border-box; color: var(--fgColor-default, var(--color-fg-default)); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; line-height: 1.45; margin-bottom: 0px; margin-top: 0px; min-height: 52px; overflow-wrap: normal; overflow: auto; padding: 16px; word-break: normal;"><span class="pl-smi" color="var(--color-prettylights-syntax-storage-modifier-import)" style="box-sizing: border-box;">var</span> <span class="pl-s1" style="box-sizing: border-box;">connectionFactory</span> <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">=</span> <span class="pl-k" color="var(--color-prettylights-syntax-keyword)" style="box-sizing: border-box;">new</span> ConnectionFactory
<span class="pl-kos" style="box-sizing: border-box;">{</span>
<span class="pl-s1" style="box-sizing: border-box;">HostName</span> <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">=</span> <span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span>localhost<span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span><span class="pl-kos" style="box-sizing: border-box;">,</span>
<span class="pl-s1" style="box-sizing: border-box;">UserName</span> <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">=</span> <span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span>myuser<span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span><span class="pl-kos" style="box-sizing: border-box;">,</span>
<span class="pl-s1" style="box-sizing: border-box;">Password</span> <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">=</span> <span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span>mypassword<span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span>
<span class="pl-kos" style="box-sizing: border-box;">}</span><span class="pl-kos" style="box-sizing: border-box;">;</span>
<span class="pl-k" color="var(--color-prettylights-syntax-keyword)" style="box-sizing: border-box;">using</span> <span class="pl-kos" style="box-sizing: border-box;">(</span><span class="pl-smi" color="var(--color-prettylights-syntax-storage-modifier-import)" style="box-sizing: border-box;">var</span> <span class="pl-s1" style="box-sizing: border-box;">connection</span> <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">=</span> connectionFactory<span class="pl-kos" style="box-sizing: border-box;">.</span><span class="pl-en" color="var(--color-prettylights-syntax-entity)" style="box-sizing: border-box;">CreateConnection</span><span class="pl-kos" style="box-sizing: border-box;">(</span><span class="pl-kos" style="box-sizing: border-box;">)</span><span class="pl-kos" style="box-sizing: border-box;">)</span>
<span class="pl-kos" style="box-sizing: border-box;">{</span>
<span class="pl-c" color="var(--color-prettylights-syntax-comment)" style="box-sizing: border-box;">// Create and configure channel</span>
<span class="pl-kos" style="box-sizing: border-box;">}</span></pre><div class="zeroclipboard-container" style="animation: auto ease 0s 1 normal none running none; box-sizing: border-box;"><clipboard-copy aria-label="Copy" class="ClipboardButton btn btn-invisible js-clipboard-copy m-2 p-0 tooltipped-no-delay d-flex flex-justify-center flex-items-center" data-copy-feedback="Copied!" data-tooltip-direction="w" role="button" style="align-items: center; appearance: none; border-radius: 6px; border: 0px; box-shadow: none; box-sizing: border-box; color: var(--fgColor-accent, var(--color-accent-fg)); cursor: pointer; display: flex; font-weight: var(--base-text-weight-medium, 500); height: var(--control-small-size, 28px); justify-content: center; line-height: 20px; margin: var(--base-size-8, 8px) !important; padding: 0px; position: relative; text-wrap: nowrap; transition: color 80ms cubic-bezier(0.33, 1, 0.68, 1) 0s, background-color 0s ease 0s, box-shadow 0s ease 0s, border-color 0s ease 0s; user-select: none; vertical-align: middle; width: var(--control-small-size, 28px);" tabindex="0" value="var connectionFactory = new ConnectionFactory
{
HostName = "localhost",
UserName = "myuser",
Password = "mypassword"
};
using (var connection = connectionFactory.CreateConnection())
{
// Create and configure channel
}"><svg aria-hidden="true" class="octicon octicon-copy js-clipboard-copy-icon" data-view-component="true" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg></clipboard-copy></div></div><div class="markdown-heading" dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; position: relative;"><h3 class="heading-element" dir="auto" style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600); line-height: 1.25; margin-bottom: 16px; margin-top: 24px;" tabindex="-1"><span style="font-size: small;">Working with Exchanges and Queues</span></h3><a aria-label="Permalink: Working with Exchanges and Queues" class="anchor-element" href="https://github.com/niranjankala/niranjankala.github.io/blob/master/_posts/2024-03-01-leveraging-rabbitmq-with-c-and-net-a-comprehensive-guide.md#working-with-exchanges-and-queues" id="user-content-working-with-exchanges-and-queues" style="align-items: center; border-radius: 6px; box-sizing: border-box; display: flex; height: 28px; justify-content: center; left: -28px; margin: auto; opacity: 0; position: absolute; text-underline-offset: 0.2rem; top: 10.9375px; transform: translateY(-50%); width: 28px;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div><p dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; margin-bottom: 16px; margin-top: 0px;">RabbitMQ uses exchanges and queues to route messages between producers and consumers. Let's create an exchange and a queue and bind them together:</p><div class="highlight highlight-source-cs notranslate position-relative overflow-auto" dir="auto" style="box-sizing: border-box; color: #24292f; display: flex; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; justify-content: space-between; margin-bottom: 16px; overflow: auto; position: relative;"><pre style="border-radius: 6px; box-sizing: border-box; color: var(--fgColor-default, var(--color-fg-default)); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; line-height: 1.45; margin-bottom: 0px; margin-top: 0px; min-height: 52px; overflow-wrap: normal; overflow: auto; padding: 16px; word-break: normal;"><span class="pl-k" color="var(--color-prettylights-syntax-keyword)" style="box-sizing: border-box;">using</span> <span class="pl-kos" style="box-sizing: border-box;">(</span><span class="pl-smi" color="var(--color-prettylights-syntax-storage-modifier-import)" style="box-sizing: border-box;">var</span> <span class="pl-s1" style="box-sizing: border-box;">model</span> <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">=</span> connection<span class="pl-kos" style="box-sizing: border-box;">.</span><span class="pl-en" color="var(--color-prettylights-syntax-entity)" style="box-sizing: border-box;">CreateModel</span><span class="pl-kos" style="box-sizing: border-box;">(</span><span class="pl-kos" style="box-sizing: border-box;">)</span><span class="pl-kos" style="box-sizing: border-box;">)</span>
<span class="pl-kos" style="box-sizing: border-box;">{</span>
<span class="pl-c" color="var(--color-prettylights-syntax-comment)" style="box-sizing: border-box;">// Declare exchange</span>
model<span class="pl-kos" style="box-sizing: border-box;">.</span><span class="pl-en" color="var(--color-prettylights-syntax-entity)" style="box-sizing: border-box;">ExchangeDeclare</span><span class="pl-kos" style="box-sizing: border-box;">(</span><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span>MyExchange<span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span><span class="pl-kos" style="box-sizing: border-box;">,</span> ExchangeType<span class="pl-kos" style="box-sizing: border-box;">.</span>Fanout<span class="pl-kos" style="box-sizing: border-box;">,</span> <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">true</span><span class="pl-kos" style="box-sizing: border-box;">)</span><span class="pl-kos" style="box-sizing: border-box;">;</span>
<span class="pl-c" color="var(--color-prettylights-syntax-comment)" style="box-sizing: border-box;">// Declare queue</span>
model<span class="pl-kos" style="box-sizing: border-box;">.</span><span class="pl-en" color="var(--color-prettylights-syntax-entity)" style="box-sizing: border-box;">QueueDeclare</span><span class="pl-kos" style="box-sizing: border-box;">(</span><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span>MyQueue<span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span><span class="pl-kos" style="box-sizing: border-box;">,</span> <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">true</span><span class="pl-kos" style="box-sizing: border-box;">)</span><span class="pl-kos" style="box-sizing: border-box;">;</span>
<span class="pl-c" color="var(--color-prettylights-syntax-comment)" style="box-sizing: border-box;">// Bind queue to exchange</span>
model<span class="pl-kos" style="box-sizing: border-box;">.</span><span class="pl-en" color="var(--color-prettylights-syntax-entity)" style="box-sizing: border-box;">QueueBind</span><span class="pl-kos" style="box-sizing: border-box;">(</span><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span>MyQueue<span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span><span class="pl-kos" style="box-sizing: border-box;">,</span> <span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span>MyExchange<span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span><span class="pl-kos" style="box-sizing: border-box;">,</span> <span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span><span class="pl-kos" style="box-sizing: border-box;">,</span> <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">false</span><span class="pl-kos" style="box-sizing: border-box;">,</span> <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">null</span><span class="pl-kos" style="box-sizing: border-box;">)</span><span class="pl-kos" style="box-sizing: border-box;">;</span>
<span class="pl-kos" style="box-sizing: border-box;">}</span></pre><div class="zeroclipboard-container" style="animation: auto ease 0s 1 normal none running none; box-sizing: border-box;"><clipboard-copy aria-label="Copy" class="ClipboardButton btn btn-invisible js-clipboard-copy m-2 p-0 tooltipped-no-delay d-flex flex-justify-center flex-items-center" data-copy-feedback="Copied!" data-tooltip-direction="w" role="button" style="align-items: center; appearance: none; border-radius: 6px; border: 0px; box-shadow: none; box-sizing: border-box; color: var(--fgColor-accent, var(--color-accent-fg)); cursor: pointer; display: flex; font-weight: var(--base-text-weight-medium, 500); height: var(--control-small-size, 28px); justify-content: center; line-height: 20px; margin: var(--base-size-8, 8px) !important; padding: 0px; position: relative; text-wrap: nowrap; transition: color 80ms cubic-bezier(0.33, 1, 0.68, 1) 0s, background-color 0s ease 0s, box-shadow 0s ease 0s, border-color 0s ease 0s; user-select: none; vertical-align: middle; width: var(--control-small-size, 28px);" tabindex="0" value="using (var model = connection.CreateModel())
{
// Declare exchange
model.ExchangeDeclare("MyExchange", ExchangeType.Fanout, true);
// Declare queue
model.QueueDeclare("MyQueue", true);
// Bind queue to exchange
model.QueueBind("MyQueue", "MyExchange", "", false, null);
}"><svg aria-hidden="true" class="octicon octicon-copy js-clipboard-copy-icon" data-view-component="true" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg></clipboard-copy></div></div><div class="markdown-heading" dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; position: relative;"><h3 class="heading-element" dir="auto" style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600); line-height: 1.25; margin-bottom: 16px; margin-top: 24px;" tabindex="-1"><span style="font-size: small;">Publishing and Consuming Messages</span></h3><a aria-label="Permalink: Publishing and Consuming Messages" class="anchor-element" href="https://github.com/niranjankala/niranjankala.github.io/blob/master/_posts/2024-03-01-leveraging-rabbitmq-with-c-and-net-a-comprehensive-guide.md#publishing-and-consuming-messages" id="user-content-publishing-and-consuming-messages" style="align-items: center; border-radius: 6px; box-sizing: border-box; display: flex; height: 28px; justify-content: center; left: -28px; margin: auto; opacity: 0; position: absolute; text-underline-offset: 0.2rem; top: 10.9375px; transform: translateY(-50%); width: 28px;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div><p dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; margin-bottom: 16px; margin-top: 0px;">Now that we have our exchange and queue set up, let's publish a message to the exchange and consume it from the queue:</p><div class="highlight highlight-source-cs notranslate position-relative overflow-auto" dir="auto" style="box-sizing: border-box; color: #24292f; display: flex; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; justify-content: space-between; margin-bottom: 16px; overflow: auto; position: relative;"><pre style="border-radius: 6px; box-sizing: border-box; color: var(--fgColor-default, var(--color-fg-default)); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; line-height: 1.45; margin-bottom: 0px; margin-top: 0px; min-height: 52px; overflow-wrap: normal; overflow: auto; padding: 16px; word-break: normal;"><span class="pl-c" color="var(--color-prettylights-syntax-comment)" style="box-sizing: border-box;">// Publish message</span>
<span class="pl-smi" color="var(--color-prettylights-syntax-storage-modifier-import)" style="box-sizing: border-box;">string</span> <span class="pl-s1" style="box-sizing: border-box;">message</span> <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">=</span> <span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span>Hello, RabbitMQ!<span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span><span class="pl-kos" style="box-sizing: border-box;">;</span>
<span class="pl-smi" color="var(--color-prettylights-syntax-storage-modifier-import)" style="box-sizing: border-box;">var</span> <span class="pl-s1" style="box-sizing: border-box;">body</span> <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">=</span> Encoding<span class="pl-kos" style="box-sizing: border-box;">.</span>UTF8<span class="pl-kos" style="box-sizing: border-box;">.</span><span class="pl-en" color="var(--color-prettylights-syntax-entity)" style="box-sizing: border-box;">GetBytes</span><span class="pl-kos" style="box-sizing: border-box;">(</span>message<span class="pl-kos" style="box-sizing: border-box;">)</span><span class="pl-kos" style="box-sizing: border-box;">;</span>
model<span class="pl-kos" style="box-sizing: border-box;">.</span><span class="pl-en" color="var(--color-prettylights-syntax-entity)" style="box-sizing: border-box;">BasicPublish</span><span class="pl-kos" style="box-sizing: border-box;">(</span><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span>MyExchange<span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span><span class="pl-kos" style="box-sizing: border-box;">,</span> <span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span><span class="pl-kos" style="box-sizing: border-box;">,</span> <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">null</span><span class="pl-kos" style="box-sizing: border-box;">,</span> body<span class="pl-kos" style="box-sizing: border-box;">)</span><span class="pl-kos" style="box-sizing: border-box;">;</span>
<span class="pl-c" color="var(--color-prettylights-syntax-comment)" style="box-sizing: border-box;">// Consume message</span>
<span class="pl-smi" color="var(--color-prettylights-syntax-storage-modifier-import)" style="box-sizing: border-box;">var</span> <span class="pl-s1" style="box-sizing: border-box;">consumer</span> <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">=</span> <span class="pl-k" color="var(--color-prettylights-syntax-keyword)" style="box-sizing: border-box;">new</span> EventingBasicConsumer<span class="pl-kos" style="box-sizing: border-box;">(</span>model<span class="pl-kos" style="box-sizing: border-box;">)</span><span class="pl-kos" style="box-sizing: border-box;">;</span>
consumer<span class="pl-kos" style="box-sizing: border-box;">.</span>Received <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">+=</span> <span class="pl-s1" style="box-sizing: border-box;"><span class="pl-kos" style="box-sizing: border-box;">(</span><span class="pl-s1" style="box-sizing: border-box;">sender</span><span class="pl-kos" style="box-sizing: border-box;">,</span> <span class="pl-s1" style="box-sizing: border-box;">args</span><span class="pl-kos" style="box-sizing: border-box;">)</span> <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">=></span></span>
<span class="pl-s1" style="box-sizing: border-box;">{</span>
<span class="pl-s1" style="box-sizing: border-box;"> <span class="pl-smi" color="var(--color-prettylights-syntax-storage-modifier-import)" style="box-sizing: border-box;">var</span> <span class="pl-s1" style="box-sizing: border-box;">messageBody</span> <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">=</span> Encoding<span class="pl-kos" style="box-sizing: border-box;">.</span>UTF8<span class="pl-kos" style="box-sizing: border-box;">.</span><span class="pl-en" color="var(--color-prettylights-syntax-entity)" style="box-sizing: border-box;">GetString</span><span class="pl-kos" style="box-sizing: border-box;">(</span>args<span class="pl-kos" style="box-sizing: border-box;">.</span>Body<span class="pl-kos" style="box-sizing: border-box;">.</span><span class="pl-en" color="var(--color-prettylights-syntax-entity)" style="box-sizing: border-box;">ToArray</span><span class="pl-kos" style="box-sizing: border-box;">(</span><span class="pl-kos" style="box-sizing: border-box;">)</span><span class="pl-kos" style="box-sizing: border-box;">)</span><span class="pl-kos" style="box-sizing: border-box;">;</span></span>
<span class="pl-s1" style="box-sizing: border-box;"> Console<span class="pl-kos" style="box-sizing: border-box;">.</span><span class="pl-en" color="var(--color-prettylights-syntax-entity)" style="box-sizing: border-box;">WriteLine</span><span class="pl-kos" style="box-sizing: border-box;">(</span><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">$"</span><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">Received message: </span><span class="pl-kos" style="box-sizing: border-box;">{</span>messageBody<span class="pl-kos" style="box-sizing: border-box;">}</span><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span><span class="pl-kos" style="box-sizing: border-box;">)</span><span class="pl-kos" style="box-sizing: border-box;">;</span></span>
<span class="pl-s1" style="box-sizing: border-box;">}</span><span class="pl-kos" style="box-sizing: border-box;">;</span>
model<span class="pl-kos" style="box-sizing: border-box;">.</span><span class="pl-en" color="var(--color-prettylights-syntax-entity)" style="box-sizing: border-box;">BasicConsume</span><span class="pl-kos" style="box-sizing: border-box;">(</span><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span>MyQueue<span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span><span class="pl-kos" style="box-sizing: border-box;">,</span> <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">true</span><span class="pl-kos" style="box-sizing: border-box;">,</span> consumer<span class="pl-kos" style="box-sizing: border-box;">)</span><span class="pl-kos" style="box-sizing: border-box;">;</span></pre><div class="zeroclipboard-container" style="animation: auto ease 0s 1 normal none running none; box-sizing: border-box;"><clipboard-copy aria-label="Copy" class="ClipboardButton btn btn-invisible js-clipboard-copy m-2 p-0 tooltipped-no-delay d-flex flex-justify-center flex-items-center" data-copy-feedback="Copied!" data-tooltip-direction="w" role="button" style="align-items: center; appearance: none; border-radius: 6px; border: 0px; box-shadow: none; box-sizing: border-box; color: var(--fgColor-accent, var(--color-accent-fg)); cursor: pointer; display: flex; font-weight: var(--base-text-weight-medium, 500); height: var(--control-small-size, 28px); justify-content: center; line-height: 20px; margin: var(--base-size-8, 8px) !important; padding: 0px; position: relative; text-wrap: nowrap; transition: color 80ms cubic-bezier(0.33, 1, 0.68, 1) 0s, background-color 0s ease 0s, box-shadow 0s ease 0s, border-color 0s ease 0s; user-select: none; vertical-align: middle; width: var(--control-small-size, 28px);" tabindex="0" value="// Publish message
string message = "Hello, RabbitMQ!";
var body = Encoding.UTF8.GetBytes(message);
model.BasicPublish("MyExchange", "", null, body);
// Consume message
var consumer = new EventingBasicConsumer(model);
consumer.Received += (sender, args) =>
{
var messageBody = Encoding.UTF8.GetString(args.Body.ToArray());
Console.WriteLine($"Received message: {messageBody}");
};
model.BasicConsume("MyQueue", true, consumer);"><svg aria-hidden="true" class="octicon octicon-copy js-clipboard-copy-icon" data-view-component="true" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg></clipboard-copy></div></div><div class="markdown-heading" dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; position: relative;"><h2 class="heading-element" dir="auto" style="border-bottom: 1px solid var(--borderColor-muted, var(--color-border-muted)); box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600); line-height: 1.25; margin-bottom: 16px; margin-top: 24px; padding-bottom: 0.3em;" tabindex="-1"><span style="font-size: small;">Performance Considerations</span></h2><a aria-label="Permalink: Performance Considerations" class="anchor-element" href="https://github.com/niranjankala/niranjankala.github.io/blob/master/_posts/2024-03-01-leveraging-rabbitmq-with-c-and-net-a-comprehensive-guide.md#performance-considerations" id="user-content-performance-considerations" style="align-items: center; border-radius: 6px; box-sizing: border-box; display: flex; height: 28px; justify-content: center; left: -28px; margin: auto; opacity: 0; position: absolute; text-underline-offset: 0.2rem; top: 16.6042px; transform: translateY(calc(-50% - 0.3rem)); width: 28px;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div><p dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; margin-bottom: 16px; margin-top: 0px;">RabbitMQ offers impressive performance, even under heavy loads. By optimizing message delivery and consumption, you can achieve high throughput and low latency. You can experiment with different configurations and message persistence options to find the best setup for your use case.</p><div class="markdown-heading" dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; position: relative;"><h2 class="heading-element" dir="auto" style="border-bottom: 1px solid var(--borderColor-muted, var(--color-border-muted)); box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600); line-height: 1.25; margin-bottom: 16px; margin-top: 24px; padding-bottom: 0.3em;" tabindex="-1"><span style="font-size: small;">Conclusion</span></h2><a aria-label="Permalink: Conclusion" class="anchor-element" href="https://github.com/niranjankala/niranjankala.github.io/blob/master/_posts/2024-03-01-leveraging-rabbitmq-with-c-and-net-a-comprehensive-guide.md#conclusion" id="user-content-conclusion" style="align-items: center; border-radius: 6px; box-sizing: border-box; display: flex; height: 28px; justify-content: center; left: -28px; margin: auto; opacity: 0; position: absolute; text-underline-offset: 0.2rem; top: 16.6042px; transform: translateY(calc(-50% - 0.3rem)); width: 28px;"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg></a></div><p></p><p dir="auto" style="box-sizing: border-box; color: #24292f; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; margin-bottom: 0px; margin-top: 0px;">In this guide, we've explored the fundamentals of RabbitMQ and demonstrated how to integrate it with C# and .NET applications. By leveraging RabbitMQ's powerful features, you can build robust and scalable messaging systems that meet the needs of your application. You can experiment with different exchange types, message routing strategies, and deployment configurations to unlock the full potential of RabbitMQ in your projects.</p>Niranjan Singhhttp://www.blogger.com/profile/10098432252247322623noreply@blogger.com0tag:blogger.com,1999:blog-2999456122062603029.post-67098462922439763582024-02-12T22:55:00.000-08:002024-02-12T22:55:13.246-08:00Understanding Microservices: A Comprehensive Guide<p> <span style="background-color: white; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; font-weight: var(--base-text-weight-semibold, 600);">Introduction:</span></p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">In modern software development, Microservices architecture has emerged as a game-changer, offering unparalleled flexibility, scalability, and resilience. This comprehensive guide aims to thoroughly understand Microservices architecture, including its core concepts, advantages, and practical applications.</p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Introduction to Microservices</span></p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">Microservices architecture is a modern approach to designing and building software applications, emphasising modularity, scalability, and agility. In contrast to traditional monolithic architectures, where a single codebase and database power the entire application, Microservices decompose complex systems into more minor, independently deployable services, each responsible for a specific business capability or domain.</p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">By embracing Microservices architecture principles, organizations can build scalable, resilient, and agile systems that enable innovation, drive business growth, and deliver exceptional value to customers. However, to make informed decisions about adopting this architecture effectively, it's essential to understand the core concepts, advantages, and challenges associated with Microservices.</p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Advantages of Microservices</span></p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">Microservices architecture offers several compelling advantages over traditional monolithic architectures. Let's explore some of the key benefits:</p><ul dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px; padding-left: 2em;"><li style="box-sizing: border-box;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Scalability and Agility:</span> One of the primary advantages of Microservices is the ability to scale individual components independently based on demand. With a monolithic architecture, scaling often involves scaling the entire application, regardless of which specific components require additional resources. In contrast, Microservices allow organizations to scale only the services experiencing increased load, resulting in more efficient resource utilization and improved responsiveness to changes in demand. Additionally, Microservices enable greater agility by allowing teams to develop, deploy, and update services independently, reducing time-to-market and facilitating continuous delivery practices.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Modularity and Decoupling:</span> Microservices promote modularity by breaking down complex systems into smaller, loosely coupled services. Each Microservice encapsulates a specific business capability or domain, making it easier to understand, develop, and maintain. This decoupling enables teams to work on isolated services without impacting other parts of the system, fostering parallel development and reducing the risk of cascading failures. Furthermore, Microservices facilitate technology diversity, allowing teams to choose the most suitable programming languages, frameworks, and databases for each service based on its requirements.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Fault Isolation and Resilience:</span> In a Microservices architecture, failures in one service typically do not propagate to other services, thanks to isolation and fault containment mechanisms. If a service experiences a failure or becomes unresponsive, other services can continue to operate independently, ensuring that the entire system remains available and resilient. Additionally, Microservices enables organizations to implement fine-grained monitoring, health checks, and circuit-breaking patterns to detect and handle failures gracefully, minimizing the impact on end-users and improving overall system reliability.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Elasticity and Resource Efficiency:</span> Microservices facilitate dynamic resource allocation and elasticity, allowing organizations to optimize resource usage based on workload patterns and traffic fluctuations. Cloud-native technologies such as containerization and orchestration platforms (e.g., Kubernetes) enable automatic scaling of Microservices based on predefined metrics such as CPU utilization, memory consumption, or request throughput. This elasticity enables organizations to achieve cost savings, improve performance, and meet service-level objectives (SLOs) more effectively by dynamically provisioning and de-provisioning resources as needed.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Continuous Delivery and DevOps Practices:</span> Microservices architecture aligns well with modern software development practices such as continuous integration (CI) and continuous delivery (CD) and DevOps principles. By decoupling services and enabling independent deployment pipelines, Microservices empower teams to release new features, updates, and bug fixes rapidly and frequently without disrupting the entire system. This agility and flexibility enable organizations to respond quickly to customer feedback, iterate on product features, and stay ahead of competitors in today's fast-paced market.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Improved Fault Tolerance and Rollback:</span> With Microservices, organizations can implement robust fault-tolerance mechanisms such as redundancy, replication, and graceful degradation to handle failures gracefully. In the event of a service outage or degradation, load balancers and service meshes can reroute traffic to healthy instances or alternative services, ensuring uninterrupted service availability. Additionally, Microservices enable organizations to implement efficient rollback and versioning strategies, allowing them to revert to previous versions of services quickly and safely in case of issues or regressions.</p></li></ul><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">By leveraging these advantages, organizations can build scalable, resilient, and agile systems that enable innovation, drive business growth, and deliver exceptional customer value. However, it's essential to weigh these benefits against potential challenges and considerations to make informed decisions about effectively adopting Microservices architecture.</p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">When to Use Microservices</span></p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">Deciding when to adopt Microservices architecture is a critical decision that requires careful consideration of various factors. While Microservices offer numerous advantages, they may not be suitable for every project or organization. Here are some scenarios where Microservices are particularly beneficial:</p><ul dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px; padding-left: 2em;"><li style="box-sizing: border-box;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Complexity and Scalability:</span> Microservices are well-suited for large and complex applications that require scalability and agility. When dealing with monolithic architectures, scaling the entire application can be challenging and often leads to resource wastage. Microservices allow individual application components to be scaled independently based on demand, resulting in better resource utilization and improved performance.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Modularity and Maintainability:</span> Microservices promote modularity by breaking the application into smaller, self-contained services. Each service is responsible for a specific business function, making it easier to understand, develop, and maintain. This modular approach enables teams to work on different services simultaneously without affecting each other, leading to faster development cycles and easier troubleshooting.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Technology Diversity:</span> In organizations with diverse technology stacks and development teams, Microservices provide the flexibility to use the most appropriate tools and technologies for each service. Different services can be developed using different programming languages, frameworks, and databases, allowing teams to leverage their expertise and choose the best-fit solutions for their specific requirements.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Continuous Delivery and Deployment:</span> Microservices facilitate continuous delivery and deployment practices by enabling independent release cycles for each service. This allows organizations to deliver new features and updates to production quickly and frequently without impacting the entire application. Organizations can achieve faster time-to-market and respond more effectively to changing business needs by decoupling services and implementing robust deployment pipelines.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Resilience and Fault Isolation:</span> Microservices architecture promotes resilience and fault isolation by isolating failures within individual services. In monolithic architectures, a single bug or failure can bring down the entire application. With Microservices, failures are contained within the affected service, minimizing the impact on other parts of the system. Additionally, Microservices can be designed to implement fallback mechanisms and failover strategies to handle unexpected errors gracefully.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Cross-functional Teams:</span> Microservices encourage the formation of cross-functional teams organized around specific business capabilities or domains. Each team is responsible for developing, deploying, and maintaining one or more services, allowing them to take ownership of the entire software lifecycle. This decentralized approach fosters collaboration, innovation, and accountability, leading to higher-quality software and faster delivery times.</p></li></ul><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">When Not to Use Microservices</span></p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">While Microservices offer many benefits, they are not a one-size-fits-all solution and may not be suitable for every project or organization. Here are some scenarios where Microservices may not be the best choice:</p><ul dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px; padding-left: 2em;"><li style="box-sizing: border-box;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Small or Simple Applications:</span> For small or simple applications with limited functionality and low scalability requirements, the overhead of implementing Microservices architecture may outweigh the benefits. In such cases, a monolithic architecture may be more straightforward to develop, deploy, and maintain.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Limited Resources:</span> Microservices introduce additional complexity regarding infrastructure, deployment, and monitoring. If your organization has limited resources or expertise in managing distributed systems, adopting Microservices may be challenging and lead to operational overhead.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Tight Deadlines:</span> Transitioning from a monolithic architecture to Microservices requires careful planning, refactoring, and testing. If you have tight deadlines or need to deliver features quickly, the time and effort required to migrate to Microservices may delay project delivery and impact business goals.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Team Size and Expertise:</span> Microservices architecture requires cross-functional teams with expertise in different technologies and domains. If your organization lacks skilled developers or struggles to form autonomous teams, adopting Microservices may result in development bottlenecks and communication challenges.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Data Consistency and Transactions:</span> Microservices promote loose coupling and autonomy, making it challenging to maintain data consistency and manage transactions across multiple services. A monolithic architecture may be more suitable if your application relies heavily on complex transactions or requires strict data consistency guarantees.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Performance Overhead:</span> While microservices offer scalability and agility, they also introduce overhead communication and network latency between services. In applications with high-performance requirements or real-time processing needs, the additional latency introduced by Microservices may impact overall system performance.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Legacy Systems Integration:</span> If your organization relies on legacy systems or monolithic, tightly coupled applications, migrating to Microservices may require significant refactoring and integration efforts. In some cases, it may be more cost-effective to modernize existing systems gradually rather than adopting Microservices architecture.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Regulatory Compliance:</span> Certain industries, such as healthcare and finance, have strict regulatory requirements regarding data privacy, security, and compliance. Implementing Microservices in such environments may introduce additional complexity and compliance challenges, requiring careful consideration and adherence to industry standards.</p></li></ul><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbYzw1rFvKkeNcOVREneNbwuHORhFadAGjJsuy4ymfSZRHhrxGbRD8o1V0EXUPAbP7ISBFlI67eZQrBFWaIQgfYdIc57DnaMqkvYKZHAQ47Bql3lgQaDqjpA2C7xY1e2NmoSaj8Bpm5aoQokhGCxNxgYwrj8gbpUGctSS1kEtJAkkUGvB-jp7FZXCch5bK/s1162/Screenshot%202024-02-12%20115138.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="741" data-original-width="1162" height="408" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbYzw1rFvKkeNcOVREneNbwuHORhFadAGjJsuy4ymfSZRHhrxGbRD8o1V0EXUPAbP7ISBFlI67eZQrBFWaIQgfYdIc57DnaMqkvYKZHAQ47Bql3lgQaDqjpA2C7xY1e2NmoSaj8Bpm5aoQokhGCxNxgYwrj8gbpUGctSS1kEtJAkkUGvB-jp7FZXCch5bK/w640-h408/Screenshot%202024-02-12%20115138.png" width="640" /></a></div><br /><span style="color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><br /></span></div><div><span style="color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><br /></span></div><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Core Concepts in Microservices Architecture</span></p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">Microservices architecture is built upon several core concepts that define its structure, behaviour, and benefits. Understanding these concepts is essential for successfully designing and implementing Microservices-based systems. Let's delve deeper into these core concepts:</p><ul dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px; padding-left: 2em;"><li style="box-sizing: border-box;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Decomposition:</span> Decomposition breaks down a monolithic application into smaller, independent services. Each service focuses on a specific business capability or functionality, allowing for greater modularity and scalability. Decomposition enables teams to work autonomously on different services, leading to faster development cycles and easier maintenance.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Service Independence:</span> Microservices are designed to be independent and autonomous entities that can be developed, deployed, and scaled independently. Each service has its codebase, data storage, and runtime environment, minimizing service dependencies. Service independence allows teams to innovate and iterate quickly without affecting other parts of the system.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Service Communication:</span> Communication between Microservices is typically done via lightweight protocols such as HTTP or messaging queues. Services interact through well-defined APIs, enabling loose coupling and flexibility. However, managing communication between services introduces challenges such as network latency, reliability, and service discovery, which must be addressed.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Data Management:</span> In Microservices architecture, each service manages its data store optimized for specific requirements. Based on their data access patterns and performance needs, services may use different databases, such as SQL, NoSQL, or in-memory databases. Data consistency and synchronization between services can be achieved through event sourcing, eventual consistency, or distributed transactions.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Scalability:</span> Microservices architecture offers horizontal scalability, allowing individual services to scale independently based on demand. Services can be deployed on separate servers or containerized environments such as Docker and orchestrated using tools like Kubernetes. Horizontal scaling ensures that resources are allocated efficiently and enables systems to handle varying workloads effectively.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Fault Isolation:</span> Microservices promote fault isolation by encapsulating failure within individual services. A failure in one service does not propagate to other services, minimizing the impact on the overall system. Implementing fault tolerance mechanisms such as circuit breakers, retries, and timeouts further enhances system resilience and reliability.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Continuous Delivery:</span> Microservices architecture enables continuous delivery and deployment practices, facilitating rapid and frequent releases. Each service can be built, tested, and deployed independently using automated pipelines. Continuous integration and delivery pipelines ensure that changes are validated and deployed reliably, reducing the time to market for new features and updates.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Observability:</span> Observability is essential for monitoring, troubleshooting, and optimizing Microservices-based systems. Distributed tracing, logging, and metrics collection provide insights into service performance, health, and behaviour. Monitoring tools such as Prometheus, Grafana, and Jaeger help teams identify and resolve issues quickly, ensuring system reliability and performance.</p></li></ul><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Practical Applications of Microservices</span></p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">Microservices architecture has gained popularity across various industries due to its ability to address the challenges of building complex, scalable, and resilient systems. Let's explore some practical applications of Microservices in real-world scenarios:</p><ul dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px; padding-left: 2em;"><li style="box-sizing: border-box;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">E-commerce Platforms:</span> E-commerce platforms often consist of multiple interconnected services responsible for product catalogue management, order processing, payment processing, user authentication, and recommendation engines. Adopting a Microservices architecture allows e-commerce companies to scale individual components independently, handle high traffic loads during peak shopping seasons, and quickly introduce new features and services to stay competitive.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Financial Services:</span> In the financial services sector, Microservices are used to build trading platforms, banking applications, payment gateways, and risk management systems. Each Microservice can handle specific functions such as account management, transaction processing, fraud detection, and compliance reporting. Organizations can achieve better agility, scalability, and security while complying with regulatory requirements by decoupling complex financial systems into more minor, modular services.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Travel and Hospitality:</span> Travel and hospitality companies leverage Microservices to build reservation systems, booking engines, customer relationship management (CRM) platforms, and loyalty programs. Microservices enable these companies to integrate seamlessly with third-party services such as airline APIs, hotel booking systems, and car rental services. Additionally, Microservices architecture allows travel companies to personalize user experiences, optimize pricing strategies, and analyze customer data to offer tailored recommendations and promotions.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Healthcare and Telemedicine:</span> Healthcare organizations use Microservices to develop electronic health record (EHR) systems, patient portals, telemedicine platforms, and medical billing solutions. Microservices enable healthcare providers to manage patient data securely, integrate with medical devices and sensors, and facilitate remote consultations and diagnostics. By adopting Microservices architecture, healthcare organizations can improve patient outcomes, streamline administrative workflows, and comply with healthcare regulations such as HIPAA.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Media and Entertainment:</span> Media and entertainment companies leverage Microservices to build streaming platforms, content management systems, recommendation engines, and advertising platforms. Microservices architecture allows these companies to simultaneously deliver high-quality video and audio content to millions of users, scale streaming infrastructure based on demand, and analyze user behaviour to personalize content recommendations and advertisements.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Internet of Things (IoT):</span> IoT platforms utilize Microservices to connect, manage, and analyze data from sensors, devices, and actuators deployed in smart homes, smart cities, and industrial environments. Each Microservice handles specific IoT functions such as device provisioning, data ingestion, real-time analytics, and device management. By adopting Microservices architecture, IoT platforms can scale horizontally to support millions of connected devices, process large volumes of data efficiently, and implement security measures to protect sensitive information.</p></li></ul><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Challenges and Considerations</span></p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">While Microservices architecture offers numerous benefits, it also presents several challenges and considerations that organizations must address to implement and maintain Microservices-based systems successfully. Let's delve into some of the key challenges and concerns:</p><ul dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px; padding-left: 2em;"><li style="box-sizing: border-box;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Complexity Management:</span> As the number of Microservices grows within a system, managing the complexity of service interactions becomes increasingly challenging. Organizations must implement robust service discovery, communication, and orchestration mechanisms to ensure seamless integration and coordination between Microservices. Additionally, the proliferation of services can increase operational overhead in monitoring, debugging, and troubleshooting.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Service Boundaries and Ownership:</span> Defining clear service boundaries and ownership is essential for effective Microservices architecture. Organizations must carefully identify domain boundaries and business capabilities to avoid service sprawl and minimize dependencies between services. Each Microservice should have a well-defined scope, responsibilities, and ownership, enabling autonomous development, deployment, and maintenance by individual teams or micro-teams.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Data Management and Consistency:</span> Microservices architecture introduces challenges related to data management, consistency, and synchronization across distributed systems. Organizations must carefully design data storage strategies, considering factors such as data partitioning, replication, and eventual consistency. Implementing distributed transactional patterns, event sourcing, and CQRS (Command Query Responsibility Segregation) can help maintain data integrity and consistency in Microservices-based applications.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Operational Complexity:</span> Deploying and managing Microservices-based systems in production environments can be operationally complex. Organizations need robust DevOps practices, infrastructure automation, and container orchestration platforms (e.g., Kubernetes) to streamline Microservices' deployment, scaling, and monitoring. Additionally, implementing comprehensive observability solutions, including logging, monitoring, and tracing, is crucial for identifying performance bottlenecks, diagnosing failures, and ensuring system reliability.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Testing and Quality Assurance:</span> Traditional monolithic testing approaches may not be suitable for Microservices-based systems, where each service can evolve independently and have its own release cadence. Organizations need to adopt a culture of automated testing, including unit tests, integration tests, and end-to-end tests, to validate Microservices' functionality, compatibility, and resilience. Implementing contract testing and consumer-driven contract (CDC) testing can help ensure compatibility and consistency between Microservices interfaces.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Security and Compliance:</span> Microservices architecture introduces new security challenges, including service-to-service communication, authentication, authorization, and data protection. Organizations must implement robust security measures such as mutual TLS (Transport Layer Security), API gateways, role-based access control (RBAC), and encryption to safeguard sensitive data and prevent unauthorized access or data breaches. Additionally, ensuring compliance with industry regulations such as GDPR, HIPAA, and PCI-DSS is essential for protecting customer privacy and maintaining trust.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Organizational Alignment and Culture:</span> Adopting Microservices architecture often requires organizations to undergo cultural and organizational changes to embrace principles such as decentralization, autonomy, and continuous delivery. Establishing cross-functional teams, fostering collaboration between development and operations teams (DevOps), and promoting a culture of experimentation, innovation, and constant improvement is essential for successfully adopting microservices. Additionally, providing adequate training, support, and incentives for teams transitioning to Microservices can facilitate smoother adoption and alignment with organizational goals.</p></li></ul><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">By proactively addressing these challenges and considerations, organizations can harness the full potential of Microservices architecture to build scalable, resilient, and adaptable systems that drive innovation and deliver value to customers.</p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 0px !important; margin-top: 0px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);">Conclusion:</span><br style="box-sizing: border-box;" />Microservices architecture offers unparalleled scalability, flexibility, and resilience benefits. By embracing the core concepts and best practices outlined in this guide, organizations can unlock new opportunities for innovation and growth in the digital era. As you embark on your journey with Microservices, remember to prioritize simplicity, modularity, and maintainability in your architecture. Happy Microservices Building!</p>Niranjan Singhhttp://www.blogger.com/profile/10098432252247322623noreply@blogger.com0tag:blogger.com,1999:blog-2999456122062603029.post-22453221222760928772023-10-31T23:24:00.007-07:002024-01-04T22:59:33.830-08:00Exploring NDepend v2023.2: Unraveling the Latest Features<p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;"><strong style="box-sizing: border-box;">Introduction:</strong></p><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;">For .NET developers and software quality enthusiasts, NDepend is an indispensable tool. NDepend v2023.2 introduces an array of new features that promise to streamline your development process and enhance the quality of your code. In this comprehensive article, we’ll delve into the latest updates and enhancements.</p><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;"><strong style="box-sizing: border-box;">Full .NET 8.0 Support:</strong></p><ul style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin-bottom: 10.5px; margin-top: 0px; text-align: justify;"><li style="box-sizing: border-box;">With .NET 8.0’s release, NDepend ensures seamless compatibility.</li><li style="box-sizing: border-box;">Analyze .NET 8 code quickly, covering project types like ASP.NET Core, Windows Desktop, Blazor, and Console applications.</li><li style="box-sizing: border-box;">Your .NET 8.0 projects are now within NDepend’s scope for analysis.</li></ul><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;"><strong style="box-sizing: border-box;">C# 12 Support and Parsing Improvements:</strong></p><ul style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin-bottom: 10.5px; margin-top: 0px; text-align: justify;"><li style="box-sizing: border-box;">NDepend v2023.2 embraces the new features of C# 12, including primary constructors for classes and inline arrays.</li><li style="box-sizing: border-box;">Achieve 100% resolution of code element declarations in your source code, from fields and enumeration values to abstract methods and more.</li><li style="box-sizing: border-box;">Source declaration line enhancements clarify your code, making issue identification more straightforward.</li></ul><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;"><strong style="box-sizing: border-box;">Performance Enhancements:</strong></p><ul style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin-bottom: 10.5px; margin-top: 0px; text-align: justify;"><li style="box-sizing: border-box;">Say hello to a faster analysis process. NDepend v2023.2 reduces report generation time by a staggering 40%.</li><li style="box-sizing: border-box;">Even for extensive code bases with thousands of source files and millions of lines of code, report generation is now a matter of seconds.</li><li style="box-sizing: border-box;">NDependReport.html file sizes are halved thanks to new optimizations, ranging from one to 5MB. Sharing and usability have never been more convenient.</li></ul><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;"><strong style="box-sizing: border-box;">UI Enhancements:</strong></p><ul style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin-bottom: 10.5px; margin-top: 0px; text-align: justify;"><li style="box-sizing: border-box;">The user interface receives significant improvements.</li><li style="box-sizing: border-box;">Loading code base snapshots with the baseline snapshot is now parallelized, resulting in a 40% reduction in loading time.</li><li style="box-sizing: border-box;">Lazy initialization of panels makes the UI instantly responsive once snapshots are loaded.</li><li style="box-sizing: border-box;"><p style="box-sizing: border-box; margin: 0px 0px 10.5px;">In Project Properties, the “Code to Analyze” panel now resolves all assemblies 41% faster.</p><p style="box-sizing: border-box; margin: 0px 0px 10.5px;"><img alt="NDepend Dashboard" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhz6F0bhA-MIzXi50UcevrOA5Ls2pzrytVkvH63x19alTXV7-w1HAJq1RlRdoIabXjVryUmg7_LHHB6ECGIi-fQS_X7mYN72bZb4WQdgpQ116l2KQowz5BWi1UxQZeUIe2oYIawV9QpLUIuT04x56rIupNZcn-xjReiyvhYhl6BOVum5bJ68ZsPCE9uN5Q/w640-h340/NDepend_2023_HomeScreen.png" style="border: 0px; box-sizing: border-box; vertical-align: middle;" /><br style="box-sizing: border-box;" />Dashboard</p><p style="box-sizing: border-box; margin: 0px 0px 10.5px;"><img alt="NDepend Report Dashboard" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2Hb02isNllvZUX0oCC7Ijty94cYm6j8nKnG0kuhe0X4ZeXNfs3NgvbuKLG6WyC7OrnYPXzo2J7pyP2UpBcV3L3eaonMe6JuGANsjoQkAdjb00sRvODdDd7b3907KNaRchyAery0JXaqHrZgNKRPMH9j5LxgQ4-m3OigQqlXlRzmmFQInHjjodmVThaVk/w640-h358/NDepend_2023_Report_HomeScreen.png" style="border: 0px; box-sizing: border-box; vertical-align: middle;" /><br style="box-sizing: border-box;" />NDepend Report Dashboard</p><p style="box-sizing: border-box; margin: 0px 0px 10.5px;"><img alt="NDepend_2023_Report_Abstractness versus Instability Diagram" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgf5-r1Fzbd7xmAuaTXFpWOdG4gMXz1JOLadh2XtZVnh7HCYhZ3nN9n6JgL_86LRJCkWqljicvSV_CalDiAS81x-YVnvnPk9FUD-ThUQQdm33eyxcPYLuLoUaoS5bXkrPA8B1LjSOjFe4Sp3g7-CbpueXCWe5k2slQ_tU02cx6zE9_Rg2AGsWlYnA0wtcY/w640-h344/NDepend_2023_Report_Abstractness%20versus%20Instability%20Diagram.png" style="border: 0px; box-sizing: border-box; vertical-align: middle;" /><br style="box-sizing: border-box;" />NDepend Report - Abstractness versus Instability Diagram</p></li></ul><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;"><strong style="box-sizing: border-box;">Customizable Issue Explanations:</strong></p><ul style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin-bottom: 10.5px; margin-top: 0px; text-align: justify;"><li style="box-sizing: border-box;">NDepend v2023.2 empowers users to define patterns for issue explanations.</li><li style="box-sizing: border-box;">This customization enables tailored issue explanations to meet specific project needs, enhancing insights into the codebase.</li><li style="box-sizing: border-box;">Issue explanations are integrated into the NDepend UI and source code views in reports, providing an in-depth understanding. <img alt="NDepend_2023_Report_Issues Improvement" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFUJCxsJEnOXvHAcslzpYtmk4hII2qMlUFREu05AYzyGC1UyfgDGAYBhxD_BL5uLhqAAygTaBVP9rT-RRPMKOzLXBfnRJ89gAXhCvAgL1HuUuQAM0sc6P86FDOmLcCDXTf9WYJxXNhV-BqnmbcnSzIqKq56FK_T0hdUtrplcOtn7qg3DMI4MOCLZVQVKM/w640-h344/NDepend_2023_Report_IssuesScreen.png" style="border: 0px; box-sizing: border-box; vertical-align: middle;" /></li></ul><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;"><strong style="box-sizing: border-box;">Fewer False Positives:</strong></p><ul style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin-bottom: 10.5px; margin-top: 0px; text-align: justify;"><li style="box-sizing: border-box;">Reducing false positives remains a top priority for NDepend.</li><li style="box-sizing: border-box;">In this release, various rules have been refined to minimize false positive issues, allowing developers to focus on genuine code quality concerns.</li></ul><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;"><strong style="box-sizing: border-box;">Conclusion:</strong> NDepend v2023.2 emerges as a powerhouse tool for .NET developers. With complete .NET 8.0 support, compatibility with C# 12, and substantial performance enhancements, it becomes a valuable asset for your toolkit. The UI improvements and customizable issue explanations elevate the code analysis experience. Bid farewell to false positives and embrace an accurate analysis.</p><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;">In a world where software quality is non-negotiable, NDepend v2023.2 is the tool you need to ensure your .NET projects shine.</p><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;"><strong style="box-sizing: border-box;">Final Thoughts:</strong> NDepend v2023.2 continues its commitment to delivering an exceptional code analysis experience. Its ability to adapt to the latest .NET technologies and enhanced performance makes it a crucial tool for any .NET developer. Dive into NDepend v2023.2 and watch your codebase reach new heights of quality and maintainability.</p>Niranjanhttp://www.blogger.com/profile/09593008555732266996noreply@blogger.com0tag:blogger.com,1999:blog-2999456122062603029.post-39324150040425617332023-10-02T05:18:00.005-07:002024-01-03T22:20:32.274-08:00Securing .NET Web Applications with Authentication: Harnessing the Power of Social Media Provider Authentication<p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);"><b>Introduction:</b></span></p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">In today's interconnected world, users expect a seamless and secure login experience on websites and applications. Social media provider authentication, such as Google Authentication, offers a convenient and trusted way for users to access your application using their existing social media accounts. In this tutorial, we'll explore how to integrate Google Authentication into your ASP.NET Core application step by step.</p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);"><b>Prerequisites:</b></span></p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">Before we dive into the implementation, make sure you have the following:</p><ol dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px; padding-left: 2em;"><li style="box-sizing: border-box;">Visual Studio or Visual Studio Code installed on your system.</li><li style="box-sizing: border-box; margin-top: 0.25em;">An ASP.NET Core web application project was created.</li></ol><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);"><b>Step 1: Install the Required NuGet Package</b></span></p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">The first step is to install the <code style="background-color: var(--bgColor-neutral-muted, var(--color-neutral-muted)); border-radius: 6px; box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 13.6px; margin: 0px; padding: 0.2em 0.4em; white-space-collapse: break-spaces;">Microsoft.AspNetCore.Authentication.Google</code> NuGet package into your ASP.NET Core project. This package provides the necessary tools for integrating Google Authentication.</p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">Open the NuGet Package Manager in Visual Studio, search for <code style="background-color: var(--bgColor-neutral-muted, var(--color-neutral-muted)); border-radius: 6px; box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 13.6px; margin: 0px; padding: 0.2em 0.4em; white-space-collapse: break-spaces;">Microsoft.AspNetCore.Authentication.Google</code>, and install the latest stable version.</p><div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" style="box-sizing: border-box; color: #1f2328; display: flex; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; justify-content: space-between; margin-bottom: 16px; overflow: auto; position: relative;"><pre style="border-radius: 6px; box-sizing: border-box; color: var(--fgColor-default, var(--color-fg-default)); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 13.6px; line-height: 1.45; margin-bottom: 0px; margin-top: 0px; overflow-wrap: normal; overflow: auto; padding: 16px; word-break: normal;">Install-Package Microsoft.AspNetCore.Authentication.Google</pre><div class="zeroclipboard-container" style="animation: auto ease 0s 1 normal none running none; box-sizing: border-box;"><clipboard-copy aria-label="Copy" class="ClipboardButton btn btn-invisible js-clipboard-copy m-2 p-0 tooltipped-no-delay d-flex flex-justify-center flex-items-center" data-copy-feedback="Copied!" data-tooltip-direction="w" role="button" style="align-items: center; appearance: none; border-radius: 6px; border: 0px; box-shadow: none; box-sizing: border-box; color: var(--fgColor-accent, var(--color-accent-fg)); cursor: pointer; display: flex; font-size: 14px; font-weight: var(--base-text-weight-medium, 500); height: var(--control-small-size, 28px); justify-content: center; line-height: 20px; margin: var(--base-size-8, 8px) !important; padding: 0px; position: relative; text-wrap: nowrap; transition: color 80ms cubic-bezier(0.33, 1, 0.68, 1) 0s, background-color 0s ease 0s, box-shadow 0s ease 0s, border-color 0s ease 0s; user-select: none; vertical-align: middle; width: var(--control-small-size, 28px);" tabindex="0" value="Install-Package Microsoft.AspNetCore.Authentication.Google"><svg aria-hidden="true" class="octicon octicon-copy js-clipboard-copy-icon" data-view-component="true" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg></clipboard-copy></div></div><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);"><b>Step 2: Configure Google Authentication</b></span></p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">To enable Google Authentication in your application, you need to set up the necessary credentials on the Google Developer Console. Follow these steps:</p><ol dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px; padding-left: 2em;"><li style="box-sizing: border-box;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;">Navigate to the <a href="https://console.cloud.google.com/" rel="nofollow" style="background-color: transparent; box-sizing: border-box; text-decoration-line: none;">Google Developer Console</a>.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;">Create a new project or select an existing one.<br style="box-sizing: border-box;" /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFRePFefoVSUFjayRmlw3tPGdhhHGVsWMAMktQmyBjOZ1QJ5APfiBgjBFOh9sdxotgl5ba_iUydXT3Pf02kqGqelGedxNcHtpG-kCqJ6PRLEpbxcDlIz9iX-wb4OqiiLawMkwR1SdO3grIVTSWK9DPqYlF6GgsyBjYPaHgRiAedKwJhysAl_1eTX-5eaae/s640/Google-Auth-Projects_Screen.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="289" data-original-width="640" height="289" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFRePFefoVSUFjayRmlw3tPGdhhHGVsWMAMktQmyBjOZ1QJ5APfiBgjBFOh9sdxotgl5ba_iUydXT3Pf02kqGqelGedxNcHtpG-kCqJ6PRLEpbxcDlIz9iX-wb4OqiiLawMkwR1SdO3grIVTSWK9DPqYlF6GgsyBjYPaHgRiAedKwJhysAl_1eTX-5eaae/w640-h289/Google-Auth-Projects_Screen.png" width="640" /></a></div><br /><br /><p></p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;">Set up the consent screen by providing the required information, including the application name, support email, and domain.<br style="box-sizing: border-box;" /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4cusmTlIIwZZN9VgcLdx4y65VQg_h09CD7MnbLdKgyG_o3GW-MMT_FT_Ksmx-5NzctCGfE32NeqD_Zgo1XT1QSGortNaDtnQDxA3uWdyPihN4WD2atTpW_dAaA2bA4JubzpEra27MCY1qyucZvKz0VbzK1_2tYo72yrL058qAliFUKaUhyphenhyphenMF6VSZvWIiq/s640/Google-Auth-Create-OAuth-Client-ID.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="334" data-original-width="640" height="334" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4cusmTlIIwZZN9VgcLdx4y65VQg_h09CD7MnbLdKgyG_o3GW-MMT_FT_Ksmx-5NzctCGfE32NeqD_Zgo1XT1QSGortNaDtnQDxA3uWdyPihN4WD2atTpW_dAaA2bA4JubzpEra27MCY1qyucZvKz0VbzK1_2tYo72yrL058qAliFUKaUhyphenhyphenMF6VSZvWIiq/w640-h334/Google-Auth-Create-OAuth-Client-ID.png" width="640" /><br /><br /></a></div><br /><br style="box-sizing: border-box;" /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4cusmTlIIwZZN9VgcLdx4y65VQg_h09CD7MnbLdKgyG_o3GW-MMT_FT_Ksmx-5NzctCGfE32NeqD_Zgo1XT1QSGortNaDtnQDxA3uWdyPihN4WD2atTpW_dAaA2bA4JubzpEra27MCY1qyucZvKz0VbzK1_2tYo72yrL058qAliFUKaUhyphenhyphenMF6VSZvWIiq/s640/Google-Auth-Create-OAuth-Client-ID.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="334" data-original-width="640" height="334" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4cusmTlIIwZZN9VgcLdx4y65VQg_h09CD7MnbLdKgyG_o3GW-MMT_FT_Ksmx-5NzctCGfE32NeqD_Zgo1XT1QSGortNaDtnQDxA3uWdyPihN4WD2atTpW_dAaA2bA4JubzpEra27MCY1qyucZvKz0VbzK1_2tYo72yrL058qAliFUKaUhyphenhyphenMF6VSZvWIiq/w640-h334/Google-Auth-Create-OAuth-Client-ID.png" width="640" /></a></div><br /><br /><p></p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;">Add authorized JavaScript origins and redirect URIs for your application. Make sure to include both the development and production URLs.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;">Under the "Scopes" section, add the necessary scopes, such as <code style="background-color: var(--bgColor-neutral-muted, var(--color-neutral-muted)); border-radius: 6px; box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 13.6px; margin: 0px; padding: 0.2em 0.4em; white-space-collapse: break-spaces;">email</code>, <code style="background-color: var(--bgColor-neutral-muted, var(--color-neutral-muted)); border-radius: 6px; box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 13.6px; margin: 0px; padding: 0.2em 0.4em; white-space-collapse: break-spaces;">profile</code>, and <code style="background-color: var(--bgColor-neutral-muted, var(--color-neutral-muted)); border-radius: 6px; box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 13.6px; margin: 0px; padding: 0.2em 0.4em; white-space-collapse: break-spaces;">openid</code>.<br style="box-sizing: border-box;" /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJOB-a4M7iemmASkOkIBDvVZkGkwJQjqYxRK5nlt6DQVb3aE8MKBWhB-z89PV-M8m_QsV19lX5M-hBWlVorq1L8bolVI2kCWYntxWIEdEKiEqzJx0zDISCXmQ05e3txn-P8aDoRrMTVhMTNZD6MSQblb9D-5MsoCUnMUgEQXz0JuYs4fDwMtxDK6cTgkR8/s640/Google-Auth-Project-Consent-Screen-3.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="332" data-original-width="640" height="332" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJOB-a4M7iemmASkOkIBDvVZkGkwJQjqYxRK5nlt6DQVb3aE8MKBWhB-z89PV-M8m_QsV19lX5M-hBWlVorq1L8bolVI2kCWYntxWIEdEKiEqzJx0zDISCXmQ05e3txn-P8aDoRrMTVhMTNZD6MSQblb9D-5MsoCUnMUgEQXz0JuYs4fDwMtxDK6cTgkR8/w640-h332/Google-Auth-Project-Consent-Screen-3.png" width="640" /></a></div><br /><br /><p></p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;">Save your changes and publish the app.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;">Create OAuth 2.0 credentials by going to "Credentials" and selecting "Create credentials" > "OAuth client ID." Choose the application type as "Web application" and configure the redirect URIs.</p></li><li style="box-sizing: border-box; margin-top: 0.25em;"><p dir="auto" style="box-sizing: border-box; margin-bottom: 16px; margin-top: 16px;">After creating the OAuth client ID, note down the "Client ID" and "Client Secret" values.<br style="box-sizing: border-box;" /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhosmXdt6JW08WND69D4vEPShMexcMfQFPGqMdmrUfUHYWSUzVmOeN42MoTGAdhtlb0q0QmlP00-a2WtMQmkV1F2NLZOQQiexv-3uT1LpM4y-Ltv2BasUFOkvMt5GgDh7Lc7M8OlxMzF0rHNmtb7iYwBX9VBg1q9DhuvFxPc0bJgY_Wxe3GKsb_CY3DJwPv/s544/Google-Auth-OAuth-Client-ID.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="544" data-original-width="512" height="640" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhosmXdt6JW08WND69D4vEPShMexcMfQFPGqMdmrUfUHYWSUzVmOeN42MoTGAdhtlb0q0QmlP00-a2WtMQmkV1F2NLZOQQiexv-3uT1LpM4y-Ltv2BasUFOkvMt5GgDh7Lc7M8OlxMzF0rHNmtb7iYwBX9VBg1q9DhuvFxPc0bJgY_Wxe3GKsb_CY3DJwPv/w602-h640/Google-Auth-OAuth-Client-ID.png" width="602" /></a><br /><br /></div><br /><br /><p></p></li></ol><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><div><span style="color: #0000ee; font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Noto Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji;"><u><br /></u></span></div><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);"><b>Step 3: Configure Your ASP.NET Core Application</b></span></p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">Now, let's configure your ASP.NET Core application to use Google Authentication. Open your <code style="background-color: var(--bgColor-neutral-muted, var(--color-neutral-muted)); border-radius: 6px; box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 13.6px; margin: 0px; padding: 0.2em 0.4em; white-space-collapse: break-spaces;">appsettings.json</code> file and add the Google Authentication settings:</p><div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" style="box-sizing: border-box; color: #1f2328; display: flex; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; justify-content: space-between; margin-bottom: 16px; overflow: auto; position: relative;"><pre style="border-radius: 6px; box-sizing: border-box; color: var(--fgColor-default, var(--color-fg-default)); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 13.6px; line-height: 1.45; margin-bottom: 0px; margin-top: 0px; overflow-wrap: normal; overflow: auto; padding: 16px; word-break: normal;">{
<span class="pl-ent" color="var(--color-prettylights-syntax-entity-tag)" style="box-sizing: border-box;">"Authentication"</span>: {
<span class="pl-ent" color="var(--color-prettylights-syntax-entity-tag)" style="box-sizing: border-box;">"Google"</span>: {
<span class="pl-ent" color="var(--color-prettylights-syntax-entity-tag)" style="box-sizing: border-box;">"ClientId"</span>: <span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-pds" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span>YOUR_CLIENT_ID<span class="pl-pds" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span>,
<span class="pl-ent" color="var(--color-prettylights-syntax-entity-tag)" style="box-sizing: border-box;">"ClientSecret"</span>: <span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-pds" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span>YOUR_CLIENT_SECRET<span class="pl-pds" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span>
}
},
<span class="pl-ii" color="var(--color-prettylights-syntax-invalid-illegal-text)" style="box-sizing: border-box;">// Other application settings...</span>
}</pre><div class="zeroclipboard-container" style="animation: auto ease 0s 1 normal none running none; box-sizing: border-box;"><clipboard-copy aria-label="Copy" class="ClipboardButton btn btn-invisible js-clipboard-copy m-2 p-0 tooltipped-no-delay d-flex flex-justify-center flex-items-center" data-copy-feedback="Copied!" data-tooltip-direction="w" role="button" style="align-items: center; appearance: none; border-radius: 6px; border: 0px; box-shadow: none; box-sizing: border-box; color: var(--fgColor-accent, var(--color-accent-fg)); cursor: pointer; display: flex; font-size: 14px; font-weight: var(--base-text-weight-medium, 500); height: var(--control-small-size, 28px); justify-content: center; line-height: 20px; margin: var(--base-size-8, 8px) !important; padding: 0px; position: relative; text-wrap: nowrap; transition: color 80ms cubic-bezier(0.33, 1, 0.68, 1) 0s, background-color 0s ease 0s, box-shadow 0s ease 0s, border-color 0s ease 0s; user-select: none; vertical-align: middle; width: var(--control-small-size, 28px);" tabindex="0" value="{
"Authentication": {
"Google": {
"ClientId": "YOUR_CLIENT_ID",
"ClientSecret": "YOUR_CLIENT_SECRET"
}
},
// Other application settings...
}"><svg aria-hidden="true" class="octicon octicon-copy js-clipboard-copy-icon" data-view-component="true" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg></clipboard-copy></div></div><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">Replace <code style="background-color: var(--bgColor-neutral-muted, var(--color-neutral-muted)); border-radius: 6px; box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 13.6px; margin: 0px; padding: 0.2em 0.4em; white-space-collapse: break-spaces;">"YOUR_CLIENT_ID"</code> and <code style="background-color: var(--bgColor-neutral-muted, var(--color-neutral-muted)); border-radius: 6px; box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 13.6px; margin: 0px; padding: 0.2em 0.4em; white-space-collapse: break-spaces;">"YOUR_CLIENT_SECRET"</code> with the values you obtained from the Google Developer Console.</p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);"><b>Step 4: Enable Google Authentication in Your App</b></span></p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">In your ASP.NET Core application, navigate to the <code style="background-color: var(--bgColor-neutral-muted, var(--color-neutral-muted)); border-radius: 6px; box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 13.6px; margin: 0px; padding: 0.2em 0.4em; white-space-collapse: break-spaces;">Program.cs</code> file. Inside the <code style="background-color: var(--bgColor-neutral-muted, var(--color-neutral-muted)); border-radius: 6px; box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 13.6px; margin: 0px; padding: 0.2em 0.4em; white-space-collapse: break-spaces;">CreateHostBuilder</code> method, add the following code to enable Google Authentication:</p><div class="highlight highlight-source-cs notranslate position-relative overflow-auto" dir="auto" style="box-sizing: border-box; color: #1f2328; display: flex; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; justify-content: space-between; margin-bottom: 16px; overflow: auto; position: relative;"><pre style="border-radius: 6px; box-sizing: border-box; color: var(--fgColor-default, var(--color-fg-default)); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 13.6px; line-height: 1.45; margin-bottom: 0px; margin-top: 0px; overflow-wrap: normal; overflow: auto; padding: 16px; word-break: normal;">builder<span class="pl-kos" style="box-sizing: border-box;">.</span>Services<span class="pl-kos" style="box-sizing: border-box;">.</span><span class="pl-en" color="var(--color-prettylights-syntax-entity)" style="box-sizing: border-box;">AddAuthentication</span><span class="pl-kos" style="box-sizing: border-box;">(</span><span class="pl-kos" style="box-sizing: border-box;">)</span>
<span class="pl-kos" style="box-sizing: border-box;">.</span><span class="pl-en" color="var(--color-prettylights-syntax-entity)" style="box-sizing: border-box;">AddGoogle</span><span class="pl-kos" style="box-sizing: border-box;">(</span><span class="pl-s1" style="box-sizing: border-box;">options <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">=></span></span>
<span class="pl-s1" style="box-sizing: border-box;"> <span class="pl-kos" style="box-sizing: border-box;">{</span></span>
<span class="pl-s1" style="box-sizing: border-box;"> options<span class="pl-kos" style="box-sizing: border-box;">.</span>ClientId <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">=</span> Configuration<span class="pl-kos" style="box-sizing: border-box;">[</span><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span>Authentication:Google:ClientId<span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span><span class="pl-kos" style="box-sizing: border-box;">]</span><span class="pl-kos" style="box-sizing: border-box;">;</span></span>
<span class="pl-s1" style="box-sizing: border-box;"> options<span class="pl-kos" style="box-sizing: border-box;">.</span>ClientSecret <span class="pl-c1" color="var(--color-prettylights-syntax-constant)" style="box-sizing: border-box;">=</span> Configuration<span class="pl-kos" style="box-sizing: border-box;">[</span><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;"><span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span>Authentication:Google:ClientSecret<span class="pl-s" color="var(--color-prettylights-syntax-string)" style="box-sizing: border-box;">"</span></span><span class="pl-kos" style="box-sizing: border-box;">]</span><span class="pl-kos" style="box-sizing: border-box;">;</span></span>
<span class="pl-s1" style="box-sizing: border-box;"> <span class="pl-kos" style="box-sizing: border-box;">}</span></span><span class="pl-kos" style="box-sizing: border-box;">)</span><span class="pl-kos" style="box-sizing: border-box;">;</span></pre><div class="zeroclipboard-container" style="animation: auto ease 0s 1 normal none running none; box-sizing: border-box;"><clipboard-copy aria-label="Copy" class="ClipboardButton btn btn-invisible js-clipboard-copy m-2 p-0 tooltipped-no-delay d-flex flex-justify-center flex-items-center" data-copy-feedback="Copied!" data-tooltip-direction="w" role="button" style="align-items: center; appearance: none; border-radius: 6px; border: 0px; box-shadow: none; box-sizing: border-box; color: var(--fgColor-accent, var(--color-accent-fg)); cursor: pointer; display: flex; font-size: 14px; font-weight: var(--base-text-weight-medium, 500); height: var(--control-small-size, 28px); justify-content: center; line-height: 20px; margin: var(--base-size-8, 8px) !important; padding: 0px; position: relative; text-wrap: nowrap; transition: color 80ms cubic-bezier(0.33, 1, 0.68, 1) 0s, background-color 0s ease 0s, box-shadow 0s ease 0s, border-color 0s ease 0s; user-select: none; vertical-align: middle; width: var(--control-small-size, 28px);" tabindex="0" value="builder.Services.AddAuthentication()
.AddGoogle(options =>
{
options.ClientId = Configuration["Authentication:Google:ClientId"];
options.ClientSecret = Configuration["Authentication:Google:ClientSecret"];
});"><svg aria-hidden="true" class="octicon octicon-copy js-clipboard-copy-icon" data-view-component="true" height="16" version="1.1" viewbox="0 0 16 16" width="16"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg></clipboard-copy></div></div><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">This code configures the authentication services to use Google Authentication and sets the client ID and client secret from your <code style="background-color: var(--bgColor-neutral-muted, var(--color-neutral-muted)); border-radius: 6px; box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 13.6px; margin: 0px; padding: 0.2em 0.4em; white-space-collapse: break-spaces;">appsettings.json</code> file.</p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);"><b>Step 5: Run Your Application</b></span></p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">With Google Authentication configured, you can start your ASP.NET Core application. You should now see the "Use other services to log in" option on your login page, with Google as one of the available choices.</p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;">Click the "Google" button, and a popup will appear, prompting you to sign in with your Google account. After signing in, you'll be redirected back to your application, logged in, and authenticated via Google.</p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 16px; margin-top: 0px;"><span style="box-sizing: border-box; font-weight: var(--base-text-weight-semibold, 600);"><b>Conclusion:</b></span></p><p dir="auto" style="background-color: white; box-sizing: border-box; color: #1f2328; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; font-size: 16px; margin-bottom: 0px; margin-top: 0px;">Integrating Google Authentication into your ASP.NET Core application provides users with a convenient and secure way to access your services without creating additional accounts. This enhances the user experience and can boost user engagement on your platform.</p>Niranjanhttp://www.blogger.com/profile/09593008555732266996noreply@blogger.com0tag:blogger.com,1999:blog-2999456122062603029.post-22717856548211351472023-09-12T22:50:00.004-07:002023-09-12T23:55:33.533-07:00Unblocking Angular CLI: Resolving the PS1 Error in PowerShell<p> </p><h2 id="introduction" style="background-color: white; color: #222222; font-family: Domine, Arial, Verdana, sans-serif; font-size: 26px; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;">Introduction</h2><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">When working with Angular CLI (Command Line Interface) and PowerShell on Windows, you may encounter an error message that says, “PS1 cannot be loaded because running scripts is disabled on this system.” This error typically occurs due to the security settings on your system that prevent the execution of PowerShell scripts. However, you must continue using Angular CLI effectively. This guide will walk you through the steps to fix this error and get back to your Angular development workflow.</p><h2 id="understanding-the-error" style="background-color: white; color: #222222; font-family: Domine, Arial, Verdana, sans-serif; font-size: 26px; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;">Understanding the Error</h2><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">Your error message is related to PowerShell’s script execution policy. PowerShell has different execution policies determining whether scripts can be run and under what conditions. The default execution policy on many Windows systems is often set to “Restricted,” which prevents the execution of scripts, including Angular CLI scripts.</p><div class="language-powershell highlighter-rouge" style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px;"><div class="highlight"><pre class="highlight" style="background-color: whitesmoke; border-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.42857; margin-bottom: 5px; margin-top: 0px; overflow-wrap: break-word; overflow-x: auto; padding: 9.5px; text-wrap: wrap; word-break: break-all;"><code style="background-color: transparent; border-radius: 4px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 11.7px; padding: 0px;"><span class="n">PS</span> <span class="nx">E:\DevWorkspaces\GitHub\niranjankala\ms-learn\src\dotnet-core\Summaries</span><span class="err">></span> <span class="nx">ng</span> <span class="nt">-v</span>
<span class="n">ng</span> <span class="p">:</span> <span class="nx">File</span> <span class="nx">C:\Users\niran\AppData\Roaming\npm\ng.ps1</span> <span class="nx">cannot</span> <span class="nx">be</span> <span class="nx">loaded.</span> <span class="nx">The</span> <span class="nx">file</span> <span class="nx">C:\Users\niran\AppData\Roaming\npm\ng.ps1</span> <span class="nx">is</span> <span class="nx">not</span> <span class="nx">digitally</span> <span class="nx">signed.</span> <span class="nx">You</span> <span class="nx">cannot</span> <span class="nx">run</span> <span class="nx">this</span> <span class="nx">script</span> <span class="nx">on</span> <span class="nx">the</span> <span class="nx">current</span> <span class="nx">system.</span> <span class="nx">For</span>
<span class="n">more</span> <span class="nx">information</span> <span class="nx">about</span> <span class="nx">running</span> <span class="nx">scripts</span> <span class="nx">and</span> <span class="nx">setting</span> <span class="nx">execution</span> <span class="nx">policy</span><span class="p">,</span> <span class="nx">see</span> <span class="nx">about_Execution_Policies</span> <span class="nx">at</span> <span class="nx">https:/go.microsoft.com/fwlink/</span><span class="nf">?</span><span class="nx">LinkID</span><span class="o">=</span><span class="nx">135170.</span>
<span class="n">At</span> <span class="nx">line:1</span> <span class="nx">char:1</span>
<span class="o">+</span> <span class="n">ng</span> <span class="nt">-v</span>
<span class="o">+</span> <span class="n">~~</span>
<span class="o">+</span> <span class="nx">CategoryInfo</span> <span class="p">:</span> <span class="nx">SecurityError:</span> <span class="p">(:)</span> <span class="p">[],</span> <span class="n">PSSecurityException</span>
<span class="o">+</span> <span class="nx">FullyQualifiedErrorId</span> <span class="p">:</span> <span class="nx">UnauthorizedAccess</span>
</code></pre></div></div><h3 id="how-to-fix-error-ps1-can-not-be-loaded-because-running-scripts-is-disabled-on-this-system-in-angular" style="background-color: white; color: #222222; font-family: Domine, Arial, Verdana, sans-serif; font-size: 24px; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;">How To Fix Error “PS1 Can Not Be Loaded Because Running Scripts Is Disabled On This System” In Angular</h3><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">When working with Angular CLI (Command Line Interface) and PowerShell on Windows, you may encounter an error message that says, “PS1 cannot be loaded because running scripts is disabled on this system.” This error typically occurs due to the security settings on your system that prevent the execution of PowerShell scripts. However, resolving this issue is essential to continue using Angular CLI effectively. This guide will walk you through the steps to fix this error and get back to your Angular development workflow.</p><h2 id="understanding-the-error-1" style="background-color: white; color: #222222; font-family: Domine, Arial, Verdana, sans-serif; font-size: 26px; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;">Understanding the Error</h2><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">Your error message is related to PowerShell’s script execution policy. PowerShell has different execution policies determining whether scripts can be run and under what conditions. The default execution policy on many Windows systems is often set to “Restricted,” which prevents the execution of scripts, including Angular CLI scripts.</p><h2 id="solution-change-the-execution-policy" style="background-color: white; color: #222222; font-family: Domine, Arial, Verdana, sans-serif; font-size: 26px; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;">Solution: Change the Execution Policy</h2><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">To resolve this issue, you must change the PowerShell execution policy to allow script execution. Here are the steps to do that:</p><ol style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin-bottom: 10px; margin-top: 0px;"><li><strong>Open PowerShell as an Administrator:</strong><ul style="margin-bottom: 0px; margin-top: 0px;"><li>Click on the Windows Start button.</li><li>Search for “PowerShell.”</li><li>Right-click on “Windows PowerShell” or “PowerShell” (depending on your Windows version) and select “Run as administrator.”</li></ul></li><li><strong>Check the Current Execution Policy:</strong><ul style="margin-bottom: 0px; margin-top: 0px;"><li>In the PowerShell window, type the following command and press Enter:<div class="language-powershell highlighter-rouge"><div class="highlight"><pre class="highlight" style="background-color: whitesmoke; border-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.42857; margin-bottom: 5px; margin-top: 0px; overflow-wrap: break-word; overflow-x: auto; padding: 9.5px; text-wrap: wrap; word-break: break-all;"><code style="background-color: transparent; border-radius: 4px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 11.7px; padding: 0px;"><span class="n">Get-ExecutionPolicy</span>
</code></pre></div></div></li><li>This command will display the current execution policy. If it’s set to “Restricted,” you need to change it.</li></ul></li><li><strong>Change the Execution Policy:</strong><ul style="margin-bottom: 0px; margin-top: 0px;"><li>To change the execution policy, you can use the following command:<div class="language-powershell highlighter-rouge"><div class="highlight"><pre class="highlight" style="background-color: whitesmoke; border-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.42857; margin-bottom: 5px; margin-top: 0px; overflow-wrap: break-word; overflow-x: auto; padding: 9.5px; text-wrap: wrap; word-break: break-all;"><code style="background-color: transparent; border-radius: 4px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 11.7px; padding: 0px;"><span class="n">Set-ExecutionPolicy</span> <span class="nx">RemoteSigned</span>
</code></pre></div></div><p style="margin: 0px 0px 15px;">The “RemoteSigned” policy allows the execution of locally created scripts that require a digital signature for scripts downloaded from the internet.</p></li><li>You might be prompted to confirm the change. Type “Y” for Yes and press Enter.</li></ul></li><li><strong>Verify the New Execution Policy:</strong><ul style="margin-bottom: 0px; margin-top: 0px;"><li>To ensure that the execution policy has been changed successfully, run the following command:<div class="language-powershell highlighter-rouge"><div class="highlight"><pre class="highlight" style="background-color: whitesmoke; border-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.42857; margin-bottom: 5px; margin-top: 0px; overflow-wrap: break-word; overflow-x: auto; padding: 9.5px; text-wrap: wrap; word-break: break-all;"><code style="background-color: transparent; border-radius: 4px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 11.7px; padding: 0px;"><span class="n">Get-ExecutionPolicy</span>
</code></pre></div></div><p style="margin: 0px 0px 15px;">It should now display “RemoteSigned.”</p></li></ul></li><li><strong>Restart PowerShell:</strong><ul style="margin-bottom: 0px; margin-top: 0px;"><li>Close the PowerShell window and open a new one for the changes to take effect.</li></ul></li><li><strong>Run Your Angular CLI Command:</strong></li><ul style="margin-bottom: 0px; margin-top: 0px;"><li>Now that you’ve allowed script execution, you should be able to run Angular CLI commands without encountering the “PS1 cannot be loaded” error.</li></ul></ol><div><span style="color: #222222; font-family: Open Sans, Helvetica, Arial, sans-serif;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmBhyXcNg1Acyj2mOPb9F7iSyb6ka1I1IMLhkKnhbQ4jzgrkiWiyb0KU3K3bNk75e1yomXnx5DzAMWc0soCtf0Z5_B25oGTamJlTqWDyZbCW1J8LOkVJy0JPsQ8c7UZ8eXmM7bISn9kh2rzRyty2O5iam8U5VoBDC4Ma2leuBUF43KlLM7Cdaa41HU4z94/s1117/Angular_PowerShell_Issue_Resolved.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="633" data-original-width="1117" height="363" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmBhyXcNg1Acyj2mOPb9F7iSyb6ka1I1IMLhkKnhbQ4jzgrkiWiyb0KU3K3bNk75e1yomXnx5DzAMWc0soCtf0Z5_B25oGTamJlTqWDyZbCW1J8LOkVJy0JPsQ8c7UZ8eXmM7bISn9kh2rzRyty2O5iam8U5VoBDC4Ma2leuBUF43KlLM7Cdaa41HU4z94/w640-h363/Angular_PowerShell_Issue_Resolved.png" width="640" /></a></div><br /><span style="font-size: 15px;"><br /></span></span></div><h2 id="caution" style="background-color: white; color: #222222; font-family: Domine, Arial, Verdana, sans-serif; font-size: 26px; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;">Caution</h2><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">Changing the execution policy to “RemoteSigned” makes your system more permissive with regard to script execution. While this change is necessary for running Angular CLI commands, it’s essential to be cautious when running scripts from untrusted sources. Ensure you run scripts from reliable and trusted locations to minimize security risks.</p><h2 id="conclusion" style="background-color: white; color: #222222; font-family: Domine, Arial, Verdana, sans-serif; font-size: 26px; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;">Conclusion</h2><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">By changing the PowerShell execution policy to “RemoteSigned,” you can resolve the “PS1 cannot be loaded” error and continue using Angular CLI without issues. However, remember to exercise caution when executing scripts and only run scripts from trusted sources to maintain the security of your system. With this error resolved, you can smoothly work on your Angular projects using PowerShell.</p>Niranjanhttp://www.blogger.com/profile/09593008555732266996noreply@blogger.com0tag:blogger.com,1999:blog-2999456122062603029.post-48492351472722542802023-07-31T00:35:00.000-07:002023-07-31T00:35:17.565-07:00How to Fix ORA-01489: Result of String Concatenation is Too Long with LISTAGG Function<p> </p><h2 id="introduction" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 32px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px; text-align: justify;">Introduction</h2><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;">Oracle Database is a powerful relational database management system offering developers and database administrators various functionalities. One of these powerful features is the <code class="language-plaintext highlighter-rouge" style="background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13.5px; padding: 2px 4px; text-wrap: nowrap;">LISTAGG</code> function, which allows you to aggregate rows of data into a single concatenated string. However, when using the <code class="language-plaintext highlighter-rouge" style="background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13.5px; padding: 2px 4px; text-wrap: nowrap;">LISTAGG</code> function with large datasets, you may encounter an error message like “ORA-01489: result of string concatenation is too long.” In this article, we will explore the causes of this error and discuss various methods to prevent and handle it effectively.</p><h2 id="understanding-the-ora-01489-error" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 32px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px; text-align: justify;">Understanding the ORA-01489 Error</h2><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;">The <code class="language-plaintext highlighter-rouge" style="background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13.5px; padding: 2px 4px; text-wrap: nowrap;">ORA-01489</code> error occurs when the result of concatenating strings with the <code class="language-plaintext highlighter-rouge" style="background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13.5px; padding: 2px 4px; text-wrap: nowrap;">LISTAGG</code> function exceeds the maximum allowed length for a string in Oracle, which is 4000 characters for non-CLOB data types in most environments. When the concatenated string surpasses this limit, the error is triggered, and the query fails to execute.</p><h2 id="solutions-to-prevent-ora-01489-error" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 32px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px; text-align: justify;">Solutions to Prevent ORA-01489 Error</h2><h3 id="1-truncate-the-result-with-on-overflow-truncate" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 26px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px; text-align: justify;">1. Truncate the Result with <code class="language-plaintext highlighter-rouge" style="background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 23.4px; padding: 2px 4px; text-wrap: nowrap;">ON OVERFLOW TRUNCATE</code>:</h3><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;">Starting from Oracle 19c, you can use the <code class="language-plaintext highlighter-rouge" style="background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13.5px; padding: 2px 4px; text-wrap: nowrap;">ON OVERFLOW TRUNCATE</code> clause with the <code class="language-plaintext highlighter-rouge" style="background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13.5px; padding: 2px 4px; text-wrap: nowrap;">LISTAGG</code> function. This option truncates the concatenated string to fit within the maximum string length allowed.</p><div class="language-sql highlighter-rouge" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; text-align: justify;"><div class="highlight" style="box-sizing: border-box;"><pre class="highlight" style="background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; line-height: 1.42857; margin-bottom: 10.5px; margin-top: 0px; overflow-wrap: break-word; overflow: auto; padding: 10px; word-break: break-all;"><code style="background-color: transparent; border-radius: 0px; box-sizing: border-box; color: inherit; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; padding: 0px; text-wrap: wrap;"><span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">SELECT</span>
<span class="n" style="box-sizing: border-box;">LISTAGG</span><span class="p" style="box-sizing: border-box;">(</span><span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">column</span><span class="p" style="box-sizing: border-box;">,</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">delimiter</span><span class="p" style="box-sizing: border-box;">)</span> <span class="n" style="box-sizing: border-box;">WITHIN</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">GROUP</span> <span class="p" style="box-sizing: border-box;">(</span><span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">ORDER</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">BY</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">column</span><span class="p" style="box-sizing: border-box;">)</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">ON</span> <span class="n" style="box-sizing: border-box;">OVERFLOW</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">TRUNCATE</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">AS</span> <span class="n" style="box-sizing: border-box;">concatenated_result</span>
<span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">FROM</span>
<span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">table_name</span><span class="p" style="box-sizing: border-box;">;</span>
</code></pre></div></div><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;">Please be careful when using this approach since it may lead to data loss if the truncated portion contains essential information.</p><h3 id="2-filter-data-to-reduce-concatenation-size" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 26px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px; text-align: justify;">2. Filter Data to Reduce Concatenation Size:</h3><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;">If the error occurs due to a large number of rows being concatenated, consider filtering the data before using the <code class="language-plaintext highlighter-rouge" style="background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13.5px; padding: 2px 4px; text-wrap: nowrap;">LISTAGG</code> function. Reducing the number of rows in the result set can help keep the concatenated string within the allowed length.</p><div class="language-sql highlighter-rouge" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; text-align: justify;"><div class="highlight" style="box-sizing: border-box;"><pre class="highlight" style="background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; line-height: 1.42857; margin-bottom: 10.5px; margin-top: 0px; overflow-wrap: break-word; overflow: auto; padding: 10px; word-break: break-all;"><code style="background-color: transparent; border-radius: 0px; box-sizing: border-box; color: inherit; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; padding: 0px; text-wrap: wrap;"><span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">SELECT</span>
<span class="n" style="box-sizing: border-box;">LISTAGG</span><span class="p" style="box-sizing: border-box;">(</span><span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">column</span><span class="p" style="box-sizing: border-box;">,</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">delimiter</span><span class="p" style="box-sizing: border-box;">)</span> <span class="n" style="box-sizing: border-box;">WITHIN</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">GROUP</span> <span class="p" style="box-sizing: border-box;">(</span><span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">ORDER</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">BY</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">column</span><span class="p" style="box-sizing: border-box;">)</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">AS</span> <span class="n" style="box-sizing: border-box;">concatenated_result</span>
<span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">FROM</span>
<span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">table_name</span>
<span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">WHERE</span>
<span class="cm" style="box-sizing: border-box; color: #999988; font-style: italic;">/* Add appropriate conditions to filter data */</span>
<span class="n" style="box-sizing: border-box;">condition</span><span class="p" style="box-sizing: border-box;">;</span>
</code></pre></div></div><h3 id="3-use-clob-data-type-for-concatenation" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 26px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px; text-align: justify;">3. Use CLOB Data Type for Concatenation:</h3><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;">If the concatenated result is expected to exceed the maximum allowed length for a non-CLOB data type, you can use the CLOB data type to store the result. CLOB can handle much larger strings, making it suitable for situations requiring extensive concatenation.</p><div class="language-sql highlighter-rouge" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; text-align: justify;"><div class="highlight" style="box-sizing: border-box;"><pre class="highlight" style="background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; line-height: 1.42857; margin-bottom: 10.5px; margin-top: 0px; overflow-wrap: break-word; overflow: auto; padding: 10px; word-break: break-all;"><code style="background-color: transparent; border-radius: 0px; box-sizing: border-box; color: inherit; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; padding: 0px; text-wrap: wrap;"><span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">SELECT</span>
<span class="n" style="box-sizing: border-box;">TO_CLOB</span><span class="p" style="box-sizing: border-box;">(</span><span class="n" style="box-sizing: border-box;">LISTAGG</span><span class="p" style="box-sizing: border-box;">(</span><span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">column</span><span class="p" style="box-sizing: border-box;">,</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">delimiter</span><span class="p" style="box-sizing: border-box;">)</span> <span class="n" style="box-sizing: border-box;">WITHIN</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">GROUP</span> <span class="p" style="box-sizing: border-box;">(</span><span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">ORDER</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">BY</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">column</span><span class="p" style="box-sizing: border-box;">))</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">AS</span> <span class="n" style="box-sizing: border-box;">concatenated_clob</span>
<span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">FROM</span>
<span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">table_name</span><span class="p" style="box-sizing: border-box;">;</span>
</code></pre></div></div><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;">Please note that CLOB data type has its limitations, and you should ensure it aligns with your database configuration.</p><h3 id="4-partition-the-data" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 26px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px; text-align: justify;">4. Partition the Data:</h3><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;">If possible, partition the data and perform concatenation on smaller subsets. You can then combine the results of each subset to get the final concatenated string.</p><div class="language-sql highlighter-rouge" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; text-align: justify;"><div class="highlight" style="box-sizing: border-box;"><pre class="highlight" style="background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; line-height: 1.42857; margin-bottom: 10.5px; margin-top: 0px; overflow-wrap: break-word; overflow: auto; padding: 10px; word-break: break-all;"><code style="background-color: transparent; border-radius: 0px; box-sizing: border-box; color: inherit; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; padding: 0px; text-wrap: wrap;"><span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">SELECT</span>
<span class="n" style="box-sizing: border-box;">LISTAGG</span><span class="p" style="box-sizing: border-box;">(</span><span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">column</span><span class="p" style="box-sizing: border-box;">,</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">delimiter</span><span class="p" style="box-sizing: border-box;">)</span> <span class="n" style="box-sizing: border-box;">WITHIN</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">GROUP</span> <span class="p" style="box-sizing: border-box;">(</span><span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">ORDER</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">BY</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">column</span><span class="p" style="box-sizing: border-box;">)</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">AS</span> <span class="n" style="box-sizing: border-box;">concatenated_result</span>
<span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">FROM</span>
<span class="p" style="box-sizing: border-box;">(</span>
<span class="cm" style="box-sizing: border-box; color: #999988; font-style: italic;">/* Subquery 1: Concatenate first partition */</span>
<span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">SELECT</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">column</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">FROM</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">table_name</span> <span class="n" style="box-sizing: border-box;">PARTITION</span> <span class="p" style="box-sizing: border-box;">(</span><span class="n" style="box-sizing: border-box;">partition_name_1</span><span class="p" style="box-sizing: border-box;">)</span>
<span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">UNION</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">ALL</span>
<span class="cm" style="box-sizing: border-box; color: #999988; font-style: italic;">/* Subquery 2: Concatenate second partition */</span>
<span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">SELECT</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">column</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">FROM</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">table_name</span> <span class="n" style="box-sizing: border-box;">PARTITION</span> <span class="p" style="box-sizing: border-box;">(</span><span class="n" style="box-sizing: border-box;">partition_name_2</span><span class="p" style="box-sizing: border-box;">)</span>
<span class="cm" style="box-sizing: border-box; color: #999988; font-style: italic;">/* Add more subqueries as needed for other partitions */</span>
<span class="p" style="box-sizing: border-box;">);</span>
</code></pre></div></div><h3 id="5-use-xmlagg-and-listagg-combination" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 26px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px; text-align: justify;">5. Use XMLAGG and LISTAGG Combination:</h3><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;">Another approach to overcome the ORA-01489 error is using <code class="language-plaintext highlighter-rouge" style="background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13.5px; padding: 2px 4px; text-wrap: nowrap;">XMLAGG</code> in combination with <code class="language-plaintext highlighter-rouge" style="background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13.5px; padding: 2px 4px; text-wrap: nowrap;">LISTAGG</code>. The <code class="language-plaintext highlighter-rouge" style="background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13.5px; padding: 2px 4px; text-wrap: nowrap;">XMLAGG</code> function helps avoid the string length limitation by aggregating data into XML elements before concatenation.</p><div class="language-sql highlighter-rouge" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; text-align: justify;"><div class="highlight" style="box-sizing: border-box;"><pre class="highlight" style="background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; line-height: 1.42857; margin-bottom: 10.5px; margin-top: 0px; overflow-wrap: break-word; overflow: auto; padding: 10px; word-break: break-all;"><code style="background-color: transparent; border-radius: 0px; box-sizing: border-box; color: inherit; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; padding: 0px; text-wrap: wrap;"><span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">SELECT</span>
<span class="n" style="box-sizing: border-box;">RTRIM</span><span class="p" style="box-sizing: border-box;">(</span>
<span class="n" style="box-sizing: border-box;">XMLAGG</span><span class="p" style="box-sizing: border-box;">(</span><span class="n" style="box-sizing: border-box;">XMLELEMENT</span><span class="p" style="box-sizing: border-box;">(</span><span class="n" style="box-sizing: border-box;">e</span><span class="p" style="box-sizing: border-box;">,</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">column</span> <span class="o" style="box-sizing: border-box; color: black; font-weight: bold;">||</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">delimiter</span><span class="p" style="box-sizing: border-box;">)</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">ORDER</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">BY</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">column</span><span class="p" style="box-sizing: border-box;">).</span><span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">EXTRACT</span><span class="p" style="box-sizing: border-box;">(</span><span class="s1" style="box-sizing: border-box; color: #d01040;">'//text()'</span><span class="p" style="box-sizing: border-box;">),</span>
<span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">delimiter</span>
<span class="p" style="box-sizing: border-box;">)</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">AS</span> <span class="n" style="box-sizing: border-box;">concatenated_result</span>
<span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">FROM</span>
<span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">table_name</span><span class="p" style="box-sizing: border-box;">;</span>
</code></pre></div></div><h3 id="6-limit-the-concatenation-length" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 26px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px; text-align: justify;">6. Limit the Concatenation Length:</h3><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;">If you don’t want to truncate the result or use CLOB, you can limit the maximum length of the concatenated string to a specific value using the <code class="language-plaintext highlighter-rouge" style="background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13.5px; padding: 2px 4px; text-wrap: nowrap;">SUBSTR</code> function.</p><div class="language-sql highlighter-rouge" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; text-align: justify;"><div class="highlight" style="box-sizing: border-box;"><pre class="highlight" style="background-color: whitesmoke; border-radius: 0px; border: 1px solid rgb(204, 204, 204); box-sizing: border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; line-height: 1.42857; margin-bottom: 10.5px; margin-top: 0px; overflow-wrap: break-word; overflow: auto; padding: 10px; word-break: break-all;"><code style="background-color: transparent; border-radius: 0px; box-sizing: border-box; color: inherit; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; padding: 0px; text-wrap: wrap;"><span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">SELECT</span>
<span class="n" style="box-sizing: border-box;">SUBSTR</span><span class="p" style="box-sizing: border-box;">(</span><span class="n" style="box-sizing: border-box;">LISTAGG</span><span class="p" style="box-sizing: border-box;">(</span><span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">column</span><span class="p" style="box-sizing: border-box;">,</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">delimiter</span><span class="p" style="box-sizing: border-box;">)</span> <span class="n" style="box-sizing: border-box;">WITHIN</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">GROUP</span> <span class="p" style="box-sizing: border-box;">(</span><span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">ORDER</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">BY</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">column</span><span class="p" style="box-sizing: border-box;">),</span> <span class="mi" style="box-sizing: border-box; color: #009999;">1</span><span class="p" style="box-sizing: border-box;">,</span> <span class="n" style="box-sizing: border-box;">max_length</span><span class="p" style="box-sizing: border-box;">)</span> <span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">AS</span> <span class="n" style="box-sizing: border-box;">concatenated_result</span>
<span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">FROM</span>
<span class="k" style="box-sizing: border-box; color: black; font-weight: bold;">table_name</span><span class="p" style="box-sizing: border-box;">;</span>
</code></pre></div></div><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;">In this example, <code class="language-plaintext highlighter-rouge" style="background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13.5px; padding: 2px 4px; text-wrap: nowrap;">max_length</code> should be the maximum allowed length for the concatenated string.</p><h2 id="conclusion" style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 32px; font-weight: 300; line-height: 1.1; margin-bottom: 10.5px; margin-top: 21px; text-align: justify;">Conclusion</h2><p style="background-color: white; box-sizing: border-box; color: #333333; font-family: "Open Sans", Calibri, Candara, Arial, sans-serif; font-size: 15px; margin: 0px 0px 10.5px; text-align: justify;">The <code class="language-plaintext highlighter-rouge" style="background-color: #f9f2f4; border-radius: 0px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 13.5px; padding: 2px 4px; text-wrap: nowrap;">LISTAGG</code> function in Oracle Database is valuable for aggregating data into a single concatenated string. However, if the result exceeds the maximum string length allowed, the ORA-01489 error may occur when dealing with large datasets. Applying one or a combination of the solutions provided in this article can effectively handle and prevent the ORA-01489 error, allowing you to manage and manipulate large datasets without encountering string concatenation length limitations. You can choose the solution that best fits your specific use case and database configuration to ensure efficient and error-free data aggregation.</p>Niranjan Singhhttp://www.blogger.com/profile/10098432252247322623noreply@blogger.com0tag:blogger.com,1999:blog-2999456122062603029.post-44180380018828474222022-08-05T00:44:00.000-07:002023-07-31T00:28:47.283-07:00How to download and install PostgreSQL? <div class="WordSection1"><p class="MsoNormal"><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; color: black; font-size: large; padding: 0in;">Introduction</span></b></span><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></b></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">This article will teach you how to download and install PostgreSQL on your system.</span></span><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p> </o:p></span></span></p><p class="MsoNormal"><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; color: black; font-size: large; padding: 0in;">Downloading and Installing PostgreSQL</span></b></span><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></b></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">To get started </span></span>working with Postgres, you need two components. <o:p></o:p></p><ol start="1" style="margin-top: 0in;" type="1"><li class="MsoListParagraphCxSpFirst" style="margin-left: 0in; mso-add-space: auto; mso-list: l1 level1 lfo1;"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">Postgres Server<br />It houses your data </span></span>and manages connections, security, and data maintenance. <br /><br /><span class="content-transcript-line"><o:p></o:p></span></li><li class="MsoListParagraphCxSpMiddle" style="margin-left: 0in; mso-add-space: auto; mso-list: l1 level1 lfo1;"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">Management Application <br />You need a way to communicate with a server </span></span>to work with and view the data it contains. For this, you'll need a management application or what is sometimes referred to as a front-end client. There are lots of different clients that you can use to interface with a Postgres Server. <o:p></o:p></li></ol><p class="MsoListParagraphCxSpLast"><span class="content-transcript-line"><o:p> </o:p></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">The easiest way to get started </span></span>is to use an installer that gives us both components in one step. Follow the below step to download and install PostgreSQL:<span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></span></p><p class="MsoNormal"><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; color: black; font-size: medium; padding: 0in;">Step 1</span></b></span><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></b></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">You'll start the installation at the URL <b><a href="https://postgresql.org/">postgressql.org</a></b>. </span></span>It is the official site for Postgres, and you will find a big download button on the top and click on it.<span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></span></p><p class="MsoNormal"><o:p> </o:p></p><p class="MsoNormal"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhgb1R3kgPjkipH14_Hm-vYSBms_67ETpHfeWf--6SyLEybXRi34rUJQK6FFv3P6Cyp36F5j0WQUSF72-BCRRu66bihIasllPIsSHXuYhXUkAB_yf7dVQ-sR-JWre7blRSbAOSM_XNXO5oiThNOg_ixuBMjJNyOieFEr3OyjQDI-tTUHSrY1gNg9Lpo1A"><img alt="" border="0" height="386" id="BLOGGER_PHOTO_ID_7128289414347673842" src="https://blogger.googleusercontent.com/img/a/AVvXsEhgb1R3kgPjkipH14_Hm-vYSBms_67ETpHfeWf--6SyLEybXRi34rUJQK6FFv3P6Cyp36F5j0WQUSF72-BCRRu66bihIasllPIsSHXuYhXUkAB_yf7dVQ-sR-JWre7blRSbAOSM_XNXO5oiThNOg_ixuBMjJNyOieFEr3OyjQDI-tTUHSrY1gNg9Lpo1A=w640-h386" width="640" /></a><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p> </o:p></span></span></p><p class="MsoNormal"><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; color: black; font-size: medium; padding: 0in;">Step 2</span></b></span><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></b></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">Now a new page will open, with several different application installers available depending on what operating system </span></span>you're working on.<span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></span></p><p class="MsoNormal"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjRKBce2rMTqvArHKQbEUhgNaGWRW4ERfETNhdQQtCZRbLvcL5d7DXlpon5nTscJhvx-RHH7995baivCIf_0d-g9MBUvHpnpDCS_2h03OKeuhaB80GoJrv97A1Ms8WWEyBh9Z8lgGrbq_k6XlSxGQku8uuNnLjh3PvwEkZpSicTGxIh0Mmi1qijBuHysQ"><img alt="" border="0" height="640" id="BLOGGER_PHOTO_ID_7128289417338273954" src="https://blogger.googleusercontent.com/img/a/AVvXsEjRKBce2rMTqvArHKQbEUhgNaGWRW4ERfETNhdQQtCZRbLvcL5d7DXlpon5nTscJhvx-RHH7995baivCIf_0d-g9MBUvHpnpDCS_2h03OKeuhaB80GoJrv97A1Ms8WWEyBh9Z8lgGrbq_k6XlSxGQku8uuNnLjh3PvwEkZpSicTGxIh0Mmi1qijBuHysQ=w592-h640" width="592" /></a><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">If you're working on a Linux machine, </span></span>you will likely already have a version of Postgres since it comes pre-installed with the OS. <o:p></o:p></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">The instructions you'll find at these links </span></span>will help you install an alternate version if you need to. The installation for your macOS and Windows is almost identical. I'm working on a Windows computer, so I will click on the Windows button highlighted with the yellow color. <span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></p><p class="MsoNormal"><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; color: black; font-size: medium; padding: 0in;">Step 3</span></b></span><span class="content-transcript-line"><b><o:p></o:p></b></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">That takes me to a page </span></span>that describes what versions of Postgres are available on each platform, either a 64-bit or 32-bit. <o:p></o:p></p><p class="MsoNormal"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhhrjvKJU-jXKAhBl8Bx1iOWj9tPMUmYFuvLX0OnuNumX7Fxe3DKXBtAAKXryV0HFB7F3eALXlU39TCYXnTCtz_Z24btSLMXh_nCWq5p_Zn0RVskqopqrQlCeTO_NKXjT1xIadKysZgmoM54iCiuetPQ-krH21LgHWvhgKWIv4NM6bAlAxjrmTPf1F30g"><img alt="" border="0" height="640" id="BLOGGER_PHOTO_ID_7128289419168550418" src="https://blogger.googleusercontent.com/img/a/AVvXsEhhrjvKJU-jXKAhBl8Bx1iOWj9tPMUmYFuvLX0OnuNumX7Fxe3DKXBtAAKXryV0HFB7F3eALXlU39TCYXnTCtz_Z24btSLMXh_nCWq5p_Zn0RVskqopqrQlCeTO_NKXjT1xIadKysZgmoM54iCiuetPQ-krH21LgHWvhgKWIv4NM6bAlAxjrmTPf1F30g=w592-h640" width="592" /></a><span class="content-transcript-line"><o:p></o:p></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p> </o:p></span></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">After viewing the platform support information, </span></span>you can click on the link up here that says <b>download the installer</b>. It takes you to a page maintained by a company called EnterpriseDB. <o:p></o:p></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;"><br /><b><span style="font-size: medium;">Step 4</span></b></span></span><span class="content-transcript-line"><b><o:p></o:p></b></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">Finally, here you can choose </span></span>which version of Postgres you want. <o:p></o:p></p><p class="MsoNormal"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjBEoJJrCnU9lZeKhUnb3AfWGFHRZxDx2VylhkvPZlqvUBHGcIxqYP3g0iqo4WVh4e4S0OyEWyUuYRGFSRPsVWvLoZWAtdQe0GxLLUSf-RSd6fO6mUzzhqVy1kSyOaTy8Kvc4JBRuXG12WmdEtu8dBJawdB1TK_-Hrvgc3_Ofg1yOJmEvwT5TzbCjB0cA"><img alt="" border="0" height="640" id="BLOGGER_PHOTO_ID_7128289424165399618" src="https://blogger.googleusercontent.com/img/a/AVvXsEjBEoJJrCnU9lZeKhUnb3AfWGFHRZxDx2VylhkvPZlqvUBHGcIxqYP3g0iqo4WVh4e4S0OyEWyUuYRGFSRPsVWvLoZWAtdQe0GxLLUSf-RSd6fO6mUzzhqVy1kSyOaTy8Kvc4JBRuXG12WmdEtu8dBJawdB1TK_-Hrvgc3_Ofg1yOJmEvwT5TzbCjB0cA=w592-h640" width="592" /></a><span class="content-transcript-line"><o:p></o:p></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p> </o:p></span></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">I'll select the downloader for your Postgres </span></span>by clicking on the download link underneath Windows. <o:p></o:p></p><p class="MsoNormal"><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; color: black; font-size: medium; padding: 0in;">Step 5</span></b></span><span class="content-transcript-line"><b><o:p></o:p></b></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">It will start the installation package download, and once the download is completed, </span></span>as I can see my screen's download progress, you can close the web browser and start the installation process. <o:p></o:p></p><p class="MsoNormal"><o:p> </o:p></p><p class="MsoNormal"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjMvc2mqKsogC1fPOdQs8MviEqJ-2UlgDbC_Xr7V1IY2XQyOeZFjQk7O3JKdnWwJaEqS6BsYXsoJCiah7wWfV7l6ZgKz9qXOWDseE2fjlxsFYNE3WCCpwG58pB9a3U0RWeZb_iJklz8ZLvxLAfaxxpkGb-e9iPdIa_ML-dRiGbOEHgJ7rerzw6HV0tDZQ"><img alt="" border="0" height="290" id="BLOGGER_PHOTO_ID_7128289425176947586" src="https://blogger.googleusercontent.com/img/a/AVvXsEjMvc2mqKsogC1fPOdQs8MviEqJ-2UlgDbC_Xr7V1IY2XQyOeZFjQk7O3JKdnWwJaEqS6BsYXsoJCiah7wWfV7l6ZgKz9qXOWDseE2fjlxsFYNE3WCCpwG58pB9a3U0RWeZb_iJklz8ZLvxLAfaxxpkGb-e9iPdIa_ML-dRiGbOEHgJ7rerzw6HV0tDZQ=w640-h290" width="640" /></a><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">You should find the file inside the downloads folder </span></span>for your computer. Go ahead and double-click on it to start it up. I'll allow it to make changes to my computer. <o:p></o:p></p><p class="MsoNormal"><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; color: black; font-size: medium; padding: 0in;">Step 6</span></b></span><span class="content-transcript-line"><b><o:p></o:p></b></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">So that starts the setup wizard. </span></span>Let's press the next button on this screen. <o:p></o:p></p><p class="MsoNormal"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhuy_T6kktke1v19Nf7mBXbb2AMlsOpSRtx-ldC18sr4xJlrhz8piFf9PNmuuDGysO7dSWCFyHk-4kqg32c2oa8mQU1AqKd26IPkWTN_i4RVTex-bd4zba54c-TsR9gDw2fvQcEuSkdGCmCNMmdlQSkDb1C8IRS28BtQFfD1Ys1pzXKW61zkJBUUsAMfw"><img alt="" border="0" height="502" id="BLOGGER_PHOTO_ID_7128289429728865938" src="https://blogger.googleusercontent.com/img/a/AVvXsEhuy_T6kktke1v19Nf7mBXbb2AMlsOpSRtx-ldC18sr4xJlrhz8piFf9PNmuuDGysO7dSWCFyHk-4kqg32c2oa8mQU1AqKd26IPkWTN_i4RVTex-bd4zba54c-TsR9gDw2fvQcEuSkdGCmCNMmdlQSkDb1C8IRS28BtQFfD1Ys1pzXKW61zkJBUUsAMfw=w640-h502" width="640" /></a><span class="content-transcript-line"><o:p></o:p></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p> </o:p></span></span></p><p class="MsoNormal"><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; color: black; font-size: medium; padding: 0in;">Step 7</span></b></span><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></b></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">The default installation directory </span></span>will be on my computer, inside the program files folder, a new folder for PostgreSQL, and then the version. I'll leave it to default and press next. <o:p></o:p></p><p class="MsoNormal"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjRLrOpd5Ye31lg3bpm6cG6OF4ORWlKUCo4T6HCjSEZpdnq2f6y_7kN_SlLuH44hJIvJk2J86RJO1RpmNpNMA4Psqy2kHi-J3vL01TZ_GjcVJoAKicf5jnwuOU_6-49qZCfCsymQ-Ium_Px3P97OPMWawlLyDorljSZ_QvOq05Hh2AjnnREGPHwyOw2Hw"><img alt="" border="0" height="502" id="BLOGGER_PHOTO_ID_7128289434679929410" src="https://blogger.googleusercontent.com/img/a/AVvXsEjRLrOpd5Ye31lg3bpm6cG6OF4ORWlKUCo4T6HCjSEZpdnq2f6y_7kN_SlLuH44hJIvJk2J86RJO1RpmNpNMA4Psqy2kHi-J3vL01TZ_GjcVJoAKicf5jnwuOU_6-49qZCfCsymQ-Ium_Px3P97OPMWawlLyDorljSZ_QvOq05Hh2AjnnREGPHwyOw2Hw=w640-h502" width="640" /></a><span class="content-transcript-line"><o:p></o:p></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p> </o:p></span></span></p><p class="MsoNormal"><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; color: black; font-size: medium; padding: 0in;">Step 8</span></b></span><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></b></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">Here, you have four different components </span></span>that you can install. <o:p></o:p></p><p class="MsoNormal"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEg-oULY_NxcyWtcBtNYsni_yCOle_pTXo94Q-kaUKME99J_HGTeQ2bdyObSSWxVGC8078cxHD5kt9wZjY01DT9fFk-PRsg41kt9-cX3hKH5Tc6dPIQva_o-90HHiK20r92PSE99LYwBbgHg0XWMMN4m7kXN6BzH8PyZ4jGTCXNfStwCKMmmoH5MOWrakg"><img alt="" border="0" height="502" id="BLOGGER_PHOTO_ID_7128289435857945842" src="https://blogger.googleusercontent.com/img/a/AVvXsEg-oULY_NxcyWtcBtNYsni_yCOle_pTXo94Q-kaUKME99J_HGTeQ2bdyObSSWxVGC8078cxHD5kt9wZjY01DT9fFk-PRsg41kt9-cX3hKH5Tc6dPIQva_o-90HHiK20r92PSE99LYwBbgHg0XWMMN4m7kXN6BzH8PyZ4jGTCXNfStwCKMmmoH5MOWrakg=w640-h502" width="640" /></a><span class="content-transcript-line"><o:p></o:p></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">The PostgreSQL Server is the main component, </span></span>so I want to make sure that that's turned on. <o:p></o:p></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">You have two interface clients that are coming along, </span></span>pgAdmin 4 is a graphical user interface, and I'll leave that on, as well as the command line tools, and I'll leave those on as well. <span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">Stack Builder is a tool </span></span>that will help you install additional add-on packages if you're interested in extending Postgres' capabilities. You can turn this off if you'd like. I'll leave it on here to install everything, and I'll go ahead and press the next button. <span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></p><p class="MsoNormal"><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; color: black; font-size: medium; padding: 0in;">Step 9</span></b></span><span class="content-transcript-line"><b><o:p></o:p></b></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">Next, it sets up a default data directory. </span></span>And once again, on my computer, as in program files, PostgreSQL version, and then a new folder called data.<span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></span></p><p class="MsoNormal"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEiGsJ9PK2vS1JjEQQJZYoqmEYpF_LIqBgxCkTATi0_H_tfvQBnqklzT0OXzM_f2ZIEoCmDKSHaj_h6oNz3M2pDj3X-UoLNylDQBPBDTHLvB8QSGiAVsvLEkmHIs8sY7wZ0DqR09MJLkkktg2gHSUB0AA6LNa_2lqksYr5HCZ-lL8ZXQV6bmHYclGAbwhw"><img alt="" border="0" height="502" id="BLOGGER_PHOTO_ID_7128289441620152114" src="https://blogger.googleusercontent.com/img/a/AVvXsEiGsJ9PK2vS1JjEQQJZYoqmEYpF_LIqBgxCkTATi0_H_tfvQBnqklzT0OXzM_f2ZIEoCmDKSHaj_h6oNz3M2pDj3X-UoLNylDQBPBDTHLvB8QSGiAVsvLEkmHIs8sY7wZ0DqR09MJLkkktg2gHSUB0AA6LNa_2lqksYr5HCZ-lL8ZXQV6bmHYclGAbwhw=w640-h502" width="640" /></a><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;"> </span></span>I'll choose that default and press next. <o:p></o:p></p><p class="MsoNormal"><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; color: black; font-size: medium; padding: 0in;">Step 10 </span></b></span><span class="content-transcript-line"><b><o:p></o:p></b></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">You'll need to have a user account to connect to the server. </span></span>Here, the installer is creating a default user that's named Postgres. And you need to create a password for this user. <o:p></o:p></p><p class="MsoNormal"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEhQAlE0wF2XlRMHqQ4we39_lcuUTDcdSMJ61R0MiJxaj7MDeufIfZIBQXAmu0kKbqrY3aM3JR2LmiJ1tJOhcvqC_Itc5jyMm8jPADLz-LN1vn1_iqEiyF106u4YWdIULhgRbSF_XLlu2EQ4E9KPlKNHPtimyX-5A-RJDCjiiNGLQmoiupjNylm2sDfV5Q"><img alt="" border="0" height="502" id="BLOGGER_PHOTO_ID_7128289443878626610" src="https://blogger.googleusercontent.com/img/a/AVvXsEhQAlE0wF2XlRMHqQ4we39_lcuUTDcdSMJ61R0MiJxaj7MDeufIfZIBQXAmu0kKbqrY3aM3JR2LmiJ1tJOhcvqC_Itc5jyMm8jPADLz-LN1vn1_iqEiyF106u4YWdIULhgRbSF_XLlu2EQ4E9KPlKNHPtimyX-5A-RJDCjiiNGLQmoiupjNylm2sDfV5Q=w640-h502" width="640" /></a><span class="content-transcript-line"><o:p></o:p></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">You can type in whatever password you'd like. </span></span>Just make sure that you remember it moving forward. This user account is going to be an administrator-level account. So this user will have permission to do anything on the server. <span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">Using this, you can create additional user accounts </span></span>to control access to the stored data in Postgres. Once you've typed in the password and retyped the same password, press the next button. <o:p></o:p></p><p class="MsoNormal"><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; color: black; font-size: medium; padding: 0in;">Step 11</span></b></span><span class="content-transcript-line"><b><o:p></o:p></b></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">The default port that Postgres will communicate on is 5432. </span></span><o:p></o:p></p><p class="MsoNormal"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgpoM8JnTJfDWm2FnUhQGHhiQMcPh3vxiOaCFci_Rc2__JQJUXA_L90UnUwKdDhSio0C3pJc-PGxLvAYgQC5NpfN4KmzrIRVYCZi6sRiUS9qNCbdtXlYHVjA7KXBO-4gXXNhbF8BKxYieZQ57y6WbYbuQVeFdicORqlY0kAApFbybGVUxcVIG9DXMQFpg"><img alt="" border="0" height="502" id="BLOGGER_PHOTO_ID_7128289447628123650" src="https://blogger.googleusercontent.com/img/a/AVvXsEgpoM8JnTJfDWm2FnUhQGHhiQMcPh3vxiOaCFci_Rc2__JQJUXA_L90UnUwKdDhSio0C3pJc-PGxLvAYgQC5NpfN4KmzrIRVYCZi6sRiUS9qNCbdtXlYHVjA7KXBO-4gXXNhbF8BKxYieZQ57y6WbYbuQVeFdicORqlY0kAApFbybGVUxcVIG9DXMQFpg=w640-h502" width="640" /></a><span class="content-transcript-line"><o:p></o:p></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">You'll just leave that there and press next. </span></span><o:p></o:p></p><p class="MsoNormal"><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; color: black; font-size: medium; padding: 0in;">Step 12</span></b></span><span class="content-transcript-line"><b><o:p></o:p></b></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">On this screen, you get to choose a default location.<u> </u></span></span>Once again, I'll leave this as the default locale and press next. <o:p></o:p></p><p class="MsoNormal"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEiIuaDTZlQ08DzuLFfgrO6HS2MDt0mZra2oZJBiqa5lMAl3FIjI61CfZjlJXw01rL-aoh93GAdNohW1hxyC9XbqFj18JvXTYe_df_pJ95G_FGGxqlx5MLShVaq7z9CmPCF3qE4x9UaP-nbLJVqPxsuiuyjcq7dbaV_BjGQfcmrmTclVnmOvghRVELxTDw"><img alt="" border="0" height="502" id="BLOGGER_PHOTO_ID_7128289447413100098" src="https://blogger.googleusercontent.com/img/a/AVvXsEiIuaDTZlQ08DzuLFfgrO6HS2MDt0mZra2oZJBiqa5lMAl3FIjI61CfZjlJXw01rL-aoh93GAdNohW1hxyC9XbqFj18JvXTYe_df_pJ95G_FGGxqlx5MLShVaq7z9CmPCF3qE4x9UaP-nbLJVqPxsuiuyjcq7dbaV_BjGQfcmrmTclVnmOvghRVELxTDw=w640-h502" width="640" /></a><span class="content-transcript-line"><o:p></o:p></span></p><p class="MsoNormal"><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; color: black; font-size: medium; padding: 0in;">Step 13</span></b></span><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></b></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">Now the installer will give me an installation summary. </span></span><o:p></o:p></p><p class="MsoNormal"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEjgNzmktG94PVbOiSgaFooE2n4PmD7XlyzxSp2NR1u9AyhhEBk_GpRmgitHqM_VQ7lLqAzCU3niQWhvMCo1lmz-t7T3IUdgex0U6REt1-Ew9nYa8j1fiDHy9D_VX9-zY8pxaSApWHCJKLseRKhbBSMrVj3loc8jS_Dgi_rhn-kRIAgeoj-cUuiDUtrjOA"><img alt="" border="0" height="502" id="BLOGGER_PHOTO_ID_7128289454334363778" src="https://blogger.googleusercontent.com/img/a/AVvXsEjgNzmktG94PVbOiSgaFooE2n4PmD7XlyzxSp2NR1u9AyhhEBk_GpRmgitHqM_VQ7lLqAzCU3niQWhvMCo1lmz-t7T3IUdgex0U6REt1-Ew9nYa8j1fiDHy9D_VX9-zY8pxaSApWHCJKLseRKhbBSMrVj3loc8jS_Dgi_rhn-kRIAgeoj-cUuiDUtrjOA=w640-h502" width="640" /></a><span class="content-transcript-line"><o:p></o:p></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">I'll press the next button and the next one more time </span></span>to install the software. <o:p></o:p></p><p class="MsoNormal"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEixwtw7I18kZ6rvzkFcvXWul3wvVdrGDwY3ymdT0LbE_7JHX3hLXU4gDmhZAxiADT3DfscD9oCaxYGa9Hzezl09Q7zvyhpqVgvMnAYYN5pR7mJF3B4Gv1jq6UjW-0QA-1ABWF5hbWcOwZk4IVdOrVVsZzI4PymSpR4B3Eh5hhroEUSCAFU5IPXRGaKIcg"><img alt="" border="0" height="502" id="BLOGGER_PHOTO_ID_7128289457085393506" src="https://blogger.googleusercontent.com/img/a/AVvXsEixwtw7I18kZ6rvzkFcvXWul3wvVdrGDwY3ymdT0LbE_7JHX3hLXU4gDmhZAxiADT3DfscD9oCaxYGa9Hzezl09Q7zvyhpqVgvMnAYYN5pR7mJF3B4Gv1jq6UjW-0QA-1ABWF5hbWcOwZk4IVdOrVVsZzI4PymSpR4B3Eh5hhroEUSCAFU5IPXRGaKIcg=w640-h502" width="640" /></a><span class="content-transcript-line"><o:p></o:p></span></p><p class="MsoNormal"><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;"><br /><span style="font-size: medium;">Step 14</span></span></b></span><span class="content-transcript-line"><b><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></b></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">When that finishes, the database server </span></span>and client applications have been installed. <o:p></o:p></p><p class="MsoNormal"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEg8XFtDZH4NF0lPVBwxH6a68yNklK5Hrqap_8LJ887ns6Ek6--ECrw-pikL2H2UsjFBUK-DuDIEqRryL4nmo4f1aidJUXe45J2jmTuLimUhxG7PvVX_AWohKGOS7odXXb7uU5Ck3uZ-YSeVv5rPvEr4Kd5Zkmlu6QD40ZpByrPw0pFD6sluEeljDqVB6g"><img alt="" border="0" height="502" id="BLOGGER_PHOTO_ID_7128289455856053650" src="https://blogger.googleusercontent.com/img/a/AVvXsEg8XFtDZH4NF0lPVBwxH6a68yNklK5Hrqap_8LJ887ns6Ek6--ECrw-pikL2H2UsjFBUK-DuDIEqRryL4nmo4f1aidJUXe45J2jmTuLimUhxG7PvVX_AWohKGOS7odXXb7uU5Ck3uZ-YSeVv5rPvEr4Kd5Zkmlu6QD40ZpByrPw0pFD6sluEeljDqVB6g=w640-h502" width="640" /></a><span class="content-transcript-line"><b><o:p></o:p></b></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">Now, if you can also choose to install the Stack Builder application, </span></span>you can turn off this checkbox here. You don't need to run Stack Builder when you finish out of this wizard, and I'll uncheck this checkbox and press the finish button. <o:p></o:p></p><p class="MsoNormal"><span class="content-transcript-line"><o:p> </o:p></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">All done. It is time to test the installation, and you will find the management application to connect with the server.</span></span><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">Now you can go into my start menu, and I'm going to scroll down and find the new folder </span></span>that was just added for PostgreSQL <version>. Inside of here, you have a couple of applications.<span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></span></p><p class="MsoNormal"><o:p> </o:p></p><p class="MsoNormal"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEiO07cnVO909HDG3hF-l7_R1BBqFPuI5q5Y2x1Ez0tSccWUJF0C00MWzmeA0TJhD2Nrim4P-qSFLicCgcHHqC0ogWwt--5-Ojh_ZfEIp_HNlojyioWIqA4wdbMmr7Joy2cN6Xsu7U-5t2ieSiTlxsLiejH4RpB8emYskviEtVO8McY-u7pdADIrX36EwA"><img alt="" border="0" height="640" id="BLOGGER_PHOTO_ID_7128289462637031794" src="https://blogger.googleusercontent.com/img/a/AVvXsEiO07cnVO909HDG3hF-l7_R1BBqFPuI5q5Y2x1Ez0tSccWUJF0C00MWzmeA0TJhD2Nrim4P-qSFLicCgcHHqC0ogWwt--5-Ojh_ZfEIp_HNlojyioWIqA4wdbMmr7Joy2cN6Xsu7U-5t2ieSiTlxsLiejH4RpB8emYskviEtVO8McY-u7pdADIrX36EwA=w600-h640" width="600" /></a><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p> </o:p></span></span></p><p class="MsoNormal"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;"> </span></span>I am only interested in below two applications:<span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></span></p><ol start="1" style="margin-top: 0in;" type="1"><li class="MsoListParagraphCxSpFirst" style="margin-left: 0in; mso-add-space: auto; mso-list: l0 level1 lfo2;"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">pgAdmin 4 - This is a graphical user interface for Postgres </span></span>that'll run inside your web browser. <o:p></o:p></li><li class="MsoListParagraphCxSpLast" style="margin-left: 0in; mso-add-space: auto; mso-list: l0 level1 lfo2;"><span class="content-transcript-line"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">SQL Shell or PSQL - This is a command line tool popular with programmers. </span></span><span class="content-transcript-line"><br /></span><br />You'll find the PostgreSQL <version> folder on macOS inside your applications folder. And inside, there will be the same pgAdmin and PSQL applications. So now you have Postgres Server and a couple of client applications for us to work with.<span class="content-transcript-line"><o:p></o:p></span></li></ol><p class="MsoNormal"><o:p> </o:p><span style="background-color: white;">Open the SQL Shell, a command-line window, </span><span class="content-transcript-line">and start the login process.</span></p><p class="MsoNormal"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">You need to know some connection details to log into a Postgres server. </span><o:p></o:p></p><p class="MsoNormal"><b><span style="background: white; border: 1pt none windowtext; color: black; font-size: medium; padding: 0in;">Server IP:</span></b><b><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></b></p><p class="MsoNormal"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">First, it asks for the server location. If you're in a typical office environment where the Postgres server is running on a centralized computer, then you'll need the IP address of that machine. In our case, we're running the server and client on the same physical machine. So we can use the word localhost instead. </span><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></p><p class="MsoNormal"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">You can either type that in or press Enter, and localhost, the default indicated by the text in square brackets, will be used instead. I'll leave this blank and press Enter to enter in localhost. </span><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></p><p class="MsoNormal"><b><span style="background: white; border: 1pt none windowtext; color: black; font-size: medium; padding: 0in;">Database:</span></b><b><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></b></p><p class="MsoNormal"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">Next, it asks you which database you want to connect to. Each Postgres server can hold many different databases. If you have just installed the server, it is brand new, and there's just one database called Postgres, so I'll log into that one. Again, you can press Enter to accept the default value of Postgres. </span><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></p><p class="MsoNormal"><b><span style="background: white; border: 1pt none windowtext; color: black; font-size: medium; padding: 0in;">Communication port:</span></b><b><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></b></p><p class="MsoNormal"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">Next, we need the communication port that the server is listening on. This was set up during the installation step but is typically left at the default of 5432. I'll press Enter to accept that value. <br /><b><br /><span style="font-size: medium;">User Name:</span></b></span><b><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></b></p><p class="MsoNormal"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">Then we need to provide the user account credentials. Again, during the installation, we created a superuser account named <b>Postgres</b>. So we'll use that. You will supply that username here if you've been assigned your own personal user account for your server. </span><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></p><p class="MsoNormal"><b><span style="background: white; border: 1pt none windowtext; color: black; font-size: medium; padding: 0in;">Password:</span></b><b><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></b></p><p class="MsoNormal"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">Finally, you have to enter the user's password. Again, we gave the Postgres user account a password during setup. So I hope that you remember what you filled in during that step. Go ahead and type it in now. When you type, it will not appear on the screen, so just type it out and press Enter when you're done.</span><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></p><p class="MsoNormal"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">If everything was filled in correctly, you should be connected to the Postgres server, and the command prompt will change. Now we can start sending commands to the server.</span><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></p><p class="MsoNormal"><a href="https://blogger.googleusercontent.com/img/a/AVvXsEgmL5yVen0I4B4VT2kYudFL180oL1o1WK-kyHtfQzcit_aKDM86YziTnr7MMtRZPqMPD2CJQq6l4xMbUo9iwQZJmQV8Ykk5a4ZT1eygRyRIGJSlFfMANXfPiGRmmo_PkOZQ7Qycp6ggxWtezIVg9RiGn3QCtPsT5w-BH1ssDXd8Gm4vVT1N_3WWtcV1Kw"><img alt="" border="0" height="336" id="BLOGGER_PHOTO_ID_7128289465501121762" src="https://blogger.googleusercontent.com/img/a/AVvXsEgmL5yVen0I4B4VT2kYudFL180oL1o1WK-kyHtfQzcit_aKDM86YziTnr7MMtRZPqMPD2CJQq6l4xMbUo9iwQZJmQV8Ykk5a4ZT1eygRyRIGJSlFfMANXfPiGRmmo_PkOZQ7Qycp6ggxWtezIVg9RiGn3QCtPsT5w-BH1ssDXd8Gm4vVT1N_3WWtcV1Kw=w640-h336" width="640" /></a><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></p><p class="MsoNormal"><b><span style="background: white; border: 1pt none windowtext; color: black; font-size: large; padding: 0in;">Conclusion</span></b><b><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></b></p><p class="MsoNormal"><span style="background: white; border: 1pt none windowtext; color: black; padding: 0in;">We have successfully installed PostgreSQL with these simple steps.</span><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p></o:p></span></p><p class="MsoNormal"><span style="background: white; border: 1pt none windowtext; padding: 0in;"><o:p> </o:p></span></p><p class="MsoNormal"><o:p> </o:p></p></div>Niranjan Singhhttp://www.blogger.com/profile/10098432252247322623noreply@blogger.com0tag:blogger.com,1999:blog-2999456122062603029.post-57951202652679242152022-08-04T01:41:00.001-07:002023-07-31T00:27:43.751-07:00How to Create a JavaScript Library/Framework?<p> </p><h3 id="introduction" style="background-color: white; color: #222222; font-family: Domine, Arial, Verdana, sans-serif; font-size: 24px; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;">Introduction</h3><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">This article will teach you how to Create a Javascript Library or Framework.</p><h3 id="creating-a-javascript-library" style="background-color: white; color: #222222; font-family: Domine, Arial, Verdana, sans-serif; font-size: 24px; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;">Creating a JavaScript library</h3><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">Library Name: Greeter</p><ul style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin-bottom: 10px; margin-top: 0px;"><li>When given a first name, last name, and options language, it generates formal and informal greetings.</li><li>Supports English and Spanish languages.</li><li>Reusable library/framework.</li><li>Easy to type ‘G$()’ structure. -Support jQuery</li></ul><h5 id="structure-safe-code" style="background-color: white; color: #222222; font-family: Domine, Arial, Verdana, sans-serif; font-size: 20px; line-height: 1.1; margin-bottom: 10px; margin-top: 0px;"><br />Structure Safe code<br /><br /></h5><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;"><strong><em>HTML</em></strong></p><div class="language-html highlighter-rouge" style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px;"><div class="highlight"><pre class="highlight" style="background-color: whitesmoke; border-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.42857; margin-bottom: 5px; margin-top: 0px; overflow-wrap: break-word; overflow-x: auto; padding: 9.5px; white-space: pre-wrap; word-break: break-all;"><code style="background-color: transparent; border-radius: 4px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 11.7px; padding: 0px;"><span class="nt"><html></span>
<span class="nt"><head></span>
<span class="nt"></head></span>
<span class="nt"><body></span>
<span class="nt"><script </span><span class="na">src=</span><span class="s">"scripts/jquery-3.6.0.js"</span><span class="nt">></script></span>
<span class="nt"><script </span><span class="na">src=</span><span class="s">"scripts/greetr.js"</span><span class="nt">></script></span>
<span class="nt"><script </span><span class="na">src=</span><span class="s">"scripts/app.js"</span><span class="nt">></script></span>
<span class="nt"></body></span>
<span class="nt"></html></span>
</code></pre></div></div><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">Include jQuery first to enable the jQuery support.</p><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;"><strong><em>greetr.js</em></strong></p><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">We require a global variable window and jQuery. Set up an IIFE function by passing the windows and the jQuery function.</p><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">Now create an IIFE function to start with.</p><div class="language-javascript highlighter-rouge" style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px;"><div class="highlight"><pre class="highlight" style="background-color: whitesmoke; border-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.42857; margin-bottom: 5px; margin-top: 0px; overflow-wrap: break-word; overflow-x: auto; padding: 9.5px; white-space: pre-wrap; word-break: break-all;"><code style="background-color: transparent; border-radius: 4px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 11.7px; padding: 0px;">
<span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nb">global</span><span class="p">,</span> <span class="nx">$</span><span class="p">)</span> <span class="p">{</span>
<span class="p">}(</span><span class="nb">window</span><span class="p">,</span> <span class="nx">jQuery</span><span class="p">));</span>
</code></pre></div></div><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">Now, this is safe to use in any of the applications and ready to use.</p><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">The next step is to set up the greeter object and the alias similar to jQuery $. You can review code the code of the jQuery library understands the safe entry method to work with any library.</p><div class="language-javascript highlighter-rouge" style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px;"><div class="highlight"><pre class="highlight" style="background-color: whitesmoke; border-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.42857; margin-bottom: 5px; margin-top: 0px; overflow-wrap: break-word; overflow-x: auto; padding: 9.5px; white-space: pre-wrap; word-break: break-all;"><code style="background-color: transparent; border-radius: 4px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 11.7px; padding: 0px;">
<span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nb">global</span><span class="p">,</span> <span class="nx">$</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">Greetr</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">firstname</span><span class="p">,</span> <span class="nx">lastName</span><span class="p">,</span> <span class="nx">language</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="k">new</span> <span class="nx">Greetr</span><span class="p">.</span><span class="nx">init</span><span class="p">(</span><span class="nx">firstName</span><span class="p">,</span> <span class="nx">lastName</span><span class="p">,</span> <span class="nx">language</span><span class="p">);</span>
<span class="p">};</span>
<span class="c1">// You can create your properties and function here</span>
<span class="nx">Greetr</span><span class="p">.</span><span class="nx">prototype</span> <span class="o">=</span> <span class="p">{};</span>
<span class="nx">Greetr</span><span class="p">.</span><span class="nx">init</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">firstName</span><span class="p">,</span> <span class="nx">lastName</span><span class="p">,</span> <span class="nx">language</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nb">self</span> <span class="o">=</span> <span class="k">this</span><span class="p">;</span>
<span class="nb">self</span><span class="p">.</span><span class="nx">firstName</span> <span class="o">=</span> <span class="nx">firstName</span> <span class="o">||</span> <span class="dl">""</span><span class="p">;</span>
<span class="nb">self</span><span class="p">.</span><span class="nx">lastName</span> <span class="o">=</span> <span class="nx">lastName</span> <span class="o">||</span> <span class="dl">""</span><span class="p">;</span>
<span class="nb">self</span><span class="p">.</span><span class="nx">language</span> <span class="o">=</span> <span class="nx">language</span> <span class="o">||</span> <span class="dl">"</span><span class="s2">en</span><span class="dl">"</span><span class="p">;</span>
<span class="p">};</span>
<span class="nx">Greetr</span><span class="p">.</span><span class="nx">init</span><span class="p">.</span><span class="nx">prototype</span> <span class="o">=</span> <span class="nx">Greetr</span><span class="p">.</span><span class="nx">prototype</span><span class="p">;</span>
<span class="c1">//Set the alias</span>
<span class="nb">global</span><span class="p">.</span><span class="nx">Greetr</span> <span class="o">=</span> <span class="nb">global</span><span class="p">.</span><span class="nx">G$</span> <span class="o">=</span> <span class="nx">Greetr</span><span class="p">;</span>
<span class="p">}(</span><span class="nb">window</span><span class="p">,</span> <span class="nx">jQuery</span><span class="p">));</span>
</code></pre></div></div><h4 id="adding-language-support" style="background-color: white; color: #222222; font-family: Domine, Arial, Verdana, sans-serif; font-size: 22px; line-height: 1.1; margin-bottom: 10px; margin-top: 0px;"><br />Adding Language support<br /><br /></h4><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">Now we set up the language support for English and Spanish. Along with this</p><pre style="background-color: whitesmoke; border-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.42857; margin-bottom: 5px; margin-top: 0px; overflow-wrap: break-word; overflow-x: auto; padding: 9.5px; white-space: pre-wrap; word-break: break-all;"><code class="language-JavaScript" style="background-color: transparent; border-radius: 4px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 11.7px; padding: 0px;">(function (global, $) {
var Greetr = function (firstname, lastName, language) {
return new Greetr.init(firstName, lastName, language);
};
var supportedLanguages = ["en", "es"];
var greetings = {
en: "Hello",
es: "Hola",
};
var formalGreetings = {
en: "Greetings",
es: "Saludos",
};
var logMessages = {
en: "Logged In",
es: "iniciar la sesión",
};
// You can create your properties and function here
Greetr.prototype = {
fullName: function () {
return this.firstName + " " + this.lastName;
},
validate: function () {
if (supportedLanguages.indexOf(this.language) === -1) {
throw "Invalid language";
}
},
greeting: function () {
return greetings[this.language] + " " + this.firstName + "!";
},
formalGreetings: function () {
return formalGreetings[this.language] + " " + this.fullName() + "!";
},
greet: function (formal) {
var msg;
//if undefined or null, it will be coerced to 'false.'
if (formal) {
msg = this.formalGreetings();
} else {
msg = this.greeting();
}
if (console) {
console.log(msg);
}
//'this' refers to the calling object at the execution time
// makes the method chainable
return this;
},
log: function () {
if (console) {
console.log(logMessages[this.language] + ": " + this.fullName());
}
return this;
},
setLanguage: function (lang) {
this.language = lang;
this.validate();
return this;
},
};
Greetr.init = function (firstName, lastName, language) {
var self = this;
self.firstName = firstName || "";
self.lastName = lastName || "";
self.language = language || "en";
};
Greetr.init.prototype = Greetr.prototype;
//Set the alias
global.Greetr = global.G$ = Greetr;
}(window, jQuery));
</code></pre><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;"><strong><em><br />Calling the library in the application</em></strong></p><div class="language-javascript highlighter-rouge" style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px;"><div class="highlight"><pre class="highlight" style="background-color: whitesmoke; border-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.42857; margin-bottom: 5px; margin-top: 0px; overflow-wrap: break-word; overflow-x: auto; padding: 9.5px; white-space: pre-wrap; word-break: break-all;"><code style="background-color: transparent; border-radius: 4px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 11.7px; padding: 0px;"><span class="kd">var</span> <span class="nx">g</span> <span class="o">=</span> <span class="nx">G$</span><span class="p">(</span><span class="dl">"</span><span class="s2">Niranjan</span><span class="dl">"</span><span class="p">,</span> <span class="dl">"</span><span class="s2">Singh</span><span class="dl">"</span><span class="p">);</span>
<span class="c1">//Chained behavior and call to display greetings</span>
<span class="nx">g</span><span class="p">.</span><span class="nx">greet</span><span class="p">().</span><span class="nx">greet</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
<span class="c1">//Change the language and then greet</span>
<span class="nx">g</span><span class="p">.</span><span class="nx">greet</span><span class="p">().</span><span class="nx">setLang</span><span class="p">(</span><span class="dl">'</span><span class="s1">es</span><span class="dl">'</span><span class="p">).</span><span class="nx">greet</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
</code></pre></div></div><h4 style="background-color: white; color: #222222; font-family: Domine, Arial, Verdana, sans-serif; font-size: 22px; line-height: 1.1; margin-bottom: 10px; margin-top: 0px;"><br />Adding jQuery support<br /><br /></h4><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">We need to add jQuery support and provide the functionality to give the id to Greetr library for updating the element text.</p><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">Update the HTML page with the below text to enable/demonstrate the jQuery incorporation.</p><div class="language-html highlighter-rouge" style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px;"><div class="highlight"><pre class="highlight" style="background-color: whitesmoke; border-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.42857; margin-bottom: 5px; margin-top: 0px; overflow-wrap: break-word; overflow-x: auto; padding: 9.5px; white-space: pre-wrap; word-break: break-all;"><code style="background-color: transparent; border-radius: 4px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 11.7px; padding: 0px;">
<span class="nt"><html></span>
<span class="nt"><head></span>
<span class="nt"></head></span>
<span class="nt"><body></span>
<span class="nt"><div</span> <span class="na">id=</span><span class="s">"logindiv"</span><span class="nt">></span>
<span class="nt"><select</span> <span class="na">id=</span><span class="s">"lang"</span> <span class="na">div</span><span class="nt">></span>
<span class="nt"><option</span> <span class="na">value=</span><span class="s">"en"</span><span class="nt">></span>English<span class="nt"></option></span>
<span class="nt"><option</span> <span class="na">value=</span><span class="s">"es"</span><span class="nt">></span>Spanish<span class="nt"></option></span>
<span class="nt"></select></span>
<span class="nt"><input</span> <span class="na">type=</span><span class="s">"button"</span> <span class="na">name=</span><span class="s">"login"</span> <span class="na">id=</span><span class="s">"login"</span> <span class="na">value=</span><span class="s">"Login"</span><span class="nt">></span>
<span class="nt"></div></span>
<span class="nt"><h1</span> <span class="na">id=</span><span class="s">"greeting"</span><span class="nt">></h1></span>
<span class="nt"><script </span><span class="na">src=</span><span class="s">"scripts/jquery-3.6.0.js"</span><span class="nt">></script></span>
<span class="nt"><script </span><span class="na">src=</span><span class="s">"scripts/greetr.js"</span><span class="nt">></script></span>
<span class="nt"><script </span><span class="na">src=</span><span class="s">"scripts/app.js"</span><span class="nt">></script></span>
<span class="nt"></body></span>
<span class="nt"></html></span>
</code></pre></div></div><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">It requires changes in the Greetr library also. So add a new method called HTMLGreeting with a selector parameter.</p><div class="language-javascript highlighter-rouge" style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px;"><div class="highlight"><pre class="highlight" style="background-color: whitesmoke; border-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.42857; margin-bottom: 5px; margin-top: 0px; overflow-wrap: break-word; overflow-x: auto; padding: 9.5px; white-space: pre-wrap; word-break: break-all;"><code style="background-color: transparent; border-radius: 4px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 11.7px; padding: 0px;">
<span class="nx">HTMLGreeting</span><span class="p">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">selector</span><span class="p">,</span> <span class="nx">formal</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">$</span><span class="p">)</span> <span class="p">{</span>
<span class="k">throw</span> <span class="dl">"</span><span class="s2">jQuery not loaded</span><span class="dl">"</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">selector</span><span class="p">)</span> <span class="p">{</span>
<span class="k">throw</span> <span class="dl">"</span><span class="s2">Missing jQuery selector </span><span class="dl">"</span><span class="p">;</span>
<span class="p">}</span>
<span class="kd">var</span> <span class="nx">msg</span><span class="p">;</span>
<span class="c1">//if undefined or null, it will be coerced to 'false.'</span>
<span class="k">if</span> <span class="p">(</span><span class="nx">formal</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">msg</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">formalGreetings</span><span class="p">();</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="nx">msg</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">greeting</span><span class="p">();</span>
<span class="p">}</span>
<span class="nx">$</span><span class="p">(</span><span class="nx">selector</span><span class="p">).</span><span class="nx">html</span><span class="p">(</span><span class="nx">msg</span><span class="p">);</span>
<span class="k">return</span> <span class="k">this</span><span class="p">;</span>
<span class="p">},</span>
</code></pre></div></div><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">Below is the simple library/framework which we have developed. It could be referred to and used to create a library.</p><pre style="background-color: whitesmoke; border-radius: 4px; border: 1px solid rgb(204, 204, 204); color: #333333; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.42857; margin-bottom: 5px; margin-top: 0px; overflow-wrap: break-word; overflow-x: auto; padding: 9.5px; white-space: pre-wrap; word-break: break-all;"><code class="language-javaScript" style="background-color: transparent; border-radius: 4px; border: 0px; color: inherit; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 11.7px; padding: 0px;">(function (global, $) {
// 'new' an object
var Greetr = function (firstName, lastName, language) {
return new Greetr.init(firstName, lastName, language);
};
// hidden within the scope of the IIFE and never directly accessible
var supportedLanguages = ["en", "es"];
// informal greetings
var greetings = {
en: "Hello",
es: "Hola",
};
// formal greetings
var formalGreetings = {
en: "Greetings",
es: "Saludos",
};
// logger messages
var logMessages = {
en: "Logged In",
es: "iniciar la sesión",
};
// You can create your properties and function here
Greetr.prototype = {
fullName: function () {
return this.firstName + " " + this.lastName;
},
validate: function () {
if (supportedLanguages.indexOf(this.language) === -1) {
throw "Invalid language";
}
},
greeting: function () {
return greetings[this.language] + " " + this.firstName + "!";
},
formalGreetings: function () {
return formalGreetings[this.language] + " " + this.fullName() + "!";
},
greet: function (formal) {
var msg;
//if undefined or null, it will be coerced to 'false.'
if (formal) {
msg = this.formalGreetings();
} else {
msg = this.greeting();
}
if (console) {
console.log(msg);
}
//'this' refers to the calling object at the execution time
// makes the method chainable
return this;
},
log: function () {
if (console) {
console.log(logMessages[this.language] + ": " + this.fullName());
}
return this;
},
setLanguage: function (lang) {
this.language = lang;
this.validate();
return this;
},
HTMLGreeting: function (selector, formal) {
if (!$) {
throw "jQuery not loaded";
}
if (!selector) {
throw "Missing jQuery selector ";
}
var msg;
//if undefined or null it will be coerced to 'false'
if (formal) {
msg = this.formalGreetings();
} else {
msg = this.greeting();
}
$(selector).html(msg);
return this;
},
};
// the actual object is created here, allowing us to 'new' an object without calling 'new'
Greetr.init = function (firstName, lastName, language) {
var self = this;
self.firstName = firstName || "";
self.lastName = lastName || "";
self.language = language || "en";
self.validate();
};
// trick borrowed from jQuery so we don't have to use the 'new' keyword
Greetr.init.prototype = Greetr.prototype;
//Set the alias, attach the Greetr to the global object and provide a shorthand '$G' for the ease our poor fingers
global.Greetr = global.G$ = Greetr;
}(window, jQuery));
</code></pre><h3 id="conclusion" style="background-color: white; color: #222222; font-family: Domine, Arial, Verdana, sans-serif; font-size: 24px; line-height: 1.1; margin-bottom: 10px; margin-top: 10px;">Conclusion</h3><p style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">We have created a small library that supports the jQuery framework also. We can create an extensive library or framework by following the same pattern. The best way to learn this is by reviewing the existing open source libraries and frameworks, e.g., jQuery.</p>Niranjan Singhhttp://www.blogger.com/profile/10098432252247322623noreply@blogger.com0tag:blogger.com,1999:blog-2999456122062603029.post-76485014477942724732022-02-16T20:49:00.002-08:002022-02-16T20:56:12.122-08:00How to resolve Global Exception Logger with Dependency Injection in ASP.NET Web API?<h4>Introduction</h4>
<p>
In this article, you will learn how to resolve Global Exception Logger with dependency injection in ASP.NET Web API using Autofac.</p>
<h4>How to resolve Global Exception Logger with dependency injection</h4>
<p><b>Step 1:</b> Create the custom exception logger by inheriting the IExceptionLogger interface to write your custom logging logic.</p>
<pre class="brush: csharp;">
/// <summary>
/// The main class <c>GlobalExceptionLogger</c>.
/// Handles the exception logging requests.
/// </summary>
public class GlobalExceptionLogger : IExceptionLogger
{
/// <summary>
///
/// </summary>
public ILogger Logger { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="GlobalExceptionLogger"/> class.
/// </summary>
public GlobalExceptionLogger()
{
Logger = NullLogger.Instance;
}
/// <summary>
/// Logs the exception.
/// </summary>
/// <param name="context">The exception context.</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task LogAsync(ExceptionLoggerContext context, CancellationToken cancellationToken)
{
var ex = context.Exception;
string message = $"{ex.Message}--{ex.Source}\n{ex.StackTrace}\n{ex.TargetSite}\n";
await Task.Run(() =>
{
Logger.Error(ex, message);
});
}
}
</pre>
<p><b>Step 2:</b> Register your custom exception logger class in the Autofac container to resolve it through dependency injection.</p>
<pre class="brush: csharp;">
/// <summary>
/// The main class <c>AutofacConfig</c>.
/// Provides Autofac DI configuration of the API.
/// </summary>
public static class AutofacConfig
{
#region Autofac Container
private static Lazy<IContainer> builder =
new Lazy<IContainer>(() =>
{
var autofacbuilder = new ContainerBuilder();
RegisterTypes(autofacbuilder);
return autofacbuilder.Build();
});
/// <summary>
/// Configured Autofac Container.
/// </summary>
public static IContainer Container => builder.Value;
#endregion
/// <summary>
/// Registers the type mappings with the autofac container builder.
/// </summary>
/// <param name="builder">The autofac container builder to configure.</param>
/// <remarks>
/// </remarks>
public static void RegisterTypes(ContainerBuilder builder)
{
string baseDirectoryPath = AppDomain.CurrentDomain.BaseDirectory + "bin";
if (!Directory.Exists(baseDirectoryPath))
baseDirectoryPath = AppDomain.CurrentDomain.BaseDirectory;
builder.RegisterModule(new LoggingModule());
builder.RegisterModule(new FileStoreModule());
//builder.RegisterModule(new CloudJobManager.CloudJobManagerModule());
builder.RegisterApiControllers(Assembly.GetExecutingAssembly()).InstancePerRequest();
//builder.RegisterType<GlobalExceptionLogger>().InstancePerLifetimeScope();
var assemblies = Directory.EnumerateFiles(baseDirectoryPath, "*.dll", SearchOption.TopDirectoryOnly)
.Where(filePath => Path.GetFileName(filePath).StartsWith("MyApp"))
.Select(Assembly.LoadFrom).Where(assemblyType =>
(assemblyType.FullName.StartsWith("MyApp") && !assemblyType.FullName.Contains("MyApp.Framework") &&
!assemblyType.FullName.Contains("MyApp.Reporting.API")
)).ToArray();
builder.RegisterAssemblyTypes(assemblies)
.AsImplementedInterfaces().InstancePerLifetimeScope();
builder.RegisterType<GlobalExceptionLogger>().AsSelf().AsImplementedInterfaces();
builder.RegisterType<GenericExceptionHandler>().AsSelf().AsImplementedInterfaces();
builder.RegisterType<ReportService>().As<IReportService>().InstancePerRequest();
}
}
</pre>
<p><b>Step 3:</b> Replace the custom exception logger in the HttpConfiguration services to use it in the place of the default ASP.NET exception logger.</p>
<pre class="brush: csharp;">
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
config.DependencyResolver = new AutofacWebApiDependencyResolver(AutofacConfig.Container);
// Web API configuration and services
//config.Services.Replace(typeof(IExceptionLogger), new GlobalExceptionLogger());
//config.Services.Replace(typeof(IExceptionHandler), new GenericExceptionHandler());
// Inject our exception logger and handler
config.Services.Replace(typeof(IExceptionHandler), config.DependencyResolver.GetService(typeof(GenericExceptionHandler)));
config.Services.Replace(typeof(IExceptionLogger), config.DependencyResolver.GetService(typeof(GlobalExceptionLogger)));
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
</pre>
<h4>Conclusion</h4>
<p>
Whenever an unhandled error occurs then you have a chance to log it. The information regarding the can be stored somewhere for review. There you can write the issue to a log or write custom logic.</p>Niranjan Singhhttp://www.blogger.com/profile/10098432252247322623noreply@blogger.com0tag:blogger.com,1999:blog-2999456122062603029.post-67669670812424993362021-07-22T21:35:00.001-07:002022-02-16T20:37:48.721-08:00Azure DevOps Server - How to fix indexing isn't working issue?<p> </p><h5 class="code-line" data-line="10" id="introduction" style="background-color: white; color: #222222; font-family: Domine, Arial, Verdana, sans-serif; line-height: 1.1; margin-bottom: 10px; margin-top: 0px;"><span style="font-size: small;">Introduction</span></h5><p class="code-line" data-line="12" style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">In this article, you will learn how to fix the Azure DevOps Server indexing issues.</p><h5 style="background-color: white; color: #222222; font-family: Domine, Arial, Verdana, sans-serif; line-height: 1.1; margin-bottom: 10px; margin-top: 0px;"><span style="font-size: small;">How to fix indexing isn't working, or is in progress issue</span></h5><p class="code-line" data-line="18" style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">In our scenario, the Search was not working and was completely broken. Nobody was able to search in the code and work items.</p><p class="code-line" data-line="22" style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">To fix this, we have referenced the Microsoft documentation - <a data-href="https://docs.microsoft.com/en-us/azure/devops/project/search/manage-search?view=azure-devops-2020" href="https://docs.microsoft.com/en-us/azure/devops/project/search/manage-search?view=azure-devops-2020" style="color: #0269c8; text-decoration-line: none; transition: color 0.3s ease 0s;" title="https://docs.microsoft.com/en-us/azure/devops/project/search/manage-search?view=azure-devops-2020">Manage Search indexing</a> to create the search index again.</p><p class="code-line" data-line="24" style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">Below is the step to fix the search indexing:</p><ul style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin-bottom: 10px; margin-top: 0px;"><li class="code-line" data-line="25">Download the scripts from the <a data-href="https://github.com/Microsoft/Code-Search" href="https://github.com/Microsoft/Code-Search" style="color: #0269c8; text-decoration-line: none; transition: color 0.3s ease 0s;" title="https://github.com/Microsoft/Code-Search">Code-Search GitHub repository</a> on the server.</li><li class="code-line" data-line="26">Extract the zip somewhere and open the <em>Powershell</em> in <em>Administrative</em> mode.</li><li class="code-line" data-line="27">Change the directory to your Azure DevOps Server version. I have to reindex the entire collection.</li><li class="code-line" data-line="28">Now execute the script <i>TriggerCollectionIndexing.ps1</i> to reindex the collection but first, you need to change the policy to execute the command<br /><br /><code class="ps functions" style="background: none; border-radius: 0px; border: 0px; box-sizing: content-box; color: deeppink; float: none; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; height: auto; inset: auto; line-height: 1.1em; margin: 0px; min-height: auto; outline: 0px; overflow: visible; padding: 0px; position: static; vertical-align: baseline; white-space: nowrap; width: auto;">Set-ExecutionPolicy</code><span style="color: black; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; white-space: pre;"> </span><code class="ps color1" style="background: none; border-radius: 0px; border: 0px; box-sizing: content-box; color: grey; float: none; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; height: auto; inset: auto; line-height: 1.1em; margin: 0px; min-height: auto; outline: 0px; overflow: visible; padding: 0px; position: static; vertical-align: baseline; white-space: nowrap; width: auto;">-Scope</code><span style="color: black; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; white-space: pre;"> </span><code class="ps keyword" style="background: none; border-radius: 0px; border: 0px; box-sizing: content-box; color: #006699; float: none; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-weight: bold; height: auto; inset: auto; line-height: 1.1em; margin: 0px; min-height: auto; outline: 0px; overflow: visible; padding: 0px; position: static; vertical-align: baseline; white-space: nowrap; width: auto;">Process</code><span style="color: black; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; white-space: pre;"> </span><code class="ps color1" style="background: none; border-radius: 0px; border: 0px; box-sizing: content-box; color: grey; float: none; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; height: auto; inset: auto; line-height: 1.1em; margin: 0px; min-height: auto; outline: 0px; overflow: visible; padding: 0px; position: static; vertical-align: baseline; white-space: nowrap; width: auto;">-ExecutionPolicy</code><span style="color: black; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; white-space: pre;"> </span><code class="ps plain" style="background: none; border-radius: 0px; border: 0px; box-sizing: content-box; color: black; float: none; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; height: auto; inset: auto; line-height: 1.1em; margin: 0px; min-height: auto; outline: 0px; overflow: visible; padding: 0px; position: static; vertical-align: baseline; white-space: nowrap; width: auto;">Bypass</code></li></ul><div style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px;"></div><ul style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin-bottom: 10px; margin-top: 0px;"><li class="code-line" data-line="32">After that run the <code style="background-color: #f9f2f4; border-radius: 4px; color: #c7254e; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 13.5px; padding: 2px 4px; white-space: nowrap;">TriggerCollectionIndexing.ps1</code> file. You need to enter the SQL server instance name of the Azure DevOps Server, Collection database name, Configuration database name, and the entities to reindex.</li></ul><p class="code-line" data-line="36" style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;"><img alt="" data-src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgevJLWoHgJRpuhv3h6G0KbeL2K2ub3_AkWxJcRoz4DWYCJBtEg3Y1PLJdOgGySAEc5uULgCfBNxQX_JFSz8-ECyrWBungyP8Z0-o5J99jiAMpDfH5GNNR4N9BD2h1eAGRjEkkDIlSqQJVz/w640-h374/Azure-DevOps-Search-Index-Fix.jpg" id="image-hash--911280253" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgevJLWoHgJRpuhv3h6G0KbeL2K2ub3_AkWxJcRoz4DWYCJBtEg3Y1PLJdOgGySAEc5uULgCfBNxQX_JFSz8-ECyrWBungyP8Z0-o5J99jiAMpDfH5GNNR4N9BD2h1eAGRjEkkDIlSqQJVz/w640-h374/Azure-DevOps-Search-Index-Fix.jpg" style="border: 0px; max-width: 100%;" /></p><h5 style="background-color: white; color: #222222; font-family: Domine, Arial, Verdana, sans-serif; line-height: 1.1; margin-bottom: 10px; margin-top: 0px;"><span style="font-size: small;">Conclusion</span></h5><p class="code-line" data-line="40" style="background-color: white; color: #222222; font-family: "Open Sans", Helvetica, Arial, sans-serif; font-size: 15px; margin: 0px 0px 15px;">Search indexing is an important feature in the Azure DevOps Server, use the scripts to get the status of the search indexing and fix the issues.</p>Niranjan Singhhttp://www.blogger.com/profile/10098432252247322623noreply@blogger.com0