diff --git a/Directory.Packages.props b/Directory.Packages.props
index f088054dc..2a74310f3 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -20,7 +20,6 @@
-
@@ -38,12 +37,7 @@
-
-
-
-
-
diff --git a/src/DurableTask.ServiceBus/Common/Abstraction/ServiceBusAbstraction.cs b/src/DurableTask.ServiceBus/Common/Abstraction/ServiceBusAbstraction.cs
index c8d97b205..26cecadce 100644
--- a/src/DurableTask.ServiceBus/Common/Abstraction/ServiceBusAbstraction.cs
+++ b/src/DurableTask.ServiceBus/Common/Abstraction/ServiceBusAbstraction.cs
@@ -3,120 +3,9 @@ namespace DurableTask.ServiceBus.Common.Abstraction
{
using System;
using System.Collections.Generic;
- using System.IO;
using System.Linq;
- using System.Runtime.Serialization;
using System.Threading.Tasks;
- using System.Xml;
- using DurableTask.ServiceBus.Tracking;
-#if !NETSTANDARD2_0
- using Microsoft.ServiceBus.Messaging;
- public class DataContractBinarySerializer
- {
- public static readonly XmlObjectSerializer Instance = new DataContractBinarySerializer(typeof(T));
- }
-
- ///
- /// This class describes a serializer class used to serialize and deserialize an Object.
- /// This class is almost identical to DataContractSerializer; only difference is that
- /// ReadObject(Stream) and WriteObject(Stream, object) pick Binary Xml Reader/Writer
- /// instead of text.
- ///
- sealed class DataContractBinarySerializer : XmlObjectSerializer
- {
- readonly DataContractSerializer dataContractSerializer;
-
- ///
- /// Initializes a new DataContractBinarySerializer instance
- ///
- public DataContractBinarySerializer(Type type)
- {
- this.dataContractSerializer = new DataContractSerializer(type);
- }
-
- ///
- /// Converts from stream to the corresponding object
- ///
- /// Object corresponding to the stream
- /// Override the default (Text) and use Binary Xml Reader instead
- public override object ReadObject(Stream stream)
- {
- return this.ReadObject(XmlDictionaryReader.CreateBinaryReader(stream, XmlDictionaryReaderQuotas.Max));
- }
-
- ///
- /// Serializes the object into the stream
- ///
- /// Override the default (Text) and use Binary Xml Reader instead
- public override void WriteObject(Stream stream, object graph)
- {
- if (stream == null)
- {
- throw new ArgumentNullException(nameof(stream));
- }
-
- var xmlDictionaryWriter = XmlDictionaryWriter.CreateBinaryWriter(stream, null, null, false);
- this.WriteObject(xmlDictionaryWriter, graph);
- xmlDictionaryWriter.Flush();
- }
-
- ///
- /// Serializes the object into the stream using the XmlDictionaryWriter
- ///
- public override void WriteObject(XmlDictionaryWriter writer, object graph)
- {
- if (writer == null)
- {
- throw new ArgumentNullException(nameof(writer));
- }
-
- this.dataContractSerializer.WriteObject(writer, graph);
- }
-
- ///
- /// This method simply delegates to the DataContractSerializer implementation
- ///
- public override bool IsStartObject(XmlDictionaryReader reader)
- {
- return this.dataContractSerializer.IsStartObject(reader);
- }
-
- ///
- /// This method simply delegates to the DataContractSerializer implementation
- ///
- public override object ReadObject(XmlDictionaryReader reader, bool verifyObjectName)
- {
- return this.dataContractSerializer.ReadObject(reader, verifyObjectName);
- }
-
- ///
- /// This method simply delegates to the DataContractSerializer implementation
- ///
- public override void WriteEndObject(XmlDictionaryWriter writer)
- {
- this.dataContractSerializer.WriteEndObject(writer);
- }
-
- ///
- /// This method simply delegates to the DataContractSerializer implementation
- ///
- public override void WriteObjectContent(XmlDictionaryWriter writer, object graph)
- {
- this.dataContractSerializer.WriteObjectContent(writer, graph);
- }
-
- ///
- /// This method simply delegates to the DataContractSerializer implementation
- ///
- public override void WriteStartObject(XmlDictionaryWriter writer, object graph)
- {
- this.dataContractSerializer.WriteStartObject(writer, graph);
- }
- }
-#endif
-
-#if NETSTANDARD2_0
///
public class IMessageSession
{
@@ -177,86 +66,16 @@ public async Task CloseAsync()
{
await this.sessionReceiver.CloseAsync();
}
-#else
- public class IMessageSession
- {
- MessageSession session;
-
- public IMessageSession(MessageSession session)
- {
- this.session = session;
- }
-
- public static implicit operator IMessageSession(MessageSession s)
- {
- return new IMessageSession(s);
- }
-
- public string SessionId => this.session.SessionId;
-
- public DateTime LockedUntilUtc => this.session.LockedUntilUtc;
-
- public async Task GetStateAsync()
- {
- Stream state = await this.session.GetStateAsync();
- if (state == null)
- return null;
- using (var ms = new MemoryStream())
- {
- state.CopyTo(ms);
- return ms.ToArray();
- }
- }
-
- public async Task SetStateAsync(byte[] sessionState)
- {
- if (sessionState == null)
- {
- await this.session.SetStateAsync(null);
- return;
- }
-
- var stream = new MemoryStream();
- stream.Write(sessionState, 0, sessionState.Length);
- await this.session.SetStateAsync(stream);
- }
-
- public async Task RenewSessionLockAsync()
- {
- await this.session.RenewLockAsync();
- }
-
- public async Task AbandonAsync(Message message)
- {
- await this.session.AbandonAsync(message.SystemProperties.LockToken);
- }
-
- public async Task> ReceiveAsync(int maxMessageCount)
- {
- return (await this.session.ReceiveBatchAsync(maxMessageCount)).Select(x => (Message)x).ToList();
- }
-
- public async Task CompleteAsync(IEnumerable messages)
- {
- await this.session.CompleteBatchAsync(messages.Select(m => m.SystemProperties.LockToken).ToList());
- }
-
- public async Task CloseAsync()
- {
- await this.session.CloseAsync();
- }
-#endif
}
-#if NETSTANDARD2_0
public abstract class Union
{
public abstract T Match(Func f, Func g);
public abstract void Switch(Action f, Action g);
- private Union() { }
+ private Union() { }
public sealed class Case1 : Union
{
@@ -339,7 +158,6 @@ public Message(byte[] serializableObject)
this.message = new Union.Case1(new Azure.Messaging.ServiceBus.ServiceBusMessage(new BinaryData(serializableObject)));
this.SystemProperties = new SystemPropertiesCollection(message);
}
-
public string MessageId
{
@@ -420,170 +238,14 @@ public SystemPropertiesCollection(Union throw NotReceivedMessagePropertyGetException(),
rm => rm.EnqueuedTime.UtcDateTime);
}
-
-#else
-
- public class Message : IDisposable
- {
- BrokeredMessage brokered;
-
- public Message(BrokeredMessage brokered)
- {
- this.brokered = brokered;
- this.SystemProperties = new SystemPropertiesCollection(this.brokered);
- }
-
- public static implicit operator Message(BrokeredMessage b)
- {
- return b == null ? null : new Message(b);
- }
-
- public static implicit operator BrokeredMessage(Message m)
- {
- return m.brokered;
- }
-
- public Message()
- {
- this.brokered = new BrokeredMessage();
- this.SystemProperties = new SystemPropertiesCollection(this.brokered);
- }
-
- public Message(object serializableObject)
- {
- this.brokered = new BrokeredMessage(serializableObject);
- this.SystemProperties = new SystemPropertiesCollection(this.brokered);
- }
-
- public Message(Stream stream)
- {
- this.brokered = new BrokeredMessage(stream);
- this.SystemProperties = new SystemPropertiesCollection(this.brokered);
- }
-
- public string MessageId
- {
- get => this.brokered?.MessageId;
- set => this.brokered.MessageId = value;
- }
-
- public DateTime ScheduledEnqueueTimeUtc
- {
- get => this.brokered.ScheduledEnqueueTimeUtc;
- set => this.brokered.ScheduledEnqueueTimeUtc = value;
- }
-
- public SystemPropertiesCollection SystemProperties { get; private set; }
-
- public IDictionary UserProperties => this.brokered.Properties;
-
- public string SessionId
- {
- get => this.brokered?.SessionId;
- set => this.brokered.SessionId = value;
- }
- public T GetBody()
- {
- return this.brokered.GetBody();
- }
-
- ///
- public void Dispose()
- {
- this.brokered.Dispose();
- this.brokered = null;
- }
}
- public class SystemPropertiesCollection
- {
- readonly BrokeredMessage _brokered;
-
- ///
- public SystemPropertiesCollection(BrokeredMessage brokered)
- {
- this._brokered = brokered;
- }
-
- /// Gets the lock token for the current message.
- ///
- /// The lock token is a reference to the lock that is being held by the broker in mode.
- /// Locks are used to explicitly settle messages as explained in the product documentation in more detail.
- /// The token can also be used to pin the lock permanently through the Deferral API and, with that, take the message out of the
- /// regular delivery state flow. This property is read-only.
- ///
- public Guid LockToken => this._brokered.LockToken;
-
- /// Get the current delivery count.
- /// This value starts at 1.
- ///
- /// Number of deliveries that have been attempted for this message. The count is incremented when a message lock expires,
- /// or the message is explicitly abandoned by the receiver. This property is read-only.
- ///
- public int DeliveryCount => this._brokered.DeliveryCount;
-
- /// Gets the date and time in UTC until which the message will be locked in the queue/subscription.
- /// The date and time until which the message will be locked in the queue/subscription.
- ///
- /// For messages retrieved under a lock (peek-lock receive mode, not pre-settled) this property reflects the UTC
- /// instant until which the message is held locked in the queue/subscription. When the lock expires, the
- /// is incremented and the message is again available for retrieval. This property is read-only.
- ///
- public DateTime LockedUntilUtc => this._brokered.LockedUntilUtc;
-
- /// Gets the unique number assigned to a message by Service Bus.
- ///
- /// The sequence number is a unique 64-bit integer assigned to a message as it is accepted
- /// and stored by the broker and functions as its true identifier. For partitioned entities,
- /// the topmost 16 bits reflect the partition identifier. Sequence numbers monotonically increase.
- /// They roll over to 0 when the 48-64 bit range is exhausted. This property is read-only.
- ///
- public long SequenceNumber => this._brokered.SequenceNumber;
-
- /// Gets or sets the date and time of the sent time in UTC.
- /// The enqueue time in UTC.
- ///
- /// The UTC instant at which the message has been accepted and stored in the entity.
- /// This value can be used as an authoritative and neutral arrival time indicator when
- /// the receiver does not want to trust the sender's clock. This property is read-only.
- ///
- public DateTime EnqueuedTimeUtc => this._brokered.EnqueuedTimeUtc;
-
-#endif
- }
-
-#if NETSTANDARD2_0
///
public abstract class RetryPolicy : Azure.Messaging.ServiceBus.ServiceBusRetryPolicy
{
-#else
-
- public class RetryPolicy
- {
- Microsoft.ServiceBus.RetryPolicy policy;
-
- public RetryPolicy(Microsoft.ServiceBus.RetryPolicy policy)
- {
- this.policy = policy;
- }
-
- public static implicit operator RetryPolicy(Microsoft.ServiceBus.RetryPolicy rp)
- {
- return new RetryPolicy(rp);
- }
-
- public static implicit operator Microsoft.ServiceBus.RetryPolicy(RetryPolicy rp)
- {
- return rp.policy;
- }
-
- public static RetryPolicy Default => Microsoft.ServiceBus.RetryPolicy.Default;
-
-#endif
}
-#if NETSTANDARD2_0
///
public class ServiceBusConnection
{
@@ -628,22 +290,8 @@ public Azure.Messaging.ServiceBus.ServiceBusClient GetSendViaEntityScopedClient(
sendViaEntityScopedServiceBusClients.Add(sendViaEntity, newClient);
return newClient;
}
-#else
- public class ServiceBusConnection
- {
- public ServiceBusConnection(ServiceBusConnectionStringBuilder connectionStringBuilder)
- {
- ConnectionString = connectionStringBuilder.ToString();
- }
-
- public string ConnectionString { get; private set; }
-
- public TokenProvider TokenProvider { get; set; }
-
-#endif
}
-#if NETSTANDARD2_0
///
public class ServiceBusConnectionStringBuilder
{
@@ -660,50 +308,8 @@ public ServiceBusConnectionStringBuilder(string connectionString)
public string SasKeyName => ConnectionStringProperties.SharedAccessKeyName;
public string SasKey => ConnectionStringProperties.SharedAccessKey;
-#else
- public class ServiceBusConnectionStringBuilder : Microsoft.ServiceBus.ServiceBusConnectionStringBuilder
- {
- public ServiceBusConnectionStringBuilder(string connectionString)
- : base(connectionString)
- {
- }
-
- public string SasKeyName => base.SharedAccessKeyName;
-
- public string SasKey => base.SharedAccessKey;
-
-#endif
}
-#if NETSTANDARD2_0
-#else
- public class TokenProvider
- {
- private Microsoft.ServiceBus.TokenProvider tokenProvider;
-
- public TokenProvider(Microsoft.ServiceBus.TokenProvider t)
- {
- this.tokenProvider = t;
- }
-
- public static implicit operator TokenProvider(Microsoft.ServiceBus.TokenProvider t)
- {
- return new TokenProvider(t);
- }
-
- public static implicit operator Microsoft.ServiceBus.TokenProvider(TokenProvider t)
- {
- return t.tokenProvider;
- }
-
- public static TokenProvider CreateSharedAccessSignatureTokenProvider(string keyName, string sharedAccessKey, TimeSpan tokenTimeToLive)
- {
- return Microsoft.ServiceBus.TokenProvider.CreateSharedAccessSignatureTokenProvider(keyName, sharedAccessKey, tokenTimeToLive);
- }
- }
-#endif
-
-#if NETSTANDARD2_0
///
public class MessageSender
{
@@ -740,69 +346,8 @@ public async Task CloseAsync()
await sender.CloseAsync();
}
-
-#else
- public class MessageSender
- {
- Microsoft.ServiceBus.Messaging.MessageSender msgSender;
-
- public MessageSender(ServiceBusConnection serviceBusConnection, string transferDestinationEntityPath, string viaEntityPath)
- {
- this.msgSender = BuildMessagingFactory(serviceBusConnection).CreateMessageSender(transferDestinationEntityPath, viaEntityPath);
- }
-
- public MessageSender(ServiceBusConnection serviceBusConnection, string entityPath, RetryPolicy retryPolicy = null)
- {
- this.msgSender = BuildMessagingFactory(serviceBusConnection).CreateMessageSender(entityPath);
- }
-
- static MessagingFactory BuildMessagingFactory(ServiceBusConnection serviceBusConnection)
- {
- var namespaceManager = Microsoft.ServiceBus.NamespaceManager.CreateFromConnectionString(serviceBusConnection.ConnectionString);
- var factory = Microsoft.ServiceBus.Messaging.MessagingFactory.Create(
- namespaceManager.Address.ToString(),
- new MessagingFactorySettings
- {
- TransportType = TransportType.NetMessaging,
- TokenProvider = serviceBusConnection.TokenProvider,
- NetMessagingTransportSettings = new NetMessagingTransportSettings
- {
- BatchFlushInterval = TimeSpan.FromMilliseconds(Core.FrameworkConstants.BatchFlushIntervalInMilliSecs)
- }
- });
- factory.RetryPolicy = Microsoft.ServiceBus.RetryPolicy.Default;
- return factory;
- }
-
- public MessageSender(Microsoft.ServiceBus.Messaging.MessageSender msgSender)
- {
- this.msgSender = msgSender;
- }
-
- public static implicit operator MessageSender(Microsoft.ServiceBus.Messaging.MessageSender ms)
- {
- return new MessageSender(ms);
- }
-
- public async Task SendAsync(Message message)
- {
- await this.msgSender.SendAsync(message);
- }
-
- public async Task SendAsync(IEnumerable messages)
- {
- await this.msgSender.SendBatchAsync(messages.Select(x => (BrokeredMessage)x));
- }
-
- public async Task CloseAsync()
- {
- await this.msgSender.CloseAsync();
- }
-
-#endif
}
-#if NETSTANDARD2_0
///
public class MessageReceiver
{
@@ -843,73 +388,8 @@ public async Task AbandonAsync(Message message)
await this.receiver.AbandonMessageAsync(message);
}
-#else
- public class MessageReceiver
- {
- Microsoft.ServiceBus.Messaging.MessageReceiver msgReceiver;
-
- public MessageReceiver(ServiceBusConnection serviceBusConnection, string entityPath)
- {
- this.msgReceiver = BuildMessagingFactory(serviceBusConnection).CreateMessageReceiver(entityPath);
- }
-
- static MessagingFactory BuildMessagingFactory(ServiceBusConnection serviceBusConnection)
- {
- var namespaceManager = Microsoft.ServiceBus.NamespaceManager.CreateFromConnectionString(serviceBusConnection.ConnectionString);
- var factory = Microsoft.ServiceBus.Messaging.MessagingFactory.Create(
- namespaceManager.Address.ToString(),
- new MessagingFactorySettings
- {
- TransportType = TransportType.NetMessaging,
- TokenProvider = serviceBusConnection.TokenProvider,
- NetMessagingTransportSettings = new NetMessagingTransportSettings
- {
- BatchFlushInterval = TimeSpan.FromMilliseconds(Core.FrameworkConstants.BatchFlushIntervalInMilliSecs)
- }
- });
- factory.RetryPolicy = Microsoft.ServiceBus.RetryPolicy.Default;
- return factory;
- }
-
- public MessageReceiver(Microsoft.ServiceBus.Messaging.MessageReceiver msgReceiver)
- {
- this.msgReceiver = msgReceiver;
- }
-
- public static implicit operator MessageReceiver(Microsoft.ServiceBus.Messaging.MessageReceiver mr)
- {
- return new MessageReceiver(mr);
- }
-
- public async Task AbandonAsync(Message message)
- {
- await this.msgReceiver.AbandonAsync(message.SystemProperties.LockToken);
- }
-
- public async Task CloseAsync()
- {
- await this.msgReceiver.CloseAsync();
- }
-
- public async Task CompleteAsync(Message message)
- {
- await this.msgReceiver.CompleteAsync(message.SystemProperties.LockToken);
- }
-
- public async Task ReceiveAsync(TimeSpan serverWaitTime)
- {
- return await this.msgReceiver.ReceiveAsync(serverWaitTime);
- }
-
- public async Task RenewLockAsync(Message message)
- {
- await ((BrokeredMessage)message).RenewLockAsync();
- }
-
-#endif
}
-#if NETSTANDARD2_0
///
public class QueueClient
{
@@ -930,70 +410,8 @@ public async Task SendAsync(Message message)
await sender.SendMessageAsync((Azure.Messaging.ServiceBus.ServiceBusMessage)message);
}
-#else
- public class QueueClient
- {
- Microsoft.ServiceBus.Messaging.QueueClient queueClient;
-
- public QueueClient(ServiceBusConnection serviceBusConnection, string entityPath, ReceiveMode receiveMode, RetryPolicy retryPolicy)
- {
- var factory = BuildMessagingFactory(serviceBusConnection);
- factory.RetryPolicy = retryPolicy;
- this.queueClient = factory.CreateQueueClient(entityPath, receiveMode);
- }
-
- static MessagingFactory BuildMessagingFactory(ServiceBusConnection serviceBusConnection)
- {
- var namespaceManager = Microsoft.ServiceBus.NamespaceManager.CreateFromConnectionString(serviceBusConnection.ConnectionString);
- var factory = Microsoft.ServiceBus.Messaging.MessagingFactory.Create(
- namespaceManager.Address.ToString(),
- new MessagingFactorySettings
- {
- TransportType = TransportType.NetMessaging,
- TokenProvider = serviceBusConnection.TokenProvider,
- NetMessagingTransportSettings = new NetMessagingTransportSettings
- {
- BatchFlushInterval = TimeSpan.FromMilliseconds(Core.FrameworkConstants.BatchFlushIntervalInMilliSecs)
- }
- });
- factory.RetryPolicy = Microsoft.ServiceBus.RetryPolicy.Default;
- return factory;
- }
-
- public QueueClient(Microsoft.ServiceBus.Messaging.QueueClient queueClient)
- {
- this.queueClient = queueClient;
- }
-
- public static implicit operator QueueClient(Microsoft.ServiceBus.Messaging.QueueClient qc)
- {
- return new QueueClient(qc);
- }
-
- public async Task SendAsync(Message message)
- {
- await this.queueClient.SendAsync(message);
- }
-
- public async Task SendAsync(IList messageList)
- {
- await this.queueClient.SendBatchAsync(messageList.Select(x => (BrokeredMessage)x));
- }
-
- public async Task CloseAsync()
- {
- await this.queueClient.CloseAsync();
- }
-
- public async Task AcceptMessageSessionAsync(TimeSpan operationTimeout)
- {
- return await this.queueClient.AcceptMessageSessionAsync(operationTimeout);
- }
-
-#endif
}
-#if NETSTANDARD2_0
public class QueueDescription
{
private readonly Union propertiesUnion;
@@ -1064,49 +482,8 @@ public async Task> GetQueuesAsync()
return queueDescriptions;
}
-#else
- public class ManagementClient
- {
- Microsoft.ServiceBus.NamespaceManager manager;
-
- public ManagementClient(string connectionString)
- {
- this.manager = Microsoft.ServiceBus.NamespaceManager.CreateFromConnectionString(connectionString);
- }
-
- public ManagementClient(Microsoft.ServiceBus.NamespaceManager manager)
- {
- this.manager = manager;
- }
-
- public static implicit operator ManagementClient(Microsoft.ServiceBus.NamespaceManager nm)
- {
- return new ManagementClient(nm);
- }
-
- public async Task CreateQueueAsync(QueueDescription queueDescription)
- {
- return await this.manager.CreateQueueAsync(queueDescription);
- }
-
- public async Task DeleteQueueAsync(string queuePath)
- {
- await this.manager.DeleteQueueAsync(queuePath);
- }
-
- public async Task GetQueueRuntimeInfoAsync(string queuePath)
- {
- return await this.manager.GetQueueAsync(queuePath);
- }
-
- public async Task> GetQueuesAsync()
- {
- return await this.manager.GetQueuesAsync();
- }
-#endif
}
-#if NETSTANDARD2_0
public class SessionClient
{
private readonly Azure.Messaging.ServiceBus.ServiceBusClient serviceBusClient;
@@ -1131,7 +508,7 @@ public async Task AcceptMessageSessionAsync(TimeSpan operationT
return new IMessageSession(await this.serviceBusClient.AcceptNextSessionAsync(entityPath, options));
}
catch (Azure.Messaging.ServiceBus.ServiceBusException e) when (e.Reason.Equals(Azure.Messaging.ServiceBus.ServiceBusFailureReason.ServiceTimeout))
- {
+ {
return null;
}
}
@@ -1141,19 +518,6 @@ public Task CloseAsync()
return Task.CompletedTask;
}
-#else
- public class SessionClient : QueueClient
- {
- public SessionClient(ServiceBusConnection serviceBusConnection, string entityPath, ReceiveMode receiveMode)
- : base(serviceBusConnection, entityPath, receiveMode, RetryPolicy.Default)
- {
- }
-
- public SessionClient(Microsoft.ServiceBus.Messaging.QueueClient queueClient)
- : base(queueClient)
- {
- }
-#endif
}
}
diff --git a/src/DurableTask.ServiceBus/Common/ServiceBusUtils.cs b/src/DurableTask.ServiceBus/Common/ServiceBusUtils.cs
index 861b16852..6020e8f3c 100644
--- a/src/DurableTask.ServiceBus/Common/ServiceBusUtils.cs
+++ b/src/DurableTask.ServiceBus/Common/ServiceBusUtils.cs
@@ -54,19 +54,15 @@ public static async Task GetBrokeredMessageFromObjectAsync(
if (compressionSettings.Style == CompressionStyle.Legacy)
{
-#if NETSTANDARD2_0
using (var ms = new MemoryStream())
{
var serialiser = (XmlObjectSerializer)typeof(DataContractSerializer)
.MakeGenericType(serializableObject.GetType())
.GetField("Instance")
?.GetValue(null);
- serialiser?.WriteObject(ms,serializableObject);
+ serialiser?.WriteObject(ms, serializableObject);
return new Message(ms.ToArray()) { SessionId = instance?.InstanceId };
}
-#else
- return new Message(serializableObject) { SessionId = instance?.InstanceId};
-#endif
}
if (messageSettings == null)
@@ -137,16 +133,12 @@ public static async Task GetBrokeredMessageFromObjectAsync(
static Message GenerateBrokeredMessageWithCompressionTypeProperty(Stream stream, string compressionType)
{
-#if NETSTANDARD2_0
Message brokeredMessage;
using (var ms = new MemoryStream())
{
stream.CopyTo(ms);
brokeredMessage = new Message(ms.ToArray());
}
-#else
- var brokeredMessage = new Message(stream);
-#endif
brokeredMessage.UserProperties[FrameworkConstants.CompressionTypePropertyName] = compressionType;
return brokeredMessage;
@@ -212,13 +204,9 @@ public static async Task GetObjectFromBrokeredMessageAsync(Message message
if (string.IsNullOrWhiteSpace(compressionType))
{
// no compression, legacy style
-#if NETSTANDARD2_0
var dataContractSerializer = new DataContractSerializer(typeof(T));
using (var ms = new MemoryStream(message.Body))
deserializedObject = (T)dataContractSerializer.ReadObject(ms);
-#else
- deserializedObject = message.GetBody();
-#endif
}
else if (string.Equals(compressionType, FrameworkConstants.CompressionTypeGzipPropertyValue,
StringComparison.OrdinalIgnoreCase))
@@ -278,7 +266,7 @@ static T SafeReadFromStream(Stream objectStream)
originalException.Throw();
}
- return (dynamic)new TaskMessage
+ return (T)(object)new TaskMessage
{
Event = new HistoryStateEvent(-1, stateMessage.State),
OrchestrationInstance = stateMessage.State.OrchestrationInstance
@@ -300,11 +288,7 @@ static Task LoadMessageStreamAsync(Message message, IOrchestrationServic
{
// load the stream from the message directly if the blob key property is not set,
// i.e., it is not stored externally
-#if NETSTANDARD2_0
return Task.FromResult(new MemoryStream(message.Body));
-#else
- return Task.FromResult(message.GetBody());
-#endif
}
// if the blob key is set in the message property,
@@ -358,7 +342,7 @@ public static void CheckAndLogDeliveryCount(string sessionId, Message message, i
TraceEventType.Critical,
"MaxDeliveryCountApproaching",
"Delivery count for message with id {0} is {1}. Message will be deadlettered if processing continues to fail.",
- message.MessageId,
+ message.MessageId,
message.SystemProperties.DeliveryCount);
}
}
diff --git a/src/DurableTask.ServiceBus/DurableTask.ServiceBus.csproj b/src/DurableTask.ServiceBus/DurableTask.ServiceBus.csproj
index 3e2a23474..7e4657140 100644
--- a/src/DurableTask.ServiceBus/DurableTask.ServiceBus.csproj
+++ b/src/DurableTask.ServiceBus/DurableTask.ServiceBus.csproj
@@ -2,7 +2,7 @@
- netstandard2.0;net48
+ netstandard2.0
Microsoft.Azure.DurableTask.ServiceBus
AnyCPU;x64
@@ -24,26 +24,10 @@
$(VersionPrefix)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
diff --git a/src/DurableTask.ServiceBus/ServiceBusOrchestrationService.cs b/src/DurableTask.ServiceBus/ServiceBusOrchestrationService.cs
index f759ff591..ea5844518 100644
--- a/src/DurableTask.ServiceBus/ServiceBusOrchestrationService.cs
+++ b/src/DurableTask.ServiceBus/ServiceBusOrchestrationService.cs
@@ -42,13 +42,8 @@ namespace DurableTask.ServiceBus
using ServiceBusConnection = DurableTask.ServiceBus.Common.Abstraction.ServiceBusConnection;
using ManagementClient = DurableTask.ServiceBus.Common.Abstraction.ManagementClient;
using ServiceBusConnectionStringBuilder = DurableTask.ServiceBus.Common.Abstraction.ServiceBusConnectionStringBuilder;
-#if NETSTANDARD2_0
using Azure.Core;
using ReceiveMode = Azure.Messaging.ServiceBus.ServiceBusReceiveMode;
-#else
- using Microsoft.ServiceBus.Messaging;
- using RetryPolicy = DurableTask.ServiceBus.Common.Abstraction.RetryPolicy;
-#endif
///
/// Orchestration Service and Client implementation using Azure Service Bus
@@ -109,8 +104,6 @@ public class ServiceBusOrchestrationService : IOrchestrationService, IOrchestrat
ServiceBusConnection serviceBusConnection;
-#if NETSTANDARD2_0
-
///
/// Create a new ServiceBusOrchestrationService to the given service bus namespace and hub name
///
@@ -136,8 +129,6 @@ public ServiceBusOrchestrationService(
{
}
-#endif
-
///
/// Create a new ServiceBusOrchestrationService to the given service bus connection string and hub name
///
@@ -187,23 +178,13 @@ public ServiceBusOrchestrationService(
if (!string.IsNullOrEmpty(connectionSettings.ConnectionString))
{
var sbConnectionStringBuilder = new ServiceBusConnectionStringBuilder(connectionSettings.ConnectionString);
-#if NETSTANDARD2_0
this.serviceBusConnection = new ServiceBusConnection(sbConnectionStringBuilder);
-#else
- this.serviceBusConnection = new ServiceBusConnection(sbConnectionStringBuilder)
- {
- TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(sbConnectionStringBuilder.SasKeyName,
- sbConnectionStringBuilder.SasKey, ServiceBusUtils.TokenTimeToLive),
- };
-#endif
}
-#if NETSTANDARD2_0
else if (connectionSettings.Endpoint != null && connectionSettings.TokenCredential != null)
{
this.serviceBusConnection = new ServiceBusConnection(connectionSettings.Endpoint.Host, connectionSettings.TransportType, connectionSettings.TokenCredential);
}
-#endif
else
{
throw new ArgumentException("Invalid Service Bus connection settings.", nameof(connectionSettings));
@@ -212,7 +193,6 @@ public ServiceBusOrchestrationService(
this.Settings = settings ?? new ServiceBusOrchestrationServiceSettings();
this.orchestratorBatchMessageSender = new MessageSender(this.serviceBusConnection, this.orchestratorEntityName);
-
this.BlobStore = blobStore;
if (instanceStore != null)
{
@@ -248,11 +228,7 @@ public async Task StartAsync()
this.orchestratorSender = new MessageSender(this.serviceBusConnection, this.orchestratorEntityName, this.workerEntityName);
this.workerSender = new MessageSender(this.serviceBusConnection, this.workerEntityName, this.orchestratorEntityName);
this.trackingSender = new MessageSender(this.serviceBusConnection, this.trackingEntityName, this.orchestratorEntityName);
-#if !NETSTANDARD2_0
- this.orchestratorQueueClient = new QueueClient(this.serviceBusConnection, this.orchestratorEntityName, ReceiveMode.PeekLock, RetryPolicy.Default);
-#else
this.orchestratorQueueClient = new QueueClient(this.serviceBusConnection, this.orchestratorEntityName);
-#endif
this.workerReceiver = new MessageReceiver(serviceBusConnection, this.workerEntityName);
this.orchestratorSessionClient = new SessionClient(serviceBusConnection, this.orchestratorEntityName, ReceiveMode.PeekLock);
this.trackingClient = new SessionClient(serviceBusConnection, this.trackingEntityName, ReceiveMode.PeekLock);
@@ -1384,11 +1360,7 @@ public async Task PurgeOrchestrationHistoryAsync(
static bool IsTransientException(Exception exception)
{
// TODO : Once we change the exception model, check for inner exception
-#if NETSTANDARD2_0
return (exception as Azure.Messaging.ServiceBus.ServiceBusException)?.IsTransient ?? false;
-#else
- return (exception as MessagingException)?.IsTransient ?? false;
-#endif
}
///
@@ -1780,19 +1752,11 @@ await Utils.ExecuteWithRetries(async () =>
{
await managementClient.DeleteQueueAsync(path);
}
-#if !NETSTANDARD2_0
- catch (MessagingEntityAlreadyExistsException)
-#else
catch (Azure.Messaging.ServiceBus.ServiceBusException e) when (e.Reason.Equals(Azure.Messaging.ServiceBus.ServiceBusFailureReason.MessagingEntityAlreadyExists))
-#endif
{
await Task.FromResult(0);
}
-#if !NETSTANDARD2_0
- catch (MessagingEntityNotFoundException)
-#else
catch (Azure.Messaging.ServiceBus.ServiceBusException e) when (e.Reason.Equals(Azure.Messaging.ServiceBus.ServiceBusFailureReason.MessagingEntityNotFound))
-#endif
{
await Task.FromResult(0);
}
@@ -1813,11 +1777,7 @@ await Utils.ExecuteWithRetries(async () =>
{
await CreateQueueAsync(managementClient, path, requiresSessions, requiresDuplicateDetection, maxDeliveryCount, maxSizeInMegabytes);
}
-#if !NETSTANDARD2_0
- catch (MessagingEntityAlreadyExistsException)
-#else
catch (Azure.Messaging.ServiceBus.ServiceBusException e) when (e.Reason.Equals(Azure.Messaging.ServiceBus.ServiceBusFailureReason.MessagingEntityAlreadyExists))
-#endif
{
await Task.FromResult(0);
}
@@ -1851,11 +1811,7 @@ async Task CreateQueueAsync(
throw new ArgumentException($"The specified value {maxSizeInMegabytes} is invalid for the maximum queue size in megabytes.\r\nIt must be one of the following values:\r\n{string.Join(";", ValidQueueSizes)}", nameof(maxSizeInMegabytes));
}
-#if NETSTANDARD2_0
var description = new Azure.Messaging.ServiceBus.Administration.CreateQueueOptions(path)
-#else
- var description = new QueueDescription(path)
-#endif
{
RequiresSession = requiresSessions,
MaxDeliveryCount = maxDeliveryCount,
@@ -1900,12 +1856,10 @@ ManagementClient CreateManagementClient()
{
return new ManagementClient(this.connectionSettings.ConnectionString);
}
-#if NETSTANDARD2_0
else if (connectionSettings.Endpoint != null && connectionSettings.TokenCredential != null)
{
return new ManagementClient(connectionSettings.Endpoint.Host, connectionSettings.TokenCredential);
}
-#endif
else
{
throw new Exception("Unable to create ManagementClient due to invalid connection settings.");
diff --git a/src/DurableTask.ServiceBus/Settings/ServiceBusConnectionSettings.cs b/src/DurableTask.ServiceBus/Settings/ServiceBusConnectionSettings.cs
index 075207532..148c9a024 100644
--- a/src/DurableTask.ServiceBus/Settings/ServiceBusConnectionSettings.cs
+++ b/src/DurableTask.ServiceBus/Settings/ServiceBusConnectionSettings.cs
@@ -13,9 +13,7 @@
namespace DurableTask.ServiceBus.Settings
{
-#if NETSTANDARD2_0
using Azure.Core;
-#endif
using System;
///
@@ -36,8 +34,6 @@ public static ServiceBusConnectionSettings Create(string connectionString)
};
}
-#if NETSTANDARD2_0
-
///
/// Creates an instance of
///
@@ -72,8 +68,6 @@ public static ServiceBusConnectionSettings Create(Uri serviceBusEndpoint, TokenC
};
}
-#endif
-
private ServiceBusConnectionSettings()
{
}
@@ -83,8 +77,6 @@ private ServiceBusConnectionSettings()
///
public string ConnectionString { get; private set; }
-#if NETSTANDARD2_0
-
///
/// Service Bus endpoint
///
@@ -99,7 +91,6 @@ private ServiceBusConnectionSettings()
/// Azure.Identity TokenCredential used to authenticate with the service bus
///
public TokenCredential TokenCredential { get; private set; }
-#endif
}
}
diff --git a/test/DurableTask.ServiceBus.Tests/DurableTask.ServiceBus.Tests.csproj b/test/DurableTask.ServiceBus.Tests/DurableTask.ServiceBus.Tests.csproj
index c3bf4e3de..7197c0680 100644
--- a/test/DurableTask.ServiceBus.Tests/DurableTask.ServiceBus.Tests.csproj
+++ b/test/DurableTask.ServiceBus.Tests/DurableTask.ServiceBus.Tests.csproj
@@ -14,18 +14,10 @@
-
-
-
-
-
-
-
-