Skip to content

Commit

Permalink
2.4.1.2 version, merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
AlesMrak committed Dec 4, 2023
2 parents f63270f + d287057 commit 91174f4
Show file tree
Hide file tree
Showing 15 changed files with 110 additions and 41 deletions.
3 changes: 3 additions & 0 deletions Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ The package contains:
- Resources containing the log4net configuration needed by the MTS SDK

CHANGE LOG:
2023-11-30 2.4.1.2
Changed timings on reconnects, updated guides

2022-11-30 2.4.1.1
Changed url stgapi.betradar.com and api.betradar.com to global

Expand Down
4 changes: 3 additions & 1 deletion build/Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
For more information please contact [email protected] or visit http://sdk.sportradar.com/mts/net

CHANGE LOG:
CHANGE LOG:
2023-11-30 2.4.1.2
Changed timings on reconnects, updated guides

2022-11-30 2.4.1.1
Changed url stgapi.betradar.com and api.betradar.com to global

Expand Down
4 changes: 2 additions & 2 deletions build/build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<MajorVersion Condition="'$(MajorVersion)' == ''">2</MajorVersion>
<MinorVersion Condition="'$(MinorVersion)' == ''">4</MinorVersion>
<BuildNumber Condition="'$(BuildNumber)' == ''">1</BuildNumber>
<Revision Condition="'$(Revision)' == ''">1</Revision>
<Revision Condition="'$(Revision)' == ''">2</Revision>
<BuildPlanName Condition="'$(BuildPlanName)' == ''">LocalBuild</BuildPlanName>
<BuildKey Condition="'$(BuildKey)' == ''">NOKEY</BuildKey>
<Timestamp>$([System.DateTime]::Now.ToString("yyyy-MM-dd\THH:mm:ss"))</Timestamp>

<!-- you get new line with inserting !NL! -->
<BuildChangeLog>Changed url stgapi.betradar.com and api.betradar.com to global</BuildChangeLog>
<BuildChangeLog>Changed timings on reconnects, updated guides</BuildChangeLog>
<ComputedAssemblyVersion>$(MajorVersion).$(MinorVersion).$(BuildNumber).$(Revision)</ComputedAssemblyVersion>
<ComputedAssemblyVersionNormalized>$(MajorVersion).$(MinorVersion).$(BuildNumber)</ComputedAssemblyVersionNormalized>
</PropertyGroup>
Expand Down
Binary file modified docs/MTS SDK NET integration guide.docx
Binary file not shown.
Binary file modified docs/MTS SDK NET integration guide.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
<Reference Include="RabbitMQ.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce, processorArchitecture=MSIL">
<HintPath>..\packages\RabbitMQ.Client.4.1.3\lib\net451\RabbitMQ.Client.dll</HintPath>
</Reference>
<Reference Include="Sportradar.MTS.SDK, Version=2.4.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Sportradar.MTS.SDK.2.4.1\lib\net45\Sportradar.MTS.SDK.dll</HintPath>
<Reference Include="Sportradar.MTS.SDK, Version=2.4.1.2, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Sportradar.MTS.SDK.2.4.1.2\lib\net45\Sportradar.MTS.SDK.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
Expand Down Expand Up @@ -93,7 +93,6 @@
<Compile Include="Example\Examples.cs" />
<Compile Include="Example\NonSrSettle.cs" />
<Compile Include="Example\Reoffer.cs" />
<Compile Include="obj\Debug\.NETFramework,Version=v4.5.1.AssemblyAttributes.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Start.cs" />
<Compile Include="Tickets\TicketExamples.cs" />
Expand All @@ -106,9 +105,6 @@
<None Include="log4net.sdk.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="obj\Debug\build.force" />
<None Include="obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache" />
<None Include="obj\Debug\Sportradar.MTS.SDK.DemoProject.csprojAssemblyReference.cache" />
<None Include="packages.config" />
<None Include="Tickets\Example1.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down Expand Up @@ -153,14 +149,6 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="obj\Debug\Sportradar.MTS.SDK.csproj.FileListAbsolute.txt" />
<Content Include="obj\Debug\Sportradar.MTS.SDK.DemoProject.csproj.FileListAbsolute.txt" />
<Content Include="obj\Debug\Sportradar.MTS.SDK.dll" />
<Content Include="obj\Debug\Sportradar.MTS.SDK.pdb" />
</ItemGroup>
<ItemGroup>
<Folder Include="obj\Debug\TempPE\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
2 changes: 1 addition & 1 deletion example/Sportradar.MTS.SDK.DemoProject/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<package id="NETStandard.Library" version="1.6.1" targetFramework="net451" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net451" />
<package id="RabbitMQ.Client" version="4.1.3" targetFramework="net451" />
<package id="Sportradar.MTS.SDK" version="2.4.1.1" targetFramework="net451" />
<package id="Sportradar.MTS.SDK" version="2.4.1.2" targetFramework="net451" />
<package id="System.Collections" version="4.3.0" targetFramework="net451" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net451" />
<package id="System.ComponentModel.Annotations" version="4.3.0" targetFramework="net451" />
Expand Down
6 changes: 3 additions & 3 deletions src/Sportradar.MTS.SDK.Test/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Sportradar.MTS.SDK.Test")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyCopyright("Copyright © 2017-2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -34,5 +34,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.4.1.1")]
[assembly: AssemblyFileVersion("2.4.1.1")]
[assembly: AssemblyVersion("2.4.1.2")]
[assembly: AssemblyFileVersion("2.4.1.2")]
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal class ChannelFactory : IChannelFactory, IDisposable

/// <summary>
/// The <see cref="IConnection"/> representing connection to the broker
/// </summary>
/// </summary>
private IConnection _connection;

/// <summary>
Expand Down Expand Up @@ -224,7 +224,12 @@ public ChannelWrapper GetChannel(int id)

if (!_connection.IsOpen)
{
throw new ConnectFailureException("Cannot create the channel because the connection is closed.", null);
if (_connectionStatus.IsConnected)
{
ExecutionLog.Error($"Error ConnectionStatus is connected: {id}");
_connectionStatus.Disconnect("No connection present!");
}
throw new ConnectFailureException("Cannot create the channel because the connection is closed. Connection Status:" + _connectionStatus.IsConnected, null);
}

if (_models.TryGetValue(id, out var wrapper) && wrapper != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
/*
* Copyright (C) Sportradar AG. See LICENSE for full license governing this code
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.Security;
using System.Security.Authentication;
using System.Threading;
using Dawn;
using log4net;
using RabbitMQ.Client;
using Sportradar.MTS.SDK.Common.Internal;
using Sportradar.MTS.SDK.Common.Log;
using Sportradar.MTS.SDK.Entities.Internal;

namespace Sportradar.MTS.SDK.API.Internal.RabbitMq
{
Expand All @@ -16,10 +22,12 @@ namespace Sportradar.MTS.SDK.API.Internal.RabbitMq
/// </summary>
internal class ConfiguredConnectionFactory : ConnectionFactory
{
private static readonly ILog _log = SdkLoggerFactory.GetLogger(typeof(ChannelFactory));
/// <summary>
/// A <see cref="IRabbitServer"/> instance containing server information
/// </summary>
private readonly IRabbitServer _server;
private static volatile int termninationCount = 0;

/// <summary>
/// Value indicating whether the current <see cref="ConfiguredConnectionFactory"/> was already configured
Expand Down Expand Up @@ -79,11 +87,75 @@ private void Configure()
/// <exception cref="T:RabbitMQ.Client.Exceptions.BrokerUnreachableException">When the configured host name was not reachable</exception>
public override IConnection CreateConnection()
{
if (Interlocked.CompareExchange(ref _configured, 1, 0) == 0)
IConnection connection = null;
try
{
Configure();
if (Interlocked.CompareExchange(ref _configured, 1, 0) == 0)
{
Configure();
}
connection = ExecuteWithTimeout(TimeSpan.FromMilliseconds(3000));
}
return base.CreateConnection();
catch(Exception ex)
{
_log.Error(ex.Message, ex);
_log.Warn($"Error ConfiguredConnectionFactory.CreateConnection!");
}
return connection;
}

private IConnection CreateConnectionThread()
{
try
{
Thread thread = Thread.CurrentThread;
thread.IsBackground = true;
if (Interlocked.CompareExchange(ref _configured, 1, 0) == 0)
{
Configure();
}
return base.CreateConnection(GenerateConnectionName());
}
catch (Exception ex)
{
_log.Error(ex.Message, ex);
_log.Warn($"Error ConfiguredConnectionFactory.CreateConnection!");
}
return null;
}

private IConnection ExecuteWithTimeout(TimeSpan timeout)
{
IConnection connection = null;
Thread createConnectionThread = new Thread(() => {
connection = CreateConnectionThread();
});

bool finished = false;
try
{
createConnectionThread.Start();
finished = createConnectionThread.Join(timeout);
if (!finished)
{
createConnectionThread.Abort();
termninationCount++;
_log.Error($"Aborted ConfiguredConnectionFactory.CreateConnection number:{termninationCount}!");
}
} catch(Exception ex)
{
_log.Error(ex.Message, ex);
_log.Warn($"Error ConfiguredConnectionFactory.CreateConnection!");
}

return connection;
}


public string GenerateConnectionName()
{
var systemStartTime = DateTime.Now.AddMilliseconds(-Environment.TickCount);
return $"MTS|NET|{SdkInfo.GetVersion()}|{DateTime.Now:yyyyMMddHHmm}|{TicketHelper.DateTimeToUnixTime(systemStartTime)}|{Process.GetCurrentProcess().Id}";
}

private static bool ShouldUseCertificateValidation(string hostName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public void Open(string queueName, IEnumerable<string> routingKeys)

private void CreateAndOpenConsumerChannel()
{
var sleepTime = 1000;
var sleepTime = 100;
while (Interlocked.Read(ref _shouldBeOpened) == 1)
{
lock (_lock)
Expand Down Expand Up @@ -270,15 +270,14 @@ private void CreateAndOpenConsumerChannel()
}
catch (Exception e)
{
ExecutionLog.Info($"Error opening the consumer channel with channelNumber: {UniqueId} and queueName: {_queueName}.",
e);
ExecutionLog.Info($"Error opening the consumer channel with channelNumber: {UniqueId} and queueName: {_queueName}.", e);
if (e is IOException || e is AlreadyClosedException || e is SocketException)
{
sleepTime = SdkInfo.Increase(sleepTime, 500, 10000);
sleepTime = SdkInfo.Increase(sleepTime, 500, 5000);
}
else
{
sleepTime = SdkInfo.Multiply(sleepTime, 1.25, _channelSettings.PublishQueueTimeoutInMs1 * 1000);
sleepTime = SdkInfo.Multiply(sleepTime, 1.25, 5000);
}

ExecutionLog.Info($"Opening the consumer channel will be retried in next {sleepTime} ms.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ private IMqPublishResult PublishMsg(string ticketId, byte[] msg, string routingK

private void CreateAndOpenPublisherChannel()
{
var sleepTime = 1000;
var sleepTime = 100;
while (Interlocked.Read(ref _shouldBeOpened) == 1)
{
try
Expand Down Expand Up @@ -384,7 +384,7 @@ private void CreateAndOpenPublisherChannel()
}
else
{
sleepTime = SdkInfo.Multiply(sleepTime, 1.25, _channelSettings.MaxPublishQueueTimeoutInMs * 1000);
sleepTime = SdkInfo.Multiply(sleepTime, 1.25, 5000);
}
ExecutionLog.Info($"Opening the publisher channel will be retried in next {sleepTime} ms.");
Thread.Sleep(sleepTime);
Expand Down
8 changes: 4 additions & 4 deletions src/Sportradar.MTS.SDK/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Sportradar AG")] // $author$
[assembly: AssemblyProduct("Sportradar MTS SDK")]
[assembly: AssemblyCopyright("Copyright © Sportradar AG 2017-2022")]
[assembly: AssemblyCopyright("Copyright © Sportradar AG 2017-2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -37,6 +37,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyInformationalVersion("2.4.1.1")]
[assembly: AssemblyVersion("2.4.1.1")]
[assembly: AssemblyFileVersion("2.4.1.1")]
[assembly: AssemblyInformationalVersion("2.4.1.2")]
[assembly: AssemblyVersion("2.4.1.2")]
[assembly: AssemblyFileVersion("2.4.1.2")]
2 changes: 1 addition & 1 deletion src/Sportradar.MTS.SDK/Sportradar.MTS.SDK
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@
<member name="F:Sportradar.MTS.SDK.API.Internal.RabbitMq.ChannelFactory._connection">
<summary>
The <see cref="T:RabbitMQ.Client.IConnection"/> representing connection to the broker
</summary>
</summary>
</member>
<member name="F:Sportradar.MTS.SDK.API.Internal.RabbitMq.ChannelFactory._disposed">
<summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Sportradar.MTS.SDK/Sportradar.MTS.SDK.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<title>Sportradar MTS SDK</title>
<authors>Sportradar AG</authors>
<description>The SDK simplifying the integration with Sportradar's MTS services</description>
<version>2.4.1.1</version>
<releaseNotes>Version 2.4.1.1</releaseNotes>
<version>2.4.1.2</version>
<releaseNotes>Version 2.4.1.2</releaseNotes>
<copyright>Copyright © Sportradar AG 2017-2022</copyright>
<repository type="git" url="https://github.com/sportradar/MtsSdkNet.git" branch="master" />
<projectUrl>http://sdk.sportradar.com/mts/net</projectUrl>
Expand Down

0 comments on commit 91174f4

Please sign in to comment.