Complete xEventService ...
This commit is contained in:
@@ -40,7 +40,8 @@ namespace xEventService.Providers
|
||||
{
|
||||
//
|
||||
// Validating Configuration ...
|
||||
if (configuration.Broker != XEventBroker.XKafka)
|
||||
if (!configuration.ZeroMQ.IsValid() ||
|
||||
configuration.Broker != XEventBroker.XZeroMQ)
|
||||
{
|
||||
XException.InvalidConfiguration.Throw();
|
||||
}
|
||||
@@ -61,6 +62,7 @@ namespace xEventService.Providers
|
||||
{
|
||||
//
|
||||
await Task.Yield();
|
||||
logger.LogInformation($"ZeroMQ Cosume Topic: {topic} ...");
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
//
|
||||
@@ -70,6 +72,7 @@ namespace xEventService.Providers
|
||||
string receivedTopic = string.Empty;
|
||||
byte[] body = null;
|
||||
|
||||
//
|
||||
if (configuration.ZeroMQ.Pattern == XZeroMQPattern.PubSub)
|
||||
{
|
||||
//
|
||||
@@ -80,6 +83,10 @@ namespace xEventService.Providers
|
||||
{
|
||||
// Process
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogError($"ZeroMQ Cosume Error ...");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -88,8 +95,13 @@ namespace xEventService.Providers
|
||||
{
|
||||
// Process
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogError($"ZeroMQ Cosume Error ...");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (body != null && body.Length > 0)
|
||||
{
|
||||
//
|
||||
@@ -113,8 +125,10 @@ namespace xEventService.Providers
|
||||
await Task.Delay(10, cancellationToken);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
//
|
||||
logger.LogError($"ZeroMQ Cosume Error: {ex.Message} ...");
|
||||
await Task.Delay(1000, cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -123,7 +137,12 @@ namespace xEventService.Providers
|
||||
public override async Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
//
|
||||
socket.Close();
|
||||
if (socket != null)
|
||||
{
|
||||
socket.Close();
|
||||
}
|
||||
|
||||
//
|
||||
await base.StopAsync(cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user