Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

abp-infrastructure

/abp-infrastructure

Opisuje infrastrukturę ABP Framework 10.x: rozproszona szyna zdarzeń, zadania w tle, cache Redis, BLOB Storing, e-mail, SignalR, blokady rozproszone i Entity Cache.

Repozytorium
abp-skills ↗
Licencja
MIT
Ostatnia zmiana repozytorium
14.08.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
2
Przestarzałość

Brak sygnałów. Repozytorium zmienione 14.08.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Opisuje infrastrukturę ABP Framework 10.x: rozproszona szyna zdarzeń, zadania w tle, cache Redis, BLOB Storing, e-mail, SignalR, blokady rozproszone i Entity Cache.

Oryginalny opis (EN)

ABP Framework v10.x (10.4–10.6) infrastructure: Distributed Event Bus, Background Jobs/Workers, Caching (Redis), BLOB Storing, Emailing, SignalR, IClock, Distributed Locking, Entity Cache. Use when you need an event bus, background job, cache, blob or email in ABP.

Jak działa

  1. Trigger
  2. Event Bus
  3. Background Jobs
  4. Caching
  5. BLOB Storing
  6. Emailing
  7. Data Filtering
  8. Data Seeding
  9. Settings
  10. Features
Sekcje z nagłówków SKILL.md, w oryginale · 218 linii, 811 słów
Podgląd SKILL.md
---
name: abp-infrastructure
description: "ABP Framework v10.x (10.4–10.6) infrastructure: Distributed Event Bus, Background Jobs/Workers, Caching (Redis), BLOB Storing, Emailing, SignalR, IClock, Distributed Locking, Entity Cache. Use when you need an event bus, background job, cache, blob or email in ABP."
---

# ABP Framework — Infrastructure

ABP Framework v10.x (10.4–10.6) infrastructure components. Event Bus, Background Jobs, Caching, BLOB Storing, Emailing, Data Filtering, Data Seeding, Settings, Features, Virtual File System, Entity Cache, Distributed Locking.

## Trigger

- "ABP event bus"
- "ABP background job"
- "ABP cache"
- "ABP Redis"
- "ABP BLOB"
- "ABP email"
- "ABP data filter"
- "ABP data seeding"
- "ABP settings"
- "ABP features"
- "ABP virtual file"
- "ABP entity cache"
- "ABP distributed lock"
- "ABP current user"
- "ABP infrastructure"

## Event Bus

| Type | Interface | Usage |
|---|---|---|
| Local | `ILocalEventBus`, `ILocalEventHandler<TEvent>` | Same process |
| Distributed | `IDistributedEventBus`, `IDistributedEventHandler<TEvent>` | Across processes |

```csharp
// Event
public class StockCountChangedEvent { public Guid ProductId { get; set; } public int NewCount { get; set; } }

// Publish (service)
await _localEventBus.PublishAsync(new StockCountChangedEvent { ProductId = id, NewCount = count });

// Publish (entity)
public class Product : AggregateRoot<Guid>
{
    public void ChangeStock(int count) { StockCount = count; AddLocalEvent(new StockCountChangedEvent { ... }); }
}

// Handler
public class Handler : ILocalEventHandler<StockCountChangedEvent>, ITransientDependency
{
    [UnitOfWork]
    public virtual async Task HandleEventAsync(StockCountChangedEvent e) { /* logic */ }
}
```

**Distributed Providers:** Local (default), RabbitMQ, Kafka, Azure Service Bus, Rebus

**Rule:** Microservice → Distributed, Modular Monolith → Distributed (inter-module), Monolith → Local

## Background Jobs

```csharp
public class EmailSendingArgs { public string Email { get; set; } public string Subject { get; set; } public string Body { get; set; } }

public class EmailSendingJob : AsyncBackgroundJob<EmailSendingArgs>, ITransientDependency
{
    private readonly IEmailSender _emailSender;
    public EmailSendingJob(IEmailSender emailSender) => _emailSender = emailSender;
    public override async Task ExecuteAsync(EmailSendingArgs args) =>
        await _emailSender.SendAsync(args.Email, args.Subject, args.Body);
}

// Enqueue
await _backgroundJobManager.EnqueueAsync(new EmailSendingArgs { ... }, priority: BackgroundJobPriority.Normal, delay: TimeSpan.FromMinutes(5));
```

**Providers:** Default (in-memory/DB), Hangfire, Quartz, RabbitMQ

## Caching

```csharp
[CacheName("Books")]
public class BookCacheItem { public string Name { get; set; } public float Price { get; set; } }

public class BookService : ITransientDependency
{
    private readonly IDistributedCache<BookCacheItem, Guid> _cache;
    public BookService(IDistributedCache<BookCacheItem, Guid> cache) => _cache = cache;

    public async Task<BookCacheItem> GetAsync(Guid id) =>
        await _cache.GetOrAddAsync(id, async () => await GetFromDbAsync(id),
            () => new DistributedCacheEntryOptions { AbsoluteExpiration = DateTimeOffset.Now.AddHours(1) });
}
```

**Redis:** `abp add-package Volo.Abp.Caching.StackExchangeRedis`
```json
"Redis": { "IsEnabled": "true", "Configuration": "127.0.0.1" }
```
**Why the ABP Redis package?** Has `SetManyAsync`/`GetManyAsync` (not in Microsoft's), simple configuration.

**Batch:** `GetManyAsync`, `SetManyAsync`, `GetOrAddManyAsync`, `RemoveManyAsync`

**UOW-level:** `await _cache.SetAsync(key, value, considerUow: true)`

## BLOB Storing

```csharp
[BlobContainerName("product-images")]
public class ProductImageBlobContainer : AbpBlobContainer { }

// Usage
await _blobContainer.SaveAsync(productId.ToString(), imageBytes, true);
var bytes = await _blobContainer.GetAllAsync(productId.ToString());
```

**Providers:** FileSystem, Database, AWS S3, Azure, MinIO, Google, Alibaba, Bunny, Memory

## Emailing

```csharp
await _emailSender.SendAsync(to: email, subject: "Welcome!", body: "...", isBodyHtml: true);
```

## Data Filtering

```csharp
using (_dataFilter.Disable<ISoftDelete>()) { return await _repository.GetListAsync(); }
using (_dataFilter.Disable<IMultiTenant>()) { return await _repository.GetCountAsync(); }
```

## Data Seeding

```csharp
public class MyDataSeedContributor : IDataSeedContributor, ITransientDependency
{
    public async Task SeedAsync(DataSeedContext context)
    {
        if (await _roleRepository.FindAsync(x => x.Name == "Admin") == null)
            await _roleRepository.InsertAsync(new IdentityRole(GuidGenerator.Create(), "Admin"));
    }
}
```

## Settings

```csharp
public class MyAppSettings : SettingDefinitionProvider
{
    public override void Define(ISettingDefinitionContext context) =>
        context.Add(new SettingDefinition("MyApp.MaxPrice", defaultValue: "1000", isVisibleToClients: true));
}

// Usage
var max = await _settingProvider.GetOrNullAsync<decimal>("MyApp.MaxPrice");
await SettingManager.SetAsync("MyApp.MaxPrice", "2000");
```

## Features

```csharp
public class MyAppFeatures : FeatureDefinitionProvider
{
    public override void Define(IFeatureDefinitionContext context) =>
        context.Add(new FeatureDefinition("MyApp.Premium", defaultValue: "false"));
}

// Usage
var enabled = await _featureChecker.IsEnabledAsync("MyApp.Premium");
```

## Virtual File System

```csharp
Configure<AbpVirtualFileSystemOptions>(options => options.FileSets.AddEmbedded<MyModule>());
```

## Current User

```csharp
var userId = CurrentUser.Id;
var userName = CurrentUser.UserName;
var tenantId = CurrentUser.TenantId;
var roles = CurrentUser.Roles;
var isAuthenticated = CurrentUser.IsAuthenticated;
```

## Distributed Locking

```csharp
await using var handle = await _distributedLock.TryAcquireAsync("my-lock-key");
if (handle != null) { /* critical operation */ }
```

## Best Practices

1. Publish events from the entity, handle them in the service
2. Move long-running work to a background job
3. Use `GetOrAddAsync`, set expiration
4. Use the BLOB provider abstraction
5. Disable the data filter with `using`
6. Settings for runtime-changeable values
7. Features for per-tenant toggles

## v10.5+

- AWS blob provider supports S3-compatible services (R2, MinIO, B2, Wasabi): `aws.ServiceURL = "https://<account-id>.r2.cloudflarestorage.com"; aws.DisablePayloadSigning = true;`
- Dynamic background worker capability markers: check `ISupportsRuntimeRegistration` / `ISupportsCronScheduling` on the manager; in-memory manager rejects cron — use Hangfire/Quartz for runtime cron scheduling.

## v10.6+

- Background jobs (opt-in): `StoreSuccessfulJobs` + `SuccessfulJobRetentionTime`, dedicated workers (`AddDedicatedWorker`), parallel execution (`MaxParallelJobExecutionCount`); EF store adds a `CompletionTime` column. Custom job store/worker implementations must add the new interface members.

## Cancellation Token Provider

- ABP wires cancellation automatically (ASP.NET Core: `HttpContext.RequestAborted` flows into DB queries). For your own logic, inject `ICancellationTokenProvider` and use `.Token` instead of passing a `CancellationToken` through every method.
- `_cancellationTokenProvider.FallbackToProvider(cancellationToken)` — uses the given token, falls back to the provider's token when it is None/default. Built-ins: `HttpContextCancellationTokenProvider` (default), `NullCancellationTokenProvider`.

## Related

[DDD](../abp-ddd/SKILL.md) · [Microservices](../abp-microservices/SKILL.md) · [Deployment](../abp-deployment/SKILL.md) · [Settings & Features](../abp-settings-features/SKILL.md) · Docs: https://abp.io/docs/latest/framework/infrastructure

Wersje

RepozytoriumWynikLicencja
Ta strona · burakdmir/abp-skills100MIT
burakdmir/abp-skills89MIT

Migawka bazy z 28.10.2026 · wersja paczki c2a358154e3d (skrót SHA-256 całej paczki)

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100background-jobs-and-events
    Obsługuje zdarzenia lokalne i rozproszone, reakcje na zmiany encji oraz zadania w tle w ABP: ILocalEventBus, IDistributedEventBus, IBackgroundJobManager i cykliczne workery.
  • 100abp-deployment
    Opisuje wdrożenie aplikacji ABP Framework 10.x na produkcję: konfiguracja produkcyjna, projekt bezstanowy, Redis, dostawca BLOB, blokady rozproszone, SignalR, reverse proxy, HTTPS, certyfikaty OpenIddict, Docker i Kubernetes.
  • 100abp-deployment
    Podaje skrót wdrożenia ABP Framework 10.x na produkcję: klaster bezstanowy, cache Redis, dostawca BLOB, blokady rozproszone, backplane SignalR, ForwardedHeaders, SSL, certyfikaty OpenIddict, Docker i Helm.
  • 100distributed-caching-and-locking
    Obsługuje typowany rozproszony cache (IDistributedCache, GetOrAddAsync na Redisie) i blokady międzyinstancyjne w ABP (IAbpDistributedLock.TryAcquireAsync, AbpDistributedCacheOptions, [CacheName]).
  • 95redis
    Dobiera strukturę danych w Redis do zadania: cache, limity żądań, Pub/Sub, Streams i blokady rozproszone.
  • 100frappe-core-cache
    Wdraża cache Redis, unieważnianie cache i rozproszone blokady w Frappe: frappe.cache, dekorator redis_cache, strategie TTL i frappe.lock, unikając nieaktualnego cache i wyścigów.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.