Spring批量框架(Spring Batch Framework)
我无法确定Spring Batch框架是否适用于以下要求。 我需要专家对此提出意见。
以下是我的要求:
读取多个Oracle表(至少10个表,包括事务和主表),根据业务规则进行复杂计算,在事务表中插入/更新/删除记录。
我确定了以下两种设计:
设计#1:
ItemReader:从密钥事务表中选择符合条件的记录。
ItemProcessor:使用ItemReader检索的记录中的可用密钥从DB获取其他详细信息。(这将需要多次DB事务)执行验证和计算,并将要写入DB的详细信息作为列表中的对象添加。
ItemWriter:使用CustomItemWriter(插入/更新/删除操作)编写对象中可用的详细信息
通过这种设计,我们可以实现并行处理,但增加了DB事务的数量。
设计#2:
步骤1
ItemReader:使用Composite Item Reader(ItemReaders组)读取所有必需的表。
ItemWriter:将结果集保存为执行上下文中的对象列表(每个表一个列表)
第2步
ItemReader:检索执行上下文中可用的对象列表,并根据业务处理将它们分组到一个对象列表中,以便处理器可以处理它们。
IremProcessor:处理ItemReader返回的对象块。 进行验证和计算,并将要写入DB的详细信息添加为列表中的对象。
ItemWriter:使用CustomItemWriter(插入/更新/删除操作)编写对象中可用的详细信息
通过这种设计,我们可以减少数据库事务的数量,但是我们正在延迟处理,直到检索到所有表记录并将其存储在执行上下文中,即我们没有使用SpringBatch提供的并行处理 。
请使用SpringBatch建议上述是否可行,或者我们需要使用传统的Java程序。
I am not able to finalize whether Spring Batch framework is applicable for the below requirement. I need experts inputs on this.
Following is my requirement:
Read multiple Oracle tables (at least 10 tables including both transaction and master), do complex calculation based on the business rules, Insert / Update / Delete records in transaction tables.
I have identified the following two designs:
Design # 1:
ItemReader: Select eligible records from Key transaction table.
ItemProcessor: Fetch additional details from DB using the key available in the record retrieved by ItemReader.(It would require multipble DB transactions) Do the validation and computation and add the details to be written to DB as objects in a list.
ItemWriter: Write the details available in objects using CustomItemWriter(insert / update / delete operation)
With this design, we can achieve parallel processing but increase the number of DB transactions.
Design # 2:
Step # 1
ItemReader: Use Composite Item Reader (Group of ItemReaders) to read all the required tables.
ItemWriter: Save the result sets as lists of Objects (One list per table) in execution context
Step # 2
ItemReader: Retrieve lists of Objects available in execution context and group them into one list of objects based on the business processing so that processor can process them.
IremProcessor: Process the chunk of Objects returned by ItemReader. Do the validation and computation and add the details to be written to DB as objects in a list.
ItemWriter: Write the details available in objects using CustomItemWriter(insert / update / delete operation)
With this design, we can REDUCE the number of DB Transactions but we are delaying the processing till all table records are retrieved and stored in execution context ie we are not using parallel processing provided by SpringBatch.
Please advise whether the above is feasible using SpringBatch or we need to use conventional Java program.
原文:https://stackoverflow.com/questions/27877802
最满意答案
命名空间和程序集是不同的东西。 特别是名称空间可以在程序集之间共享。
在这种情况下,
SqlServerValueGenerationStrategy
枚举确实包含在Microsoft.EntityFrameworkCore.Metadata
命名空间中 ,但正如您从链接中看到的那样,在Microsoft.EntityFrameworkCore.SqlServer.dll 程序集中定义。Namespaces and assemblies are different things. In particular namespaces can be shared between assemblies.
In this case, the
SqlServerValueGenerationStrategy
enum is indeed contained in theMicrosoft.EntityFrameworkCore.Metadata
namespace, but as you can see from the link, is defined in Microsoft.EntityFrameworkCore.SqlServer.dll assembly.
相关问答
更多-
EF Core 1.1 - 如何在.net核心控制台中添加迁移(EF Core 1.1 - How to Add migrations in .net core console)[2021-11-26]
要在执行EF Core迁移时避免大多数公共错误,请执行以下操作 在命令中显式写入项目参数 --startup-project,Sample.UI就像你的情况一样 --project ,这是你的DBContext离开的项目,在你的情况下是Sample.Infrastructure 如果默认情况不存在,迁移将使用public default constructor或IDbContextFactory如果使用默认构造函数,则必须在上下文类中重写On ... -
EF Core 1.1.0在其他服务器上迁移(不开发)(EF Core 1.1.0 Migrations on other servers (not development))[2022-05-24]
EF.EXE是preview3和4的一部分。 这解决了安装“dotnet.exe”的要求。 我可以将它复制到像我以前用migrate.exe那样的工件下拉菜单中。 这是EF团队提出的解决方案吗? 是。 做这个。 另请参阅问题#6313 ,我们希望在.NET Core上使这种体验变得更加简单。 EF.EXE is part of preview3 and 4. This solves the requirement for "dotnet.exe" being installed. I can copy th ... -
如何从EF Core 2.0 DbContext获取connectionString(How to get connectionString from EF Core 2.0 DbContext)[2022-12-16]
var connectionString = ctx.Database.GetDbConnection().ConnectionString; var connectionString = ctx.Database.GetDbConnection().ConnectionString; -
在EF核心中启用迁移?(Enabling Migrations in EF core?)[2023-08-05]
转到程序包管理器控制台,使用Install-Package Microsoft.EntityFrameworkCore.Tools安装所需的工具。 完成后尝试使用命令EntityFrameworkCore\Add-Migration firstMigration 。 Go to the Package Manager Console and install the needed tools with Install-Package Microsoft.EntityFrameworkCore.Tools. W ... -
EF Core 2.0迁移问题(EF Core 2.0 Migrations issue)[2023-05-11]
命名空间和程序集是不同的东西。 特别是名称空间可以在程序集之间共享。 在这种情况下, SqlServerValueGenerationStrategy枚举确实包含在Microsoft.EntityFrameworkCore.Metadata 命名空间中 ,但正如您从链接中看到的那样,在Microsoft.EntityFrameworkCore.SqlServer.dll 程序集中定义。 Namespaces and assemblies are different things. In particular ... -
在Xamarin Android项目中使用EF Core创建迁移(Create migrations with EF Core in Xamarin Android project)[2022-01-30]
对不受支持的框架的指导是将您的DbContext代码移动到.NET标准类库中,并使用一个虚拟的.NET Core控制台应用程序和这些工具。 cd MyDbContextProject dotnet ef migrations add MyMigration --startup-project ..\MyDummyProject The guidance for unsupported frameworks is to move your DbContext code into a .NET Standar ... -
builder.HasDefaultSchema()用于为模型设置模式。 MigrationHistory表的配置位不同。 你可以在这里阅读更多相关信息 从链接, 最简单的方案是您只想更改表名称或架构。 这可以使用OnConfiguring中的MigrationsHistoryTable方法(或ASP.NET Core上的ConfigureServices)来完成。 这是一个例子。 protected override void OnConfiguring(DbContextOptionsBuilder o ...
-
如何在EF Core 2.0中修改查询到SQL Server之前?(How to modify query in EF Core 2.0, before it goes to the SQL Server?)[2022-01-06]
看看这个 https://blogs.msdn.microsoft.com/dotnet/2016/09/29/implementing-seeding-custom-conventions-and-interceptors-in-ef-core-1-0/ 您可以覆盖save changes以检测,在保存到数据库之前修改更改 例: public override int SaveChanges(bool acceptAllChangesOnSuccess) { ChangeTracker.Dete ... -
首先,将注释从模型流向迁移操作。 通过覆盖特定于提供程序的IMigrationsAnnotationProvider服务来执行此操作。 class MyMigrationsAnnotationProvider : SqlServerMigrationsAnnotationProvider { public override IEnumerable
For(IProperty property) => base.For(property) ... -
你可以这样做: context.Database.Migrate(); You can do this: context.Database.Migrate();