Activities of "Denis"

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.

Hi

I have issue with GET endpoint which accepts DateTime as parameter. I have microservices 2 A and B. The endpoint is implemented by A and called by B. For calling I use dynamic HttpApiClient. When DateTime passed to http client as parameter, the DateTime is stringified to string with ToString method. Then the string passed to url parameters pasrt without encoded to url format. That leads, when DaeTime stringified to 'dd/MM/yy hh:mm:ss' format, endpoint is not found because dd MM and yy are parsed as segments of url path.

Is that a bug in http client? I checked ClientProxyUrlBuilder and I think that it should use HttpUtility.UrlEncode for every passed value.ToString() - snippet

  • ABP Framework version: v4.4.0
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): separate
  • Steps to reproduce the issue:
  1. Create GET endpoint which accepts DateTime as parameter
  2. Reference HttpApiClient project/package in another application or try to use client in the same application with the endpoint
  3. Add call of the endpoint

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

Hi,

We are developing systems which consists of several Modules. We faced with some troubles in managing of communication between them. Right now, we have only monolith deployment. That means all our Modules are referenced by single ABP Host Application (which generated by ABP Suite). We referenced all Modules accordingly architecure of layers

Application -> Application Contracts -> Contracts ...

in Host Application. We have Module A which needs to coomunicate with Module B.

  1. The first question is how to setup references and DI which fit for monolith and microservices deployment Right now, in Module B, we have Background Worker. This worker makes call to module A. For that, in Background Worker class, we reference IBookService of Module B. In monolith it is resolved to BookService, which implemented by module A. What is okay, we do not have authorization issues because authorization is disabled. But when we will place Modules in different service, what we need to do so IBookService will be resolved to HttpApiClient, so call will be made over http?
  2. The second question is what to do when we will add authorization to endpoints in IBookService? After that, we will start getting auth error, because Background Workder does not have authorization context. As solution, we are going to make InternalBookService implementing IBookService, which will implement logic of BookService. That time, BookService will just call InternalBookService. Thus, Background Worker also access to InternalBookService, instead of BookService which is remote. Question is how to manage DI? In monolith we have BookService registered first, and we will get BookService injected to our BackgroundWorker. But we would want InternalBookService injected instead and be still able to move module B to separate service
  • ABP Framework version: v4.3.0

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

I need to get language which passed via Accept-language header to endpoint. In aspbloilerplate I used Thread.CurrentThread.CurrentUICulture . In abp it does not look working.

What way I need to apply?

  • ABP Framework version: v4.3.0
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

I am trying to run service for MSA solution. Service can not start with messages in log

[15:26:22 ERR] ABP-LIC-0008 - License check failed for 'Volo.Saas.Domain-v4.4.0.0'.
You need to log in using the command `abp login &lt;username&gt;`.
For more information, contact to license@abp.io.
[15:26:25 WRN] The AMQP operation was interrupted: AMQP close-reason, initiated by Application, code=200, text='Connection close forced', classId=0, methodId=0
RabbitMQ.Client.Exceptions.OperationInterruptedException: The AMQP operation was interrupted: AMQP close-reason, initiated by Application, code=200, text='Connection close forced', classId=0, methodId=0
   at RabbitMQ.Client.Impl.SimpleBlockingRpcContinuation.GetReply(TimeSpan timeout)
   at RabbitMQ.Client.Impl.ModelBase.QueueDeclare(String queue, Boolean passive, Boolean durable, Boolean exclusive, Boolean autoDelete, IDictionary`2 arguments)
   at RabbitMQ.Client.Impl.ModelBase.QueueDeclare(String queue, Boolean durable, Boolean exclusive, Boolean autoDelete, IDictionary`2 arguments)
   at RabbitMQ.Client.Impl.AutorecoveringModel.QueueDeclare(String queue, Boolean durable, Boolean exclusive, Boolean autoDelete, IDictionary`2 arguments)
   at RabbitMQ.Client.IModelExensions.QueueDeclare(IModel model, String queue, Boolean durable, Boolean exclusive, Boolean autoDelete, IDictionary`2 arguments)
   at Volo.Abp.RabbitMQ.RabbitMqMessageConsumer.TryCreateChannelAsync()
[15:26:25 INF] Application is shutting down...
[15:26:25 INF] Initialized all ABP modules.
[15:26:25 FTL] Unable to start Kestrel.
System.Threading.Tasks.TaskCanceledException: A task was canceled.
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)

Why it is asking to log in into abp, whne license key is provided actually?

  • ABP Framework version: v4.3
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes

I need t configure DB context to use this library https://github.com/VahidN/EFCoreSecondLevelCacheInterceptor

How I can do that in ABP?

The code below is used to enable this interceptor

public static class MsSqlServiceCollectionExtensions
    {
        public static IServiceCollection AddConfiguredMsSqlDbContext(this IServiceCollection services, string connectionString)
        {
            services.AddDbContextPool<ApplicationDbContext>((serviceProvider, optionsBuilder) =>
                    optionsBuilder
                        .UseSqlServer(
                            connectionString,
                            sqlServerOptionsBuilder =>
                            {
                                sqlServerOptionsBuilder
                                    .CommandTimeout((int)TimeSpan.FromMinutes(3).TotalSeconds)
                                    .EnableRetryOnFailure()
                                    .MigrationsAssembly(typeof(MsSqlServiceCollectionExtensions).Assembly.FullName);
                            })
                        .AddInterceptors(serviceProvider.GetRequiredService<SecondLevelCacheInterceptor>()));
            return services;
        }
    }

ABP Version: 4.3

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
    }
}
Showing 1 to 10 of 42 entries
Made with ❤️ on ABP v9.1.0-rc.1. Updated on January 17, 2025, 14:13