Ich habe ein [url=viewtopic.php?t=11587]Problem[/url] mit Masstransit und der Saga-Funktion. überschreiben ">[code]Error: MassTransit.ReceiveTransport[0] R-FAULT rabbitmq://localhost/monitoring-job-saga 489a0000-4100-0250-1852-08dd500596e7 Shared.MessagingContracts.JobSubmitted MainApp.MonitoringJobState(00:00:00.0334249) System.NotSupportedException: Send saga is no longer available in IoC at MassTransit.Configuration.RegistrationServiceCollectionExtensions.TempSagaRepository`1.Send[T](ConsumeContext`1 context, ISagaPolicy`2 policy, IPipe`1 next) in /_/src/MassTransit/DependencyInjection/Configuration/RegistrationServiceCollectionExtensions.cs:Line 93 at MassTransit.Middleware.CorrelatedSagaFilter`2.Send(ConsumeContext`1 context, IPipe`1 next) < /code> services.AddMassTransit(x => { x.AddSagaStateMachine() .InMemoryRepository();
cfg.ReceiveEndpoint(sagaQueue, e => { e.StateMachineSaga( context.GetRequiredService(), context.GetRequiredService()); }); }); }); < /code> Überwachungjobstatemachine-Klasse: < /p> using MassTransit; using MainApp.Data; using Shared.MessagingContracts;
namespace MainApp { public class MonitoringJobStateMachine : MassTransitStateMachine { public State Submitted { get; private set; } = null!; public State Processing { get; private set; } = null!; public State Completed { get; private set; } = null!; public State Failed { get; private set; } = null!;
public Event JobSubmittedEvent { get; private set; } = default!; public Event JobCompletedEvent { get; private set; } = default!; public Event JobFailedEvent { get; private set; } = default!;
public Schedule JobTimeoutSchedule { get; private set; } = default!;
public MonitoringJobStateMachine() { InstanceState(x => x.CurrentState);
Console.WriteLine($"[Saga] Job {context.Saga.CorrelationId} submitted. Starting in Region {context.Saga.CurrentRegion}.");
// Sende den ProcessJob-Befehl an die regionalspezifische Queue (z. B. "jobs-de") await context.Publish(new ProcessJobCommand { CorrelationId = context.Saga.CorrelationId, Region = context.Saga.CurrentRegion, Attempt = context.Saga.CurrentAttempt }, publishContext => { // Setzt explizit die Zieladresse für die Nachricht: publishContext.DestinationAddress = new Uri($"queue:jobs-{context.Saga.CurrentRegion.ToLower()}"); }); }) // Plane den Timeout direkt in der Kette .Schedule(JobTimeoutSchedule, ctx => new JobTimeoutMessage { CorrelationId = ctx.Saga.CorrelationId }, ctx => TimeSpan.FromSeconds(10)) .TransitionTo(Processing) );
During(Processing, When(JobCompletedEvent) .Then(ctx => { Console.WriteLine($"[Saga] Job {ctx.Saga.CorrelationId} completed successfully in region {ctx.Message.Region}."); }) .Unschedule(JobTimeoutSchedule) .TransitionTo(Completed),
When(JobFailedEvent) .ThenAsync(async ctx => { Console.WriteLine($"[Saga] Job {ctx.Saga.CorrelationId} failed in region {ctx.Message.Region}. Error: {ctx.Message.ErrorMessage}"); // Erhöhe den Versuchszähler ctx.Saga.CurrentAttempt++; if (ctx.Saga.Regions != null && ctx.Saga.CurrentAttempt < ctx.Saga.Regions.Count) { // Setze die neue Region ctx.Saga.CurrentRegion = ctx.Saga.Regions[ctx.Saga.CurrentAttempt]; Console.WriteLine($"[Saga] Fallback: Retrying job {ctx.Saga.CorrelationId} in region {ctx.Saga.CurrentRegion}.");
// Sende den neuen ProcessJob-Befehl an die neue regionale Queue await ctx.Publish(new ProcessJobCommand { CorrelationId = ctx.Saga.CorrelationId, Region = ctx.Saga.CurrentRegion, Attempt = ctx.Saga.CurrentAttempt }, publishContext => { publishContext.DestinationAddress = new Uri($"queue:jobs-{ctx.Saga.CurrentRegion.ToLower()}"); }); } }) // Plane nach einem Fehlschlag (bzw. nach Timeout) einen neuen Timeout .Schedule(JobTimeoutSchedule, ctx => new JobTimeoutMessage { CorrelationId = ctx.Saga.CorrelationId }, ctx => TimeSpan.FromSeconds(10)) .IfElse(ctx => ctx.Saga.Regions != null && ctx.Saga.CurrentAttempt < ctx.Saga.Regions.Count, binder => binder.TransitionTo(Processing), binder => binder.TransitionTo(Failed) ),
When(JobTimeoutSchedule.Received) .ThenAsync(async ctx => { Console.WriteLine($"[Saga] Timeout in region {ctx.Saga.CurrentRegion} for job {ctx.Saga.CorrelationId}."); // Bei Timeout wird der Versuch ebenfalls erhöht und ein Fallback eingeleitet ctx.Saga.CurrentAttempt++; if (ctx.Saga.Regions != null && ctx.Saga.CurrentAttempt < ctx.Saga.Regions.Count) { ctx.Saga.CurrentRegion = ctx.Saga.Regions[ctx.Saga.CurrentAttempt]; Console.WriteLine($"[Saga] Fallback after timeout: Retrying job {ctx.Saga.CorrelationId} in region {ctx.Saga.CurrentRegion}."); await ctx.Publish(new ProcessJobCommand { CorrelationId = ctx.Saga.CorrelationId, Region = ctx.Saga.CurrentRegion, Attempt = ctx.Saga.CurrentAttempt }, publishContext => { publishContext.DestinationAddress = new Uri($"queue:jobs-{ctx.Saga.CurrentRegion.ToLower()}"); }); } }) .Schedule(JobTimeoutSchedule, ctx => new JobTimeoutMessage { CorrelationId = ctx.Saga.CorrelationId }, ctx => TimeSpan.FromSeconds(10)) ); } } } [/code]
Ich verwende SoapClient mit meiner PHP-Seite, um Daten von Dritten zu sammeln. Ich habe meine max_execution_time auf 50 Sekunden erhöht und diese Fehler werden nicht mehr in den Protokollen...
System : Ich habe zwei Bestelldienste (separate DBs), der erste ist der Dienst Benutzerbestellung , Benutzeroperationen wie „Place-Order“, „Get-Order“, Stornierung, Rückgabe usw. werden hier...
wie man diese unendliche Schleife vermeidet. So fügen Sie in diesem Fall Fehlerbehandlungen hinzu. Wenn eine Anmeldeinformationsfehlübereinstimmung dreimal versucht und aufhören,
wieder zu verbinden...
Ich versuche, Ajax zu rufen. Post Call gibt jedoch 400 Fehler bei xhr.send (options.hascontent && options.data null) Zeile. $.ajax({
type: POST ,
url: /Security/Login ,
async: false,
contentType:...
Gibt es eine Möglichkeit, Kern -Java /Reflexion zu verwenden, um Abhängigkeitsobjekte zu erstellen und sie als Abhängigkeit auf andere zu setzen? geschätzt.