From acee880831a67956f82ab826ff720effef5f174c Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 20 Nov 2020 10:00:49 +0800 Subject: [PATCH 1/2] Update Entity-Framework-Core.md --- docs/en/Entity-Framework-Core.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/en/Entity-Framework-Core.md b/docs/en/Entity-Framework-Core.md index 5d41d571b7..e536cfe5cb 100644 --- a/docs/en/Entity-Framework-Core.md +++ b/docs/en/Entity-Framework-Core.md @@ -446,6 +446,23 @@ context.Services.AddAbpDbContext(options => In this example, `OtherDbContext` implements `IBookStoreDbContext`. This feature allows you to have multiple DbContext (one per module) on development, but single DbContext (implements all interfaces of all DbContexts) on runtime. +### Enabling split queries globally by default + +Abp enables split queries globally by default for better performance. You can also change it as needed, such as: + +````csharp +Configure(options => +{ + options.UseSqlServer(optionsBuilder => + { + //Change QuerySplittingBehavior + optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SingleQuery); + }); +}); +```` + +For more information, please refer to https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.querysplittingbehavior?view=efcore-5.0 + ## See Also * [Entities](Entities.md) From 4d687023ad5f16c1def52acdff8a7d7f7e8d170b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Fri, 20 Nov 2020 11:17:45 +0300 Subject: [PATCH 2/2] Update background jobs. --- docs/en/Background-Jobs-RabbitMq.md | 14 +++++++---- docs/en/Background-Jobs.md | 38 +++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/docs/en/Background-Jobs-RabbitMq.md b/docs/en/Background-Jobs-RabbitMq.md index dfc8b80588..2ee478ed17 100644 --- a/docs/en/Background-Jobs-RabbitMq.md +++ b/docs/en/Background-Jobs-RabbitMq.md @@ -90,7 +90,7 @@ Using these options classes can be combined with the `appsettings.json` way. Con By default, each job type uses a separate queue. Queue names are calculated by combining a standard prefix and the job name. Default prefix is `AbpBackgroundJobs.` So, if the job name is `EmailSending` then the queue name in the RabbitMQ becomes `AbpBackgroundJobs.EmailSending` -> Use `BackgroundJobName` attribute on the background job class to specify the job name. Otherwise, the job name will be the full name (with namespace) of the job class. +> Use `BackgroundJobName` attribute on the background **job argument** class to specify the job name. Otherwise, the job name will be the full name (with namespace) of the job class. #### Job Connections @@ -106,9 +106,9 @@ By default, all the job types use the `Default` RabbitMQ connection. Configure(options => { options.DefaultQueueNamePrefix = "my_app_jobs."; - options.JobQueues[typeof(EmailSendingJob)] = + options.JobQueues[typeof(EmailSendingArgs)] = new JobQueueConfiguration( - typeof(EmailSendingJob), + typeof(EmailSendingArgs), queueName: "my_app_jobs.emails", connectionName: "SecondConnection" ); @@ -116,7 +116,7 @@ Configure(options => ```` * This example sets the default queue name prefix to `my_app_jobs.`. If different applications use the same RabbitMQ server, it would be important to use different prefixes for each application to not consume jobs of each other. -* Also specifies a different connection string for the `EmailSendingJob`. +* Also specifies a different connection string for the `EmailSendingArgs`. `JobQueueConfiguration` class has some additional options in its constructor; @@ -126,4 +126,8 @@ Configure(options => * `exclusive` (optional, default: `false`). * `autoDelete` (optional, default: `false`) -See the RabbitMQ documentation if you want to understand the `durable`, `exclusive` and `autoDelete` options better, while most of the times the default configuration is what you want. \ No newline at end of file +See the RabbitMQ documentation if you want to understand the `durable`, `exclusive` and `autoDelete` options better, while most of the times the default configuration is what you want. + +## See Also + +* [Background Jobs](Background-Jobs.md) \ No newline at end of file diff --git a/docs/en/Background-Jobs.md b/docs/en/Background-Jobs.md index e8c680fe0e..2e0b5d3f65 100644 --- a/docs/en/Background-Jobs.md +++ b/docs/en/Background-Jobs.md @@ -13,7 +13,7 @@ Background jobs are **persistent** that means they will be **re-tried** and **ex ABP provides an **abstraction** module and **several implementations** for background jobs. It has a built-in/default implementation as well as Hangfire, RabbitMQ and Quartz integrations. -`Volo.Abp.BackgroundJobs.Abstractions` nuget package provides needed services to create background jobs and queue background job items. If your module only depend on this package, it can be independent from the actual implementation/integration. +`Volo.Abp.BackgroundJobs.Abstractions` NuGet package provides needed services to create background jobs and queue background job items. If your module only depend on this package, it can be independent from the actual implementation/integration. > `Volo.Abp.BackgroundJobs.Abstractions` package is installed to the startup templates by default. @@ -24,18 +24,23 @@ A background job is a class that implements the `IBackgroundJob` interfac This example is used to send emails in background. First, define a class to store arguments of the background job: ````csharp -public class EmailSendingArgs +namespace MyProject { - public string EmailAddress { get; set; } - public string Subject { get; set; } - public string Body { get; set; } + public class EmailSendingArgs + { + public string EmailAddress { get; set; } + public string Subject { get; set; } + public string Body { get; set; } + } } ```` Then create a background job class that uses an `EmailSendingArgs` object to send an email: ````csharp +using System.Threading.Tasks; using Volo.Abp.BackgroundJobs; +using Volo.Abp.DependencyInjection; using Volo.Abp.Emailing; namespace MyProject @@ -70,6 +75,29 @@ This job simply uses `IEmailSender` to send emails (see [email sending document] A background job should not hide exceptions. If it throws an exception, the background job is automatically re-tried after a calculated waiting time. Hide exceptions only if you don't want to re-run the background job for the current argument. +#### Job Name + +Each background job has a name. Job names are used in several places. For example, RabbitMQ provider uses job names to determine the RabbitMQ Queue names. + +Job name is determined by the **job argument type**. For the `EmailSendingArgs` example above, the job name is `MyProject.EmailSendingArgs` (full name, including the namespace). You can use the `BackgroundJobName` attribute to set a different job name. + +**Example** + +```csharp +using Volo.Abp.BackgroundJobs; + +namespace MyProject +{ + [BackgroundJobName("emails")] + public class EmailSendingArgs + { + public string EmailAddress { get; set; } + public string Subject { get; set; } + public string Body { get; set; } + } +} +``` + ### Queue a Job Item Now, you can queue an email sending job using the `IBackgroundJobManager` service: