Use Management Application API restart; drop stopcontainer.bat as primary.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1507,10 +1507,11 @@ namespace ZA.CoreService.ESBCertificateManager
|
||||
this,
|
||||
$"Container wirklich neu starten?\n\n" +
|
||||
$"Ziele: {targetNames}\n\n" +
|
||||
"Wie in der Sonic Management Console:\n" +
|
||||
"stopcontainer.bat / startcontainer.bat unter SonicHome\\bin\n" +
|
||||
"(z.B. proalpha-test.DE-Test).\n\n" +
|
||||
"Keine separate Domain-Console nötig – nur SMC + SonicHome.",
|
||||
"Laut Sonic/CX-Messenger Doku (Management Application API):\n" +
|
||||
"IAgentProxy.restart – dieselbe Aktion wie Restart in der SMC.\n" +
|
||||
$"Verbindung: appsettings ConnectionUrl + User/Pass.\n" +
|
||||
"Kein stopcontainer.bat nötig.\n\n" +
|
||||
"Voraussetzung: Java + Client-JARs unter SonicHome\\lib (SMC-Installation).",
|
||||
"ESB neu starten",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Warning);
|
||||
@@ -1830,17 +1831,19 @@ namespace ZA.CoreService.ESBCertificateManager
|
||||
?? _sonicDiscovery.Connections[0];
|
||||
|
||||
string sonicHome = string.IsNullOrWhiteSpace(conn.SonicHome) ? "(leer)" : conn.SonicHome.Trim();
|
||||
(bool binOk, string? binErr, _) = new SonicBinRestartExecutor(conn).Probe();
|
||||
string binDisplay = binOk ? "stop/startcontainer=ok" : $"bin=fehlt ({binErr})";
|
||||
(string home, string? javaExe) = new SonicMfApiExecutor(conn).ResolveRuntimePaths();
|
||||
string javaDisplay = string.IsNullOrWhiteSpace(javaExe)
|
||||
? "java=? (unter SonicHome/JRE setzen)"
|
||||
: $"java={javaExe}";
|
||||
string baseText =
|
||||
$"{conn.ManagementModeDisplay} | SonicHome={sonicHome} | {binDisplay}";
|
||||
$"{conn.ManagementModeDisplay} | SonicHome={home} | {javaDisplay}";
|
||||
if (!string.IsNullOrWhiteSpace(suffix))
|
||||
{
|
||||
baseText = $"{suffix} | {baseText}";
|
||||
}
|
||||
|
||||
lblSonicStatus.Text = baseText;
|
||||
lblSonicStatus.ForeColor = binOk ? GreenColor : GoldColor;
|
||||
lblSonicStatus.ForeColor = string.IsNullOrWhiteSpace(javaExe) ? GoldColor : GreenColor;
|
||||
}
|
||||
|
||||
private static string TruncateStatus(string? text, int max = 120)
|
||||
|
||||
@@ -44,11 +44,12 @@ public sealed class SonicConnection
|
||||
/// HttpApi = REST (falls vorhanden).
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// Standard: LocalCmd = wie SMC-Neustart über SonicHome\bin\stopcontainer/startcontainer
|
||||
/// (gleiche Aktion wie Container in der Management Console stoppen/starten).
|
||||
/// Optional: MfApi (Java-Client) oder WinRm.
|
||||
/// Standard: MfApi = Management Application API (wie SMC):
|
||||
/// JMSConnectorClient + MFProxyFactory.createAgentProxy + IAgentProxy.restart.
|
||||
/// Laut CX-Messenger-Doku-Index: Docs2017/api/mgmt_api (nicht stopcontainer.bat).
|
||||
/// LocalCmd nur wenn Server-Scripts existieren (bei reiner SMC oft nicht der Fall).
|
||||
/// </summary>
|
||||
public SonicManagementMode ManagementMode { get; init; } = SonicManagementMode.LocalCmd;
|
||||
public SonicManagementMode ManagementMode { get; init; } = SonicManagementMode.MfApi;
|
||||
|
||||
/// <summary>
|
||||
/// Effektiver Modus: bei WinRm und lokalem ConnectionUrl-Host wird LocalCmd erzwungen.
|
||||
@@ -70,8 +71,8 @@ public sealed class SonicConnection
|
||||
? "LocalCmd (Host lokal erkannt)"
|
||||
: EffectiveManagementMode switch
|
||||
{
|
||||
SonicManagementMode.LocalCmd => "LocalCmd (SMC stop/startcontainer)",
|
||||
SonicManagementMode.MfApi => "MfApi (optional, braucht Java)",
|
||||
SonicManagementMode.MfApi => "MfApi (SMC Management Application API)",
|
||||
SonicManagementMode.LocalCmd => "LocalCmd (nur wenn stopcontainer.bat existiert)",
|
||||
_ => EffectiveManagementMode.ToString()
|
||||
};
|
||||
|
||||
|
||||
@@ -9,15 +9,14 @@ namespace ZA.CoreService.ESBCertificateManager.Services;
|
||||
/// <summary>
|
||||
/// Verwaltet Sonic ESB Container über die Management Console.
|
||||
///
|
||||
/// Modus = MfApi (Standard):
|
||||
/// Offizielle Sonic MF Management Runtime API über ConnectionUrl + SMC-Logins
|
||||
/// (JMSConnectorClient → MFProxyFactory.createAgentProxy → IAgentProxy.restart).
|
||||
/// Modus = MfApi (Standard, laut Aurea CX Messenger Doku-Index → Management Application API):
|
||||
/// Dieselbe Aktion wie „Restart“ in der Sonic Management Console:
|
||||
/// JMSConnectorClient → MFProxyFactory.createAgentProxy → IAgentProxy.restart
|
||||
/// über ConnectionUrl + SMC-User/Pass aus appsettings.
|
||||
/// stopcontainer.bat wird NICHT verwendet (existiert in vielen SMC-only Installationen nicht).
|
||||
///
|
||||
/// Modus = WinRm / LocalCmd (optionaler Fallback):
|
||||
/// PowerShell/CMD stopcontainer/startcontainer (nicht Domain-Manager-nativ).
|
||||
///
|
||||
/// Modus = HttpApi:
|
||||
/// HTTP REST API mit automatischer Pfad-Erkennung.
|
||||
/// Modus = LocalCmd / WinRm: nur optional, wenn Server-Scripts vorhanden sind.
|
||||
/// Modus = HttpApi: REST falls vorhanden.
|
||||
/// </summary>
|
||||
public sealed class SonicManagementClient : IDisposable
|
||||
{
|
||||
@@ -346,31 +345,16 @@ public sealed class SonicManagementClient : IDisposable
|
||||
$"Domain={_connection.DomainName}; ConnectionUrl={_connection.ConnectionUrl}\n{output}");
|
||||
}
|
||||
|
||||
// Kein Java / keine Client-JARs → offizieller Doku-Weg über stop/startcontainer.bat
|
||||
bool softFail = error?.Contains("Java nicht gefunden", StringComparison.OrdinalIgnoreCase) == true
|
||||
|| error?.Contains("Client-JARs", StringComparison.OrdinalIgnoreCase) == true
|
||||
|| error?.Contains("lib", StringComparison.OrdinalIgnoreCase) == true;
|
||||
|
||||
if (softFail)
|
||||
{
|
||||
SonicBinRestartExecutor bin = new(_connection);
|
||||
(bool binOk, string binStatus, string? binDetail) =
|
||||
await bin.RestartAsync(containerName, cancellationToken);
|
||||
if (binOk)
|
||||
{
|
||||
return (true, binStatus,
|
||||
$"MfApi nicht nutzbar ({Truncate(error ?? string.Empty, 160)}) – Fallback SonicBin:\n{binDetail}");
|
||||
}
|
||||
|
||||
return (false, "Neustart fehlgeschlagen (MfApi→SonicBin)",
|
||||
$"MfApi: {error}\n\nSonicBin-Fallback: {binDetail}\n" +
|
||||
$"SonicHome='{_connection.SonicHome}' muss stopcontainer.bat enthalten.");
|
||||
}
|
||||
|
||||
return (false, "Neustart fehlgeschlagen (MfApi)",
|
||||
$"IAgentProxy.restart für '{containerName}' (Domain '{_connection.DomainName}') " +
|
||||
$"über {_connection.ConnectionUrl} fehlgeschlagen.\n" +
|
||||
$"Fehler: {error}\nAusgabe: {output}");
|
||||
"Laut Doku (Management Application API / wie SMC-Restart):\n" +
|
||||
"JMSConnectorClient + MFProxyFactory.createAgentProxy + IAgentProxy.restart\n\n" +
|
||||
$"Container '{containerName}', Domain '{_connection.DomainName}', URL {_connection.ConnectionUrl}\n" +
|
||||
$"Fehler: {error}\nAusgabe: {output}\n\n" +
|
||||
"Benötigt (SMC-Installation):\n" +
|
||||
$"- SonicHome={_connection.SonicHome} mit lib\\*.jar (mgmt_client / mfcontext / sonic_Client)\n" +
|
||||
"- Java (JavaHome/JavaPath oder JRE unter SonicHome)\n" +
|
||||
"- Dieselben ConnectionUrl/User/Pass wie beim SMC-Login\n" +
|
||||
"Hinweis: stopcontainer.bat wird nicht verwendet (in SMC-only Versionen oft nicht vorhanden).");
|
||||
}
|
||||
|
||||
private static async Task<bool> IsTcpReachableAsync(string connectionUrl, CancellationToken cancellationToken)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"ConnectionUrl": "tcp://dekun-painwbdet:13070",
|
||||
"Username": "Administrator",
|
||||
"Password": "Administrator",
|
||||
"ManagementMode": "LocalCmd",
|
||||
"ManagementMode": "MfApi",
|
||||
"SonicHome": "C:\\DEV\\MQ10.0",
|
||||
"JavaHome": "",
|
||||
"JavaPath": "",
|
||||
|
||||
Reference in New Issue
Block a user