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,
PhbkDbContextandLpEmpPhBkContext, the question is which one to use to run the wizard script.-
PhbkDbContextmust 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
-
LpPhBkControllersis the destination project-
Consumersis the destination folder
-
-
PhbkEmployeeViewis a View to generate the class -
01025-.masstransit.consumer.cs- is a script type-
masstransit.consumer.cs.t4is 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 dbin thephbk-employee-view.masstransit.consumer.cs-file -
replace the
PhbkDbContext dbcontext-code with the codeLpEmpPhBkContext dbcontextin 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
LpPhbkDbContextto 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,LprEmployee01andLprEmployee02tables must have a foreign key, which referencesPhbkEmployeeView-table. In additionLprEmployee02must 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.