Posts

Rebalancer for RabbitMQ, SQS, etc.

Image
Rebalancer (forked from Jack Vanlightly  and improved)      Create Kafka style consumer groups in other technologies. Rebalancer was born of the need for consumer groups with RabbitMQ. But Rebalancer is completely technology agnostic and will balance activity over any group of resources across a group of participating nodes. Use cases Create Kafka-like "consumer groups" with messaging technologies like RabbitMQ, SQS, etc. Consume a group of resources such as file shares, FTPs, S3 buckets between the instances of a scaled out application. Single Active-Consumer / Active-Backup Create an application cluster that consumes a single resource in a highly available manner. The cluster leader (Coordinator) consumes the single resource and the slaves (Followers) remain idle in backup in case the leader dies. Balancing assignment of multiple resources over multiples nodes Consuming from a single resource with backup nodes in case of failure Concepts ...

Poison message handling RabbitMQ

Image
     Poison message handling in RabbitMQ it is available as of RabbitMQ 3.8.0, by using the new type of queue:  Quorum Queues .      Quorum queue support handling of poison messages, that is, messages that cause a consumer to repeatedly requeue a delivery (possibly due to a consumer failure) such that the message is never consumed completely and positively acknowledged so that it can be marked for deletion by RabbitMQ.      Be aware, some features are not currently supported by quorum queues:      Quorum queues keep track of the number of unsuccessful delivery attempts and expose it in the "x-delivery-count" header that is included with any redelivered message.      It is possible to set a delivery limit for a queue using a policy argument, delivery-limit. When a message has been returned more times than the limit the message will be dropped or dead-lettered (if a DLX is configu...

Managing database objects in SQL with SMO framework

SQL Server Management Objects (SMO) is a collection of objects that are designed for programming all aspects of managing Microsoft SQL Server. SQL Server Replication Management Objects (RMO) is a collection of objects that encapsulates SQL Server replication management. To get a good overview see the  SMO Programming Guide . There many operations which may be performed with SMO from obtaining information about SQL-Server objects to creating and modifying objects or perhaps backing up or restoring a database. The code sample below is used to transform single column PKs and FKs in composite ones.  The source code can be found on GitHub at: https://github.com/dradoaica/Managing.Database.Objects.In.SQL.With.SMO Enjoy (ง°ل͜°)ง

Cross subscription/resource group Azure deployment using ARM template

Azure Resource Manager is the deployment and management service for Azure. It provides a consistent management layer that enables you to create, update, and delete resources in your Azure subscription. You can use its access control, auditing, and tagging features to secure and organize your resources after deployment. With ARM , you can create a template (in JSON format) that defines the infrastructure and configuration of your Azure solution. By using a template, you can repeatedly deploy your solution throughout its lifecycle and have confidence your resources are deployed in a consistent state. When deploying the template you usually specify a single subscription/resource group, but sometimes you need to create some resources in another subscription/resource group and you want to do it in one go. I n the following, I will show you how to create a template for a c ross subscription/resource group deployment. You can deploy to only five resource groups in a single d...

Building a RESTful API with NancyFx v2

The NancyFx v2 official release is available in Nuget since april 2019. The primary reason for upgrading NancyFx to v2 is because of its support for .NETStandard 2.0 which means you can move to .NET Core. Starting from my previous post  Building a RESTful API with NancyFx , I will show you how to upgrade to  NancyFx v2. The full   list ,  though short,  of b reaking changes can be found at: https://github.com/NancyFx/Nancy/wiki/Nancy-v2-Upgrade-Notes The most glaring breaking changes are with "Routing" and "Authentication and security". Routing Routing syntax has changed to Get("/", args => "Hello World");, these can be made async by adding the async/await keywords. To avoid changing the syntax for old routes and modules, Derek Comartin created a new module that would add back the existing routing behavior by calling the new underlying methods in the NancyModule, for more details see: https://codeopinion.com/upgrading-...

Kubernetes cluster with docker private registry

Prerequisites One or more machines running one of Ubuntu 20.04+ 2 GB or more of RAM per machine (any less will leave little room for your apps) 2 CPUs or more Full network connectivity between all machines in the cluster (public or private network is fine) * 192.168.147.3 is the IP of my machine which is used as master in the cluster Putting it all together 1. Install Docker # Install Docker CE ## Set up the repository: ### Update the apt package index apt-get update ### Install packages to allow apt to use a repository over HTTPS apt-get update && apt-get install apt-transport-https software-properties-common ca-certificates curl gnupg lsb-release ### Add Docker’s official GPG key curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg ### Add docker apt repository. echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] ...

Host ASP.NET Core 2.1 application on Ubuntu Server 18.04

To understand and apply this, first see: Host ASP.NET Core on Linux with Nginx The tutorial from above is pretty straightforward, but is for Ubuntu Server 16.04. In the following, i will show you how to bypass the problems when hosting ASP.NET Core 2.1 application on Ubuntu Server 18.04. The first problem is installing the SDK, for Ubuntu Server 18.04 use: shell> curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg shell> sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg shell> sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod bionic main" > /etc/apt/sources.list.d/dotnetdev.list' shell> wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb shell> sudo dpkg -i packages-microsoft-prod.deb shell> sudo apt-get install apt-transport-https shell> sudo apt-get update shell> sudo apt-get inst...

How to: Transform Web.config When Deploying a Web Site Project

Publishing a Web Site project with Visual Studio does not support Web.config transform files. In the following, I will show you how to use the same functionality from a Web Application project (see:  How to: Transform Web.config When Deploying a Web Application Project ) in a Web site project. You have to create a publish profile for the Web Site project and add an MSBuild step in the "website.publishproj" file: <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">   ...   <Import Project="$(_WebPublishTargetsPath)\Web\Microsoft.WebSite.Publishing.targets" />   <UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />   <Target Name="BeforeBuild">     <TransformXml ...

DevTalks Bucharest 2018 review

Dev<Talks/> brings together great community leaders and innovation, this year’s stages featured: Devops, Emerging tech, Web & Mobile, Datafication, Java, Product Management, Automotive and a variety of workshops. This is the 5th edition of Dev<Talks/> Bucharest and it took place in the Romexpo exhibition complex. As in the previous years, it started early in the morning, around 9 AM. First I had to register and then get the badge and the agenda for the day (the online version of the agenda: http://www.devtalks.ro/bucharest/agenda/ ). This year I attended only presentations from the DevOps stage. It was not quite what I expected it to be, there were some presentations that were not related to the DevOps field and very few that had a hands-on approach. Besides that, there were some very good presentations: "Continuous Delivery – one for all and all for one" by Ionut Hrinca: he presented the struggle of ING Tech company...

Building a schedule manager with Quartz

Contents Introduction Prerequisites Schedule manager Putting it all together Introduction Create simple schedule manager using Quartz library ( https://www.quartz-scheduler.net/ ) Prerequisites IDE: Microsoft Visual Studio or Visual Studio Code NuGet packages: https://www.nuget.org/packages/Quartz/3.0.5 https://www.nuget.org/packages/log4net/2.0.8 Schedule manager The schedule manager allows you to: start the schedule manager suspend jobs firing for the schedule manager stop the schedule manager schedule a job (CRON trigger + timezone or Quartz trigger) unschedule a job run a job on demand Usage: ScheduleManager.Instance.Start(); // schedule an every 15 seconds test job ScheduleManager.Instance.ScheduleJob<TestJob>( "testJob" , "testGroup" , "0/15 * * * * ?" ); // some sleep to show what's happening Task.Delay(TimeSpan.FromSeconds(60)).Wait(); ScheduleManager.Instance.Stop(); Putt...

Juice this "static" up a little

    Static members and methods are basically the same as a non-static members and methods, but there is one difference: you don't need an instance variable to access them. For example, if you have a static class that is named HelperClass  that has a public method named DoStuff , you call the method as shown in the following example: HelperClass.DoStuff()     For more information about statics see " Static Classes and Static Class Members (C# Programming Guide) ".     The good about statics: single point data manipulation less memory usage (no instances) faster access/call times (the compiler generates overhead for non-static members and methods) low level of code complexity     The bad about statics: statics limitations (no inheritance, no overriding, can't use non-statics, etc.) code rigidity harder to test no control over the life cycle (remains in memory for the lifetime of the application domain) ...

.NET Framework source code debugging

Image
The .NET Framework source code for the targeted version can be downloaded at: http://referencesource.microsoft.com/ from "Download" section. To enable .NET Framework  source code debugging in Microsoft Visual Studio see: https://msdn.microsoft.com/en-us/library/cc667410.aspx Specify which symbols to load: After this, hit "OK" button and proceed with the debugging. Enjoy (ง°ل͜°)ง

Sandboxing with AppDomain

Image
Contents Introduction Prerequisites Sandboxing with AppDomain Putting it all together Introduction In the following, i will show you how to run partially trusted code and avoid polluting main application domain by sandboxing with AppDomain. Prerequisites IDE: Microsoft Visual Studio or Visual Studio Code Sandboxing with AppDomain To understand and apply this, first see: https://docs.microsoft.com/en-us/dotnet/framework/misc/how-to-run-partially-trusted-code-in-a-sandbox In addition to that: communication across application domains is made via a proxy (a class that extends  System.MarshalByRefObject ); modifications on reference type parameters are available across application domains only for ref and out  parameters; CreateInstanceAndUnwrap  rises  AssemblyResolve  events in the application domain from which it was called for the specified assembly (i wasn't expecting that!!!). In the screenshot from above we...

DevTalks Bucharest 2017 review

Image
Dev<Talks/> brings together great community leaders and innovation, this year’s stages featured: Web & Mobile, BigData & Cloud, DevOps, Java, Project Management, smart devices, machine learning, AI and a variety of workshops. This is the 4th edition of Dev<Talks/> Bucharest and it took place in the Romexpo exhibition complex. It started early in the morning, around 9 AM. First I had to register and then get the badge and the agenda for the day (the online version of the agenda:  http://www.devtalks.ro/bucharest/agenda/ ): As I was saying, it was early in the morning and the place was pretty quiet: The agitation began with the opening of the stages. With pretty good timing and with the help of the agenda (it also contained a map) you could have enjoyed all the presentations you desired. The presentations consisted in introductory material and recipes for real-life situations, new approaches in software development and highlighting th...

Network and application monitoring using Zabbix

Image
Contents Introduction Prerequisites Zabbix server installation Zabbix agent installation Introduction Zabbix is software that monitors numerous parameters of a network and the health and integrity of servers. Zabbix uses a flexible notification mechanism that allows users to configure e-mail based alerts for virtually any event. This allows a fast reaction to server problems. Zabbix offers excellent reporting and data visualisation features based on the stored data. This makes Zabbix ideal for capacity planning. Zabbix supports both polling and trapping. All Zabbix reports and statistics, as well as configuration parameters, are accessed through a web-based frontend. A web-based frontend ensures that the status of your network and the health of your servers can be assessed from any location. Properly configured, Zabbix can play an important role in monitoring IT infrastructure. This is equally true for small organisations with a few servers and for large companies...

Debugging an externally launched WildFly

Image
Contents Introduction Prerequisites Remote debugging Introduction WildFly application server is the second most popular Java EE container, so there's a chance that you used it already or you will use it in the near future. One great problem during a delpoyment is when things go wrong in the production environment and you must find out what is wrong with your application. The first thing that comes to your mind is to look through the log files, but what happens when that isn't enough? In the following, i will show you how to run WildFly in debug-mode and how to remote debugging it using Eclipse IDE. Prerequisites IDE: Eclipse IDE for Java EE Developers Java EE container: WildFly 10.x OS: Windows Remote debugging To run WildFly in debug-mode you have to use the following command line: ${WildFlyInstallationPath}\bin\standalone.bat --debug 1044 meaning that it will allow remote debugging on the port specified (you can us...

Building a RESTful API with NancyFx

Contents Introduction Prerequisites The basics of NancyFx Model binding and validation Bootstrapping NancyFx Hosting NancyFx Authentication and security Putting it all together Introduction In the following, I will show you how easy is to build a simple RESTful API with NancyFx. As it is said by its creators "Nancy is a lightweight, low-ceremony, framework for building HTTP based services on .NET and Mono. The goal of the framework is to stay out of the way as much as possible and provide a super-duper-happy-path to all interactions." (the full documentation can be found at https://github.com/NancyFx/Nancy/wiki/Documentation ). To understand and apply this, basic knowledge of C# programming language and RESTful API concepts is required. Prerequisites IDE: Microsoft Visual Studio or Visual Studio Code NuGet packages: https://www.nuget.org/packages/FluentValidation/3.4.0 https://www.nuget.org/packages/Microsoft.Owin/3.1.0 https://www.nuget.org/packa...