Example #1
0
 public AmqpServiceClient(AmqpEventHubClient eventHubClient, string address)
     : base("AmqpServiceClient-" + StringUtility.GetRandomString())
 {
     this.eventHubClient    = eventHubClient;
     this.Address           = address;
     this.link              = new FaultTolerantAmqpObject <RequestResponseAmqpLink>(t => this.OpenLinkAsync(t), rrlink => rrlink.CloseAsync(TimeSpan.FromSeconds(10)));
     this.clientLinkManager = new ActiveClientLinkManager(this.eventHubClient);
 }
        public AmqpServiceClient(AmqpEventHubClient eventHubClient, string address)
            : base(nameof(AmqpServiceClient <T>) + StringUtility.GetRandomString())
        {
            if (!typeof(T).GetTypeInfo().IsInterface)
            {
                throw new NotSupportedException("Not an interface");
            }

            this.eventHubClient    = eventHubClient;
            this.Address           = address;
            this.Channel           = new AmqpClientProxy(this, typeof(T)).GetChannel();
            this.link              = new FaultTolerantAmqpObject <RequestResponseAmqpLink>(t => this.OpenLinkAsync(t), rrlink => rrlink.CloseAsync(TimeSpan.FromSeconds(10)));
            this.clientLinkManager = new ActiveClientLinkManager(this.eventHubClient);
        }
Example #3
0
        internal MessageSender(
            string entityPath,
            string transferDestinationPath,
            MessagingEntityType?entityType,
            ServiceBusConnection serviceBusConnection,
            ICbsTokenProvider cbsTokenProvider,
            RetryPolicy retryPolicy)
            : base(nameof(MessageSender), entityPath, retryPolicy ?? RetryPolicy.Default)
        {
            MessagingEventSource.Log.MessageSenderCreateStart(serviceBusConnection?.Endpoint.Authority, entityPath);

            if (string.IsNullOrWhiteSpace(entityPath))
            {
                throw Fx.Exception.ArgumentNullOrWhiteSpace(entityPath);
            }

            this.ServiceBusConnection = serviceBusConnection ?? throw new ArgumentNullException(nameof(serviceBusConnection));
            this.Path = entityPath;
            this.SendingLinkDestination = entityPath;
            this.EntityType             = entityType;
            this.ServiceBusConnection.ThrowIfClosed();

            if (cbsTokenProvider != null)
            {
                this.CbsTokenProvider = cbsTokenProvider;
            }
            else if (this.ServiceBusConnection.TokenProvider != null)
            {
                this.CbsTokenProvider = new TokenProviderAdapter(this.ServiceBusConnection.TokenProvider, this.ServiceBusConnection.OperationTimeout);
            }
            else
            {
                throw new ArgumentNullException($"{nameof(ServiceBusConnection)} doesn't have a valid token provider");
            }

            this.SendLinkManager            = new FaultTolerantAmqpObject <SendingAmqpLink>(this.CreateLinkAsync, CloseSession);
            this.RequestResponseLinkManager = new FaultTolerantAmqpObject <RequestResponseAmqpLink>(this.CreateRequestResponseLinkAsync, CloseRequestResponseSession);
            this.clientLinkManager          = new ActiveClientLinkManager(this, this.CbsTokenProvider);
            this.diagnosticSource           = new ServiceBusDiagnosticSource(entityPath, serviceBusConnection.Endpoint);

            if (!string.IsNullOrWhiteSpace(transferDestinationPath))
            {
                this.isViaSender             = true;
                this.TransferDestinationPath = transferDestinationPath;
                this.ViaEntityPath           = entityPath;
            }

            MessagingEventSource.Log.MessageSenderCreateStop(serviceBusConnection.Endpoint.Authority, entityPath, this.ClientId);
        }
Example #4
0
        internal MessageSender(
            string entityPath,
            MessagingEntityType?entityType,
            ServiceBusConnection serviceBusConnection,
            RetryPolicy retryPolicy)
            : base(nameof(MessageSender), entityPath, retryPolicy ?? RetryPolicy.Default)
        {
            MessagingEventSource.Log.MessageSenderCreateStart(serviceBusConnection?.Endpoint.Authority, entityPath);

            this.ServiceBusConnection = serviceBusConnection ?? throw new ArgumentNullException(nameof(serviceBusConnection));
            this.OperationTimeout     = serviceBusConnection.OperationTimeout;
            this.Path                       = entityPath;
            this.EntityType                 = entityType;
            this.SendLinkManager            = new FaultTolerantAmqpObject <SendingAmqpLink>(this.CreateLinkAsync, CloseSession);
            this.RequestResponseLinkManager = new FaultTolerantAmqpObject <RequestResponseAmqpLink>(this.CreateRequestResponseLinkAsync, CloseRequestResponseSession);
            this.clientLinkManager          = new ActiveClientLinkManager(this.ClientId);

            MessagingEventSource.Log.MessageSenderCreateStop(serviceBusConnection.Endpoint.Authority, entityPath, this.ClientId);
        }