Hi :-)
I have tried to follow https://abp.io/docs/latest/framework/infrastructure/event-bus/distributed
The CustomerService shall publish a message over RabbitMQ disitrbuted bus to the InvoiceService when Customer is updated.
The publisher:
public class CustomersAppService : ApplicationService, ICustomersAppService
{
protected IDistributedCache<CustomerDownloadTokenCacheItem, string> _downloadTokenCache;
protected ICustomerRepository _customerRepository;
protected CustomerManager _customerManager;
protected IDistributedEventBus _eventBus;
public CustomersAppService(
ICustomerRepository customerRepository,
CustomerManager customerManager,
IDistributedEventBus eventBus,
IDistributedCache<CustomerDownloadTokenCacheItem, string> downloadTokenCache)
{
_downloadTokenCache = downloadTokenCache;
_customerRepository = customerRepository;
_customerManager = customerManager;
_eventBus = eventBus;
}
public virtual async Task<CustomerDto> UpdateAsync(Guid id, CustomerUpdateDto input)
{
var customer = await _customerManager.UpdateAsync(
id,
input.Name, input.Street, input.ZipCode, input.City, input.PhoneNumber,
input.Email, input.IsCompany, input.IdentificationNumber, input.AttName,
input.ConcurrencyStamp
);
// Send update event
var customerUpdatedEto = ObjectMapper.Map<Customer, CustomerUpdatedEto>(customer);
await _eventBus.PublishAsync(customerUpdatedEto);
// Return object
return ObjectMapper.Map<Customer, CustomerDto>(customer);
}
...
}
The ETO class:
using Volo.Abp.EventBus;
namespace MyProject.CustomerService.Customers;
[EventName("MyProject.CustomerService.Customers.CustomerUpdated")]
public class CustomerUpdatedEto
{
public Guid Id { get; set; }
public string Name { get; set; } = null!;
public string Street { get; set; } = null!;
public string ZipCode { get; set; } = null!;
public string City { get; set; } = null!;
public string PhoneNumber { get; set; } = null!;
public string Email { get; set; }
public bool IsCompany { get; set; }
public string? IdentificationNumber { get; set; }
public string? AttName { get; set; }
}
That's everything I have done in the CustomerService. In the subscriber, InvoiceService is only one added class CustomerServiceEventHandler
using MyProject.CustomerService.Customers;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EventBus.Distributed;
namespace MyProject.InvoiceService;
public class CustomerServiceEventHandler : IDistributedEventHandler<CustomerUpdatedEto>, ITransientDependency
{
public async Task HandleEventAsync(CustomerUpdatedEto eventData)
{
var customerId = eventData.Id;
}
}
Now, I have started the both services, CustomerService and the InvoiceService, and the RabbitMQ queues are listed by using the RabbitMQ CLI:
$ docker exec -it rabbitmq rabbitmqctl list_queues
Timeout: 60.0 seconds ...
Listing queues for vhost / ...
name messages
AbpBackgroundJobsDelayed.Volo.Abp.Emailing.BackgroundEmailSendingJobArgs 0
MyProject_AuthServer 0
MyProject_IdentityService 0
MyProject_CustomerService 0
AbpBackgroundJobs.Volo.Abp.Emailing.BackgroundEmailSendingJobArgs 0
MyProject_InvoiceService 0
So the queues seems to be registered. However, I can't see that any message is published, nor received at the subscribe. Notice that the receiver has a binding to the ETO class MyProject.CustomerService.Customers.CustomerUpdated. When using debugger in CustomerService, I can see that there is no exceptions thrown in the await _eventBus.PublishAsync(customerUpdatedEto); line.
$ docker exec -it rabbitmq rabbitmqctl list_bindings | grep MyProject_CustomerService
exchange MyProject_CustomerService queue MyProject_CustomerService []
MyProject exchange MyProject_CustomerService queue Volo.Abp.Localization.LanguageChangedEto []
MyProject exchange MyProject_CustomerService queue Volo.Payment.RecurringPaymentUpdated []
MyProject exchange MyProject_CustomerService queue Volo.Payment.SubscriptionCanceled []
MyProject exchange MyProject_CustomerService queue Volo.Payment.SubscriptionCreated []
MyProject exchange MyProject_CustomerService queue abp.data.apply_database_migrations []
MyProject exchange MyProject_CustomerService queue abp.multi_tenancy.tenant.connection_string.updated []
MyProject exchange MyProject_CustomerService queue abp.multi_tenancy.tenant.created []
$ docker exec -it rabbitmq rabbitmqctl list_bindings | grep MyProject_InvoiceService
exchange MyProject_InvoiceService queue MyProject_InvoiceService []
MyProject exchange MyProject_InvoiceService queue MyProject.CustomerService.Customers.CustomerUpdated []
MyProject exchange MyProject_InvoiceService queue Volo.Abp.Localization.LanguageChangedEto []
MyProject exchange MyProject_InvoiceService queue Volo.Payment.RecurringPaymentUpdated []
MyProject exchange MyProject_InvoiceService queue Volo.Payment.SubscriptionCanceled []
MyProject exchange MyProject_InvoiceService queue Volo.Payment.SubscriptionCreated []
MyProject exchange MyProject_InvoiceService queue abp.data.apply_database_migrations []
MyProject exchange MyProject_InvoiceService queue abp.multi_tenancy.tenant.connection_string.updated []
MyProject exchange MyProject_InvoiceService queue abp.multi_tenancy.tenant.created []
Thanks, it is working fine now! :-)
Hi, I added your suggestions in the project file. However, the generate embedded files manifest setting
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
result with this in the Developer console in web browser:
[Error] Error: One or more errors occurred. (An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Volo.Abp.AspNetCore.Components.WebAssembly.AbpAspNetCoreComponentsWebAssemblyModule, Volo.Abp.AspNetCore.Components.WebAssembly, Version=9.0.4.0, Culture=neutral, PublicKeyToken=null: The API description of the Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.IAbpApplicationConfigurationAppService.GetAsync method was not found!. See the inner exception for details.)
(anonym funktion) (blazor.web.js:1:157835)
When setting to false / remove it, then it is the same result as before. Any other ideas?
Thanks
Thanks,
I can understand why you don't recommend to use Language Module for static content. However, we was first trying to follow the localization guide at https://abp.io/docs/latest/framework/fundamentals/localization but failed.
So perhaps you can guide us to set the localization instead of using the language module?
This is what we have done:
ProjectBlazorClientModule.cs:
[DependsOn(
typeof(AbpLocalizationModule),
...
typeof(AbpVirtualFileSystemModule) //virtual file system
)]
public class ProjectBlazorClientModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var environment = context.Services.GetSingletonInstance<IWebAssemblyHostEnvironment>();
var builder = context.Services.GetSingletonInstance<WebAssemblyHostBuilder>()
// Include the generated app-generate-proxy.json in the virtual file system
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<ProjectBlazorClientModule>();
});
ConfigureLocalization();
...
}
private void ConfigureLocalization()
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<ProjectBlazorClientModule>();
});
Configure<AbpLocalizationOptions>(options =>
{
//Define a new localization resource (TestResource)
options.Resources
.Add<TestResource>("en")
.AddVirtualJson("/Localization/Resources/Test");
options.DefaultResourceType = typeof(TestResource);
});
}
}
TestResource.cs
using Volo.Abp.Localization;
namespace GeoTicket.Blazor.Client.Localization.Resources;
[LocalizationResourceName("Test")]
public class TestResource;
File structure:
Project.Blazor.Client/
├── Project.Blazor.Client.csproj
├── ProjectBlazorClientModule.cs
├── .....
├── ProjectComponentBase.cs
├── Localization
│ ├── Resources
│ │ └── Test
│ │ ├── en.json
│ │ └── sv.json
│ └── TestResource.cs
.....
en.json content (similar for sv.json):
{
"culture": "en",
"texts": {
"HelloWorld": "Hello World!"
}
}
@page "/"
@using Project.Blazor.Client.Localization.Resources
@using Microsoft.Extensions.Localization
@inherits ProjectComponentBase
@inject IStringLocalizer<TestResource> W
@W["HelloWorld"]
The @W["HelloWorld"] is not working, just HelloWorld in the page above.
I think that we have followed the guide, but still doesn't get it. Any ideas?
Thanks ensign,
No log is generated in development console (tried with Edge, Chrome and Safari) after clicking on the profile image both before and after opening dev console.
However, when using abp bundle in solved the problem.
Thanks Berkan,
This working great. I think that we got something to start with. The errors was not shown in Chrome.
Great support!
Thanks Berkan,
Looking good! Its just the last thing that is not working:
[Error] Failed to load resource: the server responded with a status of 404 () (bootstrap.min.css.map, line 0) https://staging.myproject.io/bootstrap.min.css.map
[Error] Failed to load resource: the server responded with a status of 404 () (dotnet.js.map, line 0) https://staging.myproject.io/_framework/dotnet.js.map
[Error] Failed to load resource: the server responded with a status of 404 () (dotnet.runtime.js.map, line 0) https://staging.myproject.io/_framework/dotnet.runtime.js.map
[Error] Failed to load resource: the server responded with a status of 404 () (bootstrap.bundle.min.js.map;, line 0) https://staging.myproject.io/bootstrap.bundle.min.js.map;
Thanks for the advice, I have implemented these but unfortunately without success. I have also verified that the correct Docker image is being used in the Kubernetes deployment. In the Blazor container, I have opened a pod shell and verified the app/wwwroot/appsettings.json, and its contents are correct as follows:
root@myproject-blazor-6d98cf46bf-lrdqn:/app/wwwroot# cat appsettings.json
{
"App": {
"SelfUrl": "https://staging.myproject.io"
},
"AuthServer": {
"Authority": "https://auth.staging.myproject.io",
"ClientId": "Blazor",
"ResponseType": "code"
},
"RemoteServices": {
"Default": {
"BaseUrl": "https://gateway-web.staging.myproject.io"
}
},
"AbpCli": {
"Bundle": {
"Mode": "BundleAndMinify", /* Options: None, Bundle, BundleAndMinify */
"Name": "global"
}
}
}
I have also executed the following:
root@myproject-blazor-6d98cf46bf-lrdqn:/app# grep "localhost" -r
wwwroot/_content/Volo.Abp.AspNetCore.Components.Web.LeptonXTheme/side-menu/libs/bootstrap-icons/package.json: "test:linkinator": "linkinator _site --recurse --silent --skip \"^(?!http://localhost)\"",
wwwroot/_content/Volo.Abp.AspNetCore.Components.Web.LeptonXTheme/side-menu/libs/bootstrap-icons/README.md:Then open `http://localhost:4000` in your browser.
root@myproject-blazor-6d98cf46bf-lrdqn:/app#
So far, I have not found anything indicating a misconfiguration. Where is localhost:44366 defined? Feels like it is hardcoded in some dll or so? Do you have any further ideas?
Best regards, Carl
Thanks Berkan,
I was adding suggested patch above with same results unfortunately. However, I was sending you a Onedrive link, did you manage to download it? As you say, it will simplify troubleshooting.
Best regards, Carl
Hi, here it comes:
Blazor Backend (K8S)
2025-02-08T13:00:38.046+01:00[myproject-blazor] Request starting HTTP/1.1 GET http://staging.mysecretdomain.com/appsettings.json - - -
2025-02-08T13:00:38.046+01:00[myproject-blazor]info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
2025-02-08T13:00:38.046+01:00[myproject-blazor] Executing endpoint 'Microsoft.AspNetCore.Routing.RouteEndpoint'
2025-02-08T13:00:38.046+01:00[myproject-blazor]info: Microsoft.AspNetCore.StaticAssets.StaticAssetsInvoker[6]
2025-02-08T13:00:38.046+01:00[myproject-blazor] The file appsettings.json was not modified
2025-02-08T13:00:38.046+01:00[myproject-blazor]info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
2025-02-08T13:00:38.046+01:00[myproject-blazor] Executed endpoint 'Microsoft.AspNetCore.Routing.RouteEndpoint'
2025-02-08T13:00:38.047+01:00[myproject-blazor]info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
2025-02-08T13:00:38.047+01:00[myproject-blazor] Request finished HTTP/1.1 GET http://staging.mysecretdomain.com/appsettings.json - 304 - application/json 0.6110ms
AuthServer (K8S)
2025-02-08T13:01:51.535+01:00[myproject-authserver][12:01:51 INF] Request finished HTTP/1.1 GET http://myproject-authserver:80/metrics - 200 null application/openmetrics-text; version=1.0.0; charset=utf-8 14.5306ms
2025-02-08T13:02:06.520+01:00[myproject-authserver][12:02:06 INF] Request starting HTTP/1.1 GET http://myproject-authserver:80/metrics - null null
2025-02-08T13:02:06.525+01:00[myproject-authserver][12:02:06 INF] Executing endpoint 'Prometheus metrics'
2025-02-08T13:02:06.536+01:00[myproject-authserver][12:02:06 INF] Executed endpoint 'Prometheus metrics'
2025-02-08T13:02:06.536+01:00[myproject-authserver][12:02:06 INF] Request finished HTTP/1.1 GET http://myproject-authserver:80/metrics - 200 null application/openmetrics-text; version=1.0.0; charset=utf-8 15.9733ms
Safari developer log
[Error] Inläsningsfel av källkarta (x5)
[Error] Failed to load resource: the server responded with a status of 404 () (bootstrap.min.css.map, line 0)
[Error] Failed to load resource: the server responded with a status of 404 () (bootstrap.bundle.min.js.map;, line 0)
[Error] Failed to load resource: the server responded with a status of 404 () (bootstrap.min.css.map, line 0)
[Error] Failed to load resource: the server responded with a status of 404 () (dotnet.js.map, line 0)
[Error] Failed to load resource: the server responded with a status of 404 () (dotnet.runtime.js.map, line 0)
[Info] info: Volo.Abp.AbpApplicationBase[0] (dotnet.runtime.o8gq1i8bk6.js, line 3)
Loaded ABP modules:
[Info] info: Volo.Abp.AbpApplicationBase[0] (dotnet.runtime.o8gq1i8bk6.js, line 3)
- MyProject.Blazor.Client.MyProjectBlazorClientModule
[Info] info: Volo.Abp.AbpApplicationBase[0] (dotnet.runtime.o8gq1i8bk6.js, line 3)
- Volo.Abp.Autofac.WebAssembly.AbpAutofacWebAssemblyModule
[Info] info: Volo.Abp.AbpApplicationBase[0] (dotnet.runtime.o8gq1i8bk6.js, line 3)
- Volo.Abp.Autofac.AbpAutofacModule
[Info] info: Volo.Abp.AbpApplicationBase[0] (dotnet.runtime.o8gq1i8bk6.js, line 3)
- Volo.Abp.Castle.AbpCastleCoreModule
[Info] info: Volo.Abp.AbpApplicationBase[0] (dotnet.runtime.o8gq1i8bk6.js, line 3)
- Volo.Abp.AspNetCore.Components.WebAssembly.AbpAspNetCoreComponentsWebAssemblyModule
......
......
- MyProject.AdministrationService.MyProjectAdministrationServiceContractsModule
[Info] info: Volo.Abp.AbpApplicationBase[0] (dotnet.runtime.o8gq1i8bk6.js, line 3)
- Volo.Abp.Identity.Pro.Blazor.Server.WebAssembly.AbpIdentityProBlazorWebAssemblyModule
[Info] info: Volo.Abp.AbpApplicationBase[0] (dotnet.runtime.o8gq1i8bk6.js, line 3)
- Volo.Abp.Identity.Pro.Blazor.AbpIdentityProBlazorModule
[Info] info: Volo.Abp.AbpApplicationBase[0] (dotnet.runtime.o8gq1i8bk6.js, line 3)
- Volo.Abp.SettingManagement.Blazor.WebAssembly.AbpSettingManagementBlazorWebAssemblyModule
[Info] info: Volo.Abp.AbpApplicationBase[0] (dotnet.runtime.o8gq1i8bk6.js, line 3)
- Volo.Abp.SettingManagement.AbpSettingManagementHttpApiClientModule
[Info] info: Volo.Abp.AbpApplicationBase[0] (dotnet.runtime.o8gq1i8bk6.js, line 3)
- Volo.Abp.Identity.AbpIdentityHttpApiClientModule
[Info] info: Volo.Abp.AbpApplicationBase[0] (dotnet.runtime.o8gq1i8bk6.js, line 3)
- Volo.Abp.Account.Pro.Admin.Blazor.WebAssembly.AbpAccountAdminBlazorWebAssemblyModule
[Info] info: Volo.Abp.AbpApplicationBase[0] (dotnet.runtime.o8gq1i8bk6.js, line 3)
- Volo.Abp.Account.Pro.Admin.Blazor.AbpAccountAdminBlazorModule