064 Service bus Consumer for PhbkEmployeeView - chempkovsky/CS82ANGULAR GitHub Wiki
- We have already created the service, which sends data to the bus.
- We have already created the Helper class which updates the data to the
- MassTransit introduces Consumer
- Now we need the code, which receives data from the Service bus and calls the methods of the Helper class.
- with
01025-.masstransit.consumer.cs
-Wizard's script we will generate the code for the Service bus Consumer.
- with
- Since we have two database contexts,
PhbkDbContext
andLpEmpPhBkContext
, the question is which one to use to run the wizard script.-
PhbkDbContext
must be used to generate Lookup resource Service bus Consumer.
-
- We do not describe step by step instructions
- please repeat the steps similar to those described in the article 043
-
LpPhBkControllers
is the destination project-
Consumers
is the destination folder
-
-
PhbkEmployeeView
is a View to generate the class -
01025-.masstransit.consumer.cs
- is a script type-
masstransit.consumer.cs.t4
is a t4 script
-
-
phbk-employee-view.masstransit.consumer.cs
- file will be created
- open
phbk-employee-view.masstransit.consumer.cs
-file
Click to show the picture
- We need to make modifications of the
phbk-employee-view.masstransit.consumer.cs
-file
-
replace the
using PhBkContext.PhBk;
-line with theusing LpPhBkContext.PhBk;
-
replace the
PhbkDbContext db
-code with the codeLpEmpPhBkContext db
in thephbk-employee-view.masstransit.consumer.cs
-file -
replace the
PhbkDbContext dbcontext
-code with the codeLpEmpPhBkContext dbcontext
in thephbk-employee-view.masstransit.consumer.cs
-file -
Note: The Lookup resource Helper and Consumer Classes are the only two classes that need to be modified after generation. We can not use
LpPhbkDbContext
to generatephbk-employee-view.masstransit.consumer.cs
-file. Without additional foreign keys, the Wizard will not be able to recognize the group of tables as a lookup resource. To be recognizable as a lookup resource,LprEmployee01
andLprEmployee02
tables must have a foreign key, which referencesPhbkEmployeeView
-table. In additionLprEmployee02
must have a foreign key, which referencesPhbkDivision
-table... In short, find and replace-approach is optimal.
- open
phbk-employee-view.masstransit.consumer.cs
-file- at the beginning of the file you will find instruction of how to setup the app to connect to Service bus
- read the article Configuring MassTransit for an Application to view the setup instruction code.