Starts in:
2 DAYS
18 HRS
24 MIN
50 SEC
Starts in:
2 D
18 H
24 M
50 S

Activities of "Denis"

How I can make APM also to catch Exceptions then? I want APM to catch exception before ABP does that. I guess APM proxies exception further

Please do these steps as well

  1. Create new Controller in HttpApi project
  2. Create some service in Application project, which throws an exception
  3. Make Controller call to call the service
  1. Create new ABP Application
  2. Integrate Elastic following instruction https://www.elastic.co/guide/en/apm/agent/dotnet/current/configuration-on-asp-net-core.html
  3. Create and endpoint which throws some exception
  4. Call this endpoint and check Elastic APM

Sure,

Controller

[HttpGet]
[Route("by-dateTime/{utcDateTime}")]
public async Task<RecordDto> GetRecordByDateTime(DateTime utcDateTime)
        {
            return await _recordAppService.GetRecordByDateTime(utcDateTime);
        }

Application service

public async Task<RecordDto> GetRecordByDateTime([DisableDateTimeNormalization] DateTime utcDateTime)
        {
            var record = await _recordRepository.GetAsync(i => i.UtcDateTime == utcDateTime);

            return await ObjectMapper.Map<RecordDto>(record);
        }

Microservice A gets call of url path /api/records/by-dateTime/27/12/2021 10:00:00. The format of date time is default format in InvariantCulture used by HttpClient.

But the issue relates not only to DateTime. It relates to any object which has special symbols in string presentation. For example, if we replace DateTime with string parameter, which value has space symbol inside, then we get problem again, because space can not be used without encoding in url path.

Some details and rephrasing... The job is placed in application level of module A. The job uses app service from module B. In monotlith, app service interface is resolved to app service, which provided by B. If service has auth protection then job gets error. I would like to apply some workaround... implement internal version of service in B, which will not be exposed to controllers. Internal service implements the same interface (eg IBookAppService). Then, I would like internal version of service injected in monolith deployment. But in microservices deployment client proxy should be injected

Thus, we have 3 implementations of app service interface

  1. App service - used for controllers. Protected
  2. Internal App service - used for internal communication in monolith. Internal service implementation is reused by App service for controllers
  3. Http Client - used in microservice depployment

@gterdem Thank yor for reply. But my question is about how to make Background Worker of module A to pull data from module B in way that will work in monolith and microservice deployments

Actually both ways work. The reasl reason is ABP comes with not default languages included into supported cultures. You need to add them into AbpLocalization yourself

Sure. The same as in endpoint. CurrentUser is materizled from JWT token which passed to event data or in appsettings

public class UserStatBackgroundJob : IAsyncBackgroundJob<Object>
{
    private readonly IUserLookupService<AppUser> _userLookupService;
    
    ICurrentUser _currentUser;     <<--------

    public UserStatBackgroundJob(IUserLookupService<AppUser> userLookupService, ICurrentUser currentUser)
    {
        _userLookupService = userLookupService;
        _currentUser = currentUser      <<-------
    }

    public async Task ExecuteAsync(Object args)
    {
        long userCount = await _userLookupService.GetCountAsync();
        
        var userName = currentUser.Name;         <<---------

        //usage of userCount
    }
}

Hi

Sorriy, but I could not find what you wrote about on page provided by link. Can you please send link to source of project you talking about?

Also I would want to give more details about by question. I would like to not bind to http client proxy implementation of application services, so calls will be done via HTTP always for any deployment: monolith or microservices. I want to keep event handlers without changes, but also implement Attribute for authentication and authorization, at same way as that done in middleware which is called before endpoint execution. This Attribute will use JWT token provided in app configuration. Execution authorization will be done before event handler call, in the way as it is done in ABP middleware before endpoint execution, so all application services in monolith will be called directly in runtime, as that would be done by another application service during endpoint execution.

In short - I want CurrentUser and CurrentTenant will be provided before event handler execution

Hi @maliming

Can you please explain, how I can do authorization in event handler? I mean that I need to reach the same result as on endpoint execution. Before endpoint executed there is middleware doing authorization. I would like to make that in scope of event handlers

Showing 1 to 10 of 31 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06