这是indexloc提供的服务,不要输入任何密码
Skip to content

Throw exception when PublishAsync #80

@trumhemcut

Description

@trumhemcut

My config at Startup.cs

            services.AddDbContext<TradeBotDbContext>(ServiceLifetime.Transient);

            services.AddCap(cap =>
            {
                cap.UseEntityFramework<TradeBotDbContext>();
                cap.UseRabbitMQ(Configuration["CAP:RabbitMQ:HostName"]);
            });
            services.AddTransient<ICapPublisher, CapPublisher>();
            services.AddMvc();
            services.AddSingleton<IHostedService, TradeBotService>();

Then, Just simply call this in the Service

await CapPublisher.PublishAsync("test", new { Message = "Hello World" });

And it throws the exception The transaction operation cannot be performed because there are pending requests working on this transaction. sometimes.

It throws here:

        private void ClosedCap()
        {
            if (IsCapOpenedTrans)
            {
                DbTransaction.Commit(); // THROW WHEN CALLING HERE
                DbTransaction.Dispose();
            }
            if (IsCapOpenedConn)
                DbConnection.Dispose();
        }

I'm using SQL Server on Linux as the storage

UPDATED:
Trying with the Postgres and it says:
A command is already in progress: INSERT INTO Cap.[Published] ([Name],[Content],[Retries],[Added],[ExpiresAt],[StatusName])VALUES(@Name,@Content,@Retries,@Added,@ExpiresAt,@StatusName)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions