User Tools

Site Tools


nebolintegration_basic_integration

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
nebolintegration_basic_integration [2021/08/11 22:50] – created nebolnebolintegration_basic_integration [2021/11/03 17:24] (current) nebol
Line 1: Line 1:
-==== NebolIntegration Sample 1: .NET Core Console application with SQL LocalDB ====+==== NebolIntegration: Basic Integration - Creating your first integration ==== 
 + 
 +We will be creating a .NET Core Console application and an integration that requests GUID's from an external webservice when requested by the user. Data will be stored in a SQL LocalDB.
  
 ==== NOT DONE! WORK IN PROGRESS! ==== ==== NOT DONE! WORK IN PROGRESS! ====
Line 16: Line 18:
 Install-Package SharpRepository.EfCoreRepository # EF Core support for SharpRepository Install-Package SharpRepository.EfCoreRepository # EF Core support for SharpRepository
 Install-Package Microsoft.EntityFrameworkCore.SqlServer # MS SQL support for Entity Framework Install-Package Microsoft.EntityFrameworkCore.SqlServer # MS SQL support for Entity Framework
-Install-Package SharpRepository.IocMicrosoft.DependencyInjection # MS dependency injection support for SharpRepository+Install-Package SharpRepository.Ioc.Microsoft.DependencyInjection # MS dependency injection support for SharpRepository
 Install-Package NewtonSoft.Json # needed for some JSON converting later Install-Package NewtonSoft.Json # needed for some JSON converting later
 </code> </code>
Line 22: Line 24:
 SharpRepository.EfCoreRepository is needed for EF Core support for SharpRepository SharpRepository.EfCoreRepository is needed for EF Core support for SharpRepository
 Microsoft.EntityFrameworkCore.SqlServer is needed for MS SQL support for Entity Framework Microsoft.EntityFrameworkCore.SqlServer is needed for MS SQL support for Entity Framework
-SharpRepository.IocMicrosoft.DependencyInjection is needed for MS dependency injection support for SharpRepository+SharpRepository.Ioc.Microsoft.DependencyInjection is needed for MS dependency injection support for SharpRepository
 NewtonSoft.Json is needed for some JSON converting later on NewtonSoft.Json is needed for some JSON converting later on
  
Line 36: Line 38:
 <code> <code>
 "Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=integration;AttachDBFilename=E:\NebolIntegrationSample.mdf"; "Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=integration;AttachDBFilename=E:\NebolIntegrationSample.mdf";
 +</code>
 +or something like this for MS SQL Server:
 +<code>
 +"Server=mssql;user id=myuser;password=sdfsf4rerweew;database=test_integrations";
 </code> </code>
  
Line 44: Line 50:
 First, the actual integration. We'll use a public webservice that just returns a UUID. Very simple. First, the actual integration. We'll use a public webservice that just returns a UUID. Very simple.
  
-We create a class derived from SystemIntegration. We supply it with a few parameters that specifies how the integration is managed, and we override the ProcessRequest() and ProcessResponse() methods.+We create a class derived from SystemIntegration. We supply it with a few parameters that specifies how the integration is managed (will be discussed later), and we override the ProcessRequest() and ProcessResponse() methods.
 The ProcessRequest() method is called when a new task is found in the queue. It does what needs to be done, in this case call a simple webservice. The ProcessResponse() handles the response recieved from the webservice, in this case it just outputs the UUID that is fetched. The ProcessRequest() method is called when a new task is found in the queue. It does what needs to be done, in this case call a simple webservice. The ProcessResponse() handles the response recieved from the webservice, in this case it just outputs the UUID that is fetched.
  
-<code>+<code csharp> 
 +// Representation of a successful response
 public class FetchedUUID public class FetchedUUID
 { {
Line 53: Line 60:
 } }
  
 +// Our integration class
 public class FetchUUID : SystemIntegration public class FetchUUID : SystemIntegration
 { {
Line 100: Line 108:
 Now let's set everything up. Now let's set everything up.
  
-<code>+A couple of static variables in the Program class: 
 +<code csharp> 
 +static Engine engine; 
 +static ServiceCollection services; 
 +</code> 
 + 
 +<code csharp>
 static void SetupIntegration() static void SetupIntegration()
 { {
Line 140: Line 154:
 NebolIntegration takes advantage of NebolLogger, so we will set that up as well. In this case we'll just use the color-coded console logger: NebolIntegration takes advantage of NebolLogger, so we will set that up as well. In this case we'll just use the color-coded console logger:
  
-<code>+<code csharp>
 protected static void InitLoggingFramework() protected static void InitLoggingFramework()
 { {
Line 149: Line 163:
  
 Now let's start the integration engine: Now let's start the integration engine:
-<code>+<code csharp>
 engine.StartIntegrations(); engine.StartIntegrations();
 </code> </code>
  
-And we'll add a basic console loop: +And we'll add a simple console input loop: 
-<code>+<code csharp>
 string command; string command;
 Console.WriteLine("Press ENTER to submit request to integration engine. Q to quit."); Console.WriteLine("Press ENTER to submit request to integration engine. Q to quit.");
Line 171: Line 185:
 Finally, the cleanup: Finally, the cleanup:
  
-<code>+<code csharp>
 engine.StopIntegrations(); engine.StopIntegrations();
 </code> </code>
Line 186: Line 200:
 {{:nebolintegration_sample_1_console2.png?nolink|}} {{:nebolintegration_sample_1_console2.png?nolink|}}
  
-Congrats! A call was made to the webservice and the responce processed. Your integration is up and running!+Congrats! A call was made to the webservice and the response processed. Your integration is up and running!
  
-Next: Adding a healthcheck+Next: [[NebolIntegration_Database_and_Flow]] - So what happened?
nebolintegration_basic_integration.1628715053.txt.gz · Last modified: 2021/08/11 22:50 by nebol