public void MergeFrom(InboundHandlerConfig other)
 {
     if (other == null)
     {
         return;
     }
     if (other.Tag.Length != 0)
     {
         Tag = other.Tag;
     }
     if (other.receiverSettings_ != null)
     {
         if (receiverSettings_ == null)
         {
             receiverSettings_ = new global::V2Ray.Core.Common.Serial.TypedMessage();
         }
         ReceiverSettings.MergeFrom(other.ReceiverSettings);
     }
     if (other.proxySettings_ != null)
     {
         if (proxySettings_ == null)
         {
             proxySettings_ = new global::V2Ray.Core.Common.Serial.TypedMessage();
         }
         ProxySettings.MergeFrom(other.ProxySettings);
     }
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }
Beispiel #2
0
        public AzureServiceBusInboundTransport([NotNull] IAzureServiceBusEndpointAddress address,
                                               [NotNull] ConnectionHandler <AzureServiceBusConnection> connectionHandler,
                                               [NotNull] AzureManagement management,
                                               [CanBeNull] IMessageNameFormatter formatter   = null,
                                               [CanBeNull] ReceiverSettings receiverSettings = null)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            if (connectionHandler == null)
            {
                throw new ArgumentNullException("connectionHandler");
            }
            if (management == null)
            {
                throw new ArgumentNullException("management");
            }

            _address           = address;
            _connectionHandler = connectionHandler;
            _management        = management;
            _formatter         = formatter ?? new AzureServiceBusMessageNameFormatter();
            _receiverSettings  = receiverSettings; // can be null all the way to usage in Receiver.

            _logger.DebugFormat("created new inbound transport for '{0}'", address);
        }
Beispiel #3
0
        public static void AddAdminQueueListener(this IServiceCollection services, IConfiguration configuration)
        {
            var listenerSection = configuration.GetSection("Queue").GetSection("Listener");
            var brokerSection   = configuration.GetSection("Queue").GetSection("Broker");
            var queueSettings   = new ReceiverSettings
            {
                Queue        = listenerSection["Queue"],
                Durable      = bool.Parse(listenerSection["Durable"]),
                AutoAck      = bool.Parse(listenerSection["AutoAck"]),
                Exchange     = listenerSection["Exchange"],
                ExchangeType = listenerSection["ExchangeType"],
                Keys         = listenerSection["RoutingKeys"]?.Split(';')?.ToList()
            };
            var brokerSettings = new BrokerSettings
            {
                Host     = brokerSection["Host"],
                Port     = int.Parse(brokerSection["Port"]),
                User     = brokerSection["User"],
                Password = brokerSection["Password"]
            };

            services.AddScoped(typeof(IRepository <>), typeof(EfRepository <>));
            services.AddSingleton(brokerSettings);
            services.AddSingleton(queueSettings);
            services.AddHostedService <AdminQueueListener>();
        }
 public SampleService(StatelessServiceContext serviceContext,
                      ILogger logger, ReceiverSettings settings,
                      Action <string, object[]> serviceEventSource,
                      Func <CancellationToken, Task> @switch,
                      Func <string, Func <EventContext, Task> > f,
                      EventProcessorOptions options)
     : base(serviceContext, logger, settings, serviceEventSource, @switch, f, options)
 {
 }
        /// <summary>
        /// 	c'tor taking settings to configure the endpoint with
        /// </summary>
        public TransportFactoryImpl(ReceiverSettings receiverSettings, SenderSettings senderSettings)
        {
            _addresses = new ReaderWriterLockedDictionary<Uri, IAzureServiceBusEndpointAddress>();
            _connCache = new ReaderWriterLockedDictionary<Uri, ConnectionHandler<AzureServiceBusConnection>>();
            _formatter = new AzureServiceBusMessageNameFormatter();

            _receiverSettings = receiverSettings;
            _senderSettings = senderSettings;

            _logger.Debug("created new transport factory");
        }
Beispiel #6
0
        /// <summary>
        ///     c'tor taking settings to configure the endpoint with
        /// </summary>
        public TransportFactoryImpl(ReceiverSettings receiverSettings, SenderSettings senderSettings)
        {
            _addresses = new ReaderWriterLockedDictionary <Uri, AzureServiceBusEndpointAddress>();
            _connCache = new ReaderWriterLockedDictionary <Uri, ConnectionHandler <ConnectionImpl> >();
            _formatter = new AzureMessageNameFormatter();

            _receiverSettings = receiverSettings;
            _senderSettings   = senderSettings;

            _logger.Debug("created new transport factory");
        }
		public InboundTransportImpl([NotNull] AzureServiceBusEndpointAddress address,
			[NotNull] ConnectionHandler<ConnectionImpl> connectionHandler,
			[NotNull] AzureManagement management, 
			[CanBeNull] IMessageNameFormatter formatter = null,
			[CanBeNull] ReceiverSettings receiverSettings = null)
		{
			if (address == null) throw new ArgumentNullException("address");
			if (connectionHandler == null) throw new ArgumentNullException("connectionHandler");
			if (management == null) throw new ArgumentNullException("management");

			_address = address;
			_connectionHandler = connectionHandler;
			_management = management;
			_formatter = formatter ?? new AzureMessageNameFormatter();
			_receiverSettings = receiverSettings; // can be null all the way to usage in Receiver.

			_logger.DebugFormat("created new inbound transport for '{0}'", address);
		}
        public override int GetHashCode()
        {
            int hash = 1;

            if (Tag.Length != 0)
            {
                hash ^= Tag.GetHashCode();
            }
            if (receiverSettings_ != null)
            {
                hash ^= ReceiverSettings.GetHashCode();
            }
            if (proxySettings_ != null)
            {
                hash ^= ProxySettings.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        public PerConnectionReceiver(
            [NotNull] AzureServiceBusEndpointAddress address,
            [NotNull] ReceiverSettings settings,
            [NotNull] Action <Receiver.Receiver> onBound,
            [NotNull] Action <Receiver.Receiver> onUnbound)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            if (onBound == null)
            {
                throw new ArgumentNullException("onBound");
            }
            if (onUnbound == null)
            {
                throw new ArgumentNullException("onUnbound");
            }

            _address   = address;
            _settings  = settings;
            _onBound   = onBound;
            _onUnbound = onUnbound;
        }
Beispiel #10
0
 public AdminQueueListener(IServiceProvider serviceProvider, BrokerSettings brokerSettings,
                           ReceiverSettings receiverSettings) : base(brokerSettings, receiverSettings)
 {
     _serviceProvider = serviceProvider;
 }
Beispiel #11
0
 public AdminQueueListener(IRepository <Employee> employeeRepository, BrokerSettings brokerSettings,
                           ReceiverSettings receiverSettings) : base(brokerSettings, receiverSettings)
 {
     _employeeRepository = employeeRepository;
 }
Beispiel #12
0
 public GivingToCustomerQueueListener(IServiceProvider serviceProvider, BrokerSettings brokerSettings,
                                      ReceiverSettings receiverSettings) : base(brokerSettings, receiverSettings)
 {
     _serviceProvider = serviceProvider;
 }
        /// <summary>
        /// This is the entry point of the service host process.
        /// </summary>
        private static void Main(string[] args)
        {
            var telemetryClient = new TelemetryClient(TelemetryConfiguration.CreateDefault()
                                                      .Tap(x =>
            {
                if (args.Length > 1)
                {
                    x.InstrumentationKey = args.Last();
                }
            }));

            Log.Logger = new LoggerConfiguration()
                         .WriteTo.ApplicationInsights(telemetryClient, TelemetryConverter.Traces, Serilog.Events.LogEventLevel.Debug)
                         //.WriteTo.AzureTableStorage(CloudStorageAccount.DevelopmentStorageAccount, Serilog.Events.LogEventLevel.Warning)
                         .WriteTo.ColoredConsole(Serilog.Events.LogEventLevel.Debug, outputTemplate:
                                                 "[{Timestamp:HH:mm:ss} {Level:u3}] {PartitionId} {Scope:lj} {Message:lj}{NewLine}{Exception}")
                         .MinimumLevel.Debug()
                         .Enrich.FromLogContext()
                         .CreateLogger();

            var logger = new SerilogLoggerProvider(Log.Logger, true)
                         .CreateLogger("Stateless-Sample");

            var storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
            var table          = storageAccount.CreateCloudTableClient().GetTableReference("receiversample");

            table.CreateIfNotExistsAsync().GetAwaiter().GetResult();

            var settings = new ReceiverSettings()
            {
                EventHubConnectionString = args.First(),
                EventHubPath             = "sample",
                StorageConnectionString  = "UseDevelopmentStorage=true",
                ConsumerGroup            = "sf",
                LeaseContainerName       = "leases"
            };

            var options = new EventProcessorOptions
            {
                InitialOffsetProvider = partition =>
                {
                    logger.LogWarning("InitialOffsetProvider called for {partition}", partition);
                    return(EventPosition.FromStart());
                }
            };

            var pipeline = Composition.Combine(
                CMP.ServiceFabricReceiver.Common.Features.PartitionLogging(),
                CMP.ServiceFabricReceiver.Common.Features.OperationLogging(telemetryClient),
                CMP.ServiceFabricReceiver.Common.Features.Logging(),
                CMP.ServiceFabricReceiver.Common.Features.Retry(),
                CMP.ServiceFabricReceiver.Common.Features.Handling(x => EventHandler.Handle("Sample", table, x.Events)),
                CMP.ServiceFabricReceiver.Common.Features.Checkpointing()
                );

            var isInCluster = PlatformServices.Default.Application.ApplicationBasePath.Contains(".Code.");

            if (!isInCluster)
            {
                logger.LogInformation("Running in Process. Application insights key set : {instrumentationKeySet}", string.IsNullOrWhiteSpace(telemetryClient.InstrumentationKey));
                settings.ToHost()
                .RunAsync(logger, options, CancellationToken.None, (s, o) => { }, "none", partitionId => ctx => pipeline(ctx))
                .GetAwaiter()
                .GetResult();

                Thread.Sleep(Timeout.Infinite);
            }

            try
            {
                ServiceRuntime.RegisterServiceAsync(
                    "ReceiverServiceType2",
                    context =>
                    new SampleService(
                        context,
                        logger,
                        settings,
                        ServiceEventSource.Current.Message,
                        ct => Task.CompletedTask,
                        partitionId => ctx => pipeline(ctx),
                        options)
                    ).GetAwaiter().GetResult();

                ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, $"{typeof(ReceiverService).Name}2");

                // Prevents this host process from terminating so services keep running.
                Thread.Sleep(Timeout.Infinite);
            }
            catch (Exception e)
            {
                ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString());
                throw;
            }
        }