public Task StartAsync(OnSessionMessage messageHandler, OnSessionMessageException exceptionHandler, OnSessionMessageOptions options) { lock (_initializationLock) { if (_initialized) { throw new MessageReceiverException("Message receiver has already been initialized."); } if (messageHandler == null) { throw new ArgumentNullException("messageHandler"); } if (options == null) { options = _defaultOptions; } // Log. ServiceBusEventSource.Log.SessionMessagePumpStart(GetType().Name, Namespace, Path, options.AutoRenewSessionTimeout, options.MaxConcurrentSessions); // Initialize the handler options. var sessionHandlerOptions = new SessionHandlerOptions(); sessionHandlerOptions.AutoComplete = options.AutoComplete; sessionHandlerOptions.AutoRenewTimeout = options.AutoRenewSessionTimeout; sessionHandlerOptions.MaxConcurrentSessions = options.MaxConcurrentSessions; sessionHandlerOptions.MessageWaitTimeout = options.MessageWaitTimeout; sessionHandlerOptions.ExceptionReceived += (s, e) => { if (e.Exception != null) { // Log. ServiceBusEventSource.Log.MessagePumpExceptionReceived(Namespace, Path, e.Action, e.Exception); // Handle exception. if (exceptionHandler != null) { exceptionHandler(e.Action, e.Exception); } } }; // Mark receiver as initialized. _initialized = true; // Start. return(OnStartAsync(new SessionMessageAsyncHandlerFactory(Namespace, Path, messageHandler, options), new SessionHandlerOptions { AutoComplete = options.AutoComplete, AutoRenewTimeout = options.AutoRenewSessionTimeout, MaxConcurrentSessions = options.MaxConcurrentSessions, MessageWaitTimeout = options.MessageWaitTimeout })); } }
public Task StartAsync(OnSessionMessage messageHandler, OnSessionMessageException exceptionHandler, OnSessionMessageOptions options) { lock (_initializationLock) { if (_initialized) throw new MessageReceiverException("Message receiver has already been initialized."); if (messageHandler == null) throw new ArgumentNullException("messageHandler"); if (options == null) options = new OnSessionMessageOptions(); // Log. ServiceBusEventSource.Log.StartSessionMessageReceiver(GetType().Name, Namespace, Path); // Initialize the handler options. var sessionHandlerOptions = new SessionHandlerOptions(); sessionHandlerOptions.AutoComplete = options.AutoComplete; sessionHandlerOptions.AutoRenewTimeout = options.AutoRenewSessionTimeout; sessionHandlerOptions.MaxConcurrentSessions = options.MaxConcurrentSessions; sessionHandlerOptions.MessageWaitTimeout = options.MessageWaitTimeout; sessionHandlerOptions.ExceptionReceived += (s, e) => { if (e.Exception != null) { // Log. ServiceBusEventSource.Log.SessionMessageReceiverException(Namespace, Path, null, null, null, e.Action, e.Exception.Message, e.Exception.StackTrace); // Handle exception. if (exceptionHandler != null) exceptionHandler(e.Action, e.Exception); } }; // Mark receiver as initialized. _initialized = true; // Start. return OnStartAsync(new SessionMessageAsyncHandlerFactory(Namespace, Path, messageHandler, options), new SessionHandlerOptions { AutoComplete = options.AutoComplete, AutoRenewTimeout = options.AutoRenewSessionTimeout, MaxConcurrentSessions = options.MaxConcurrentSessions, MessageWaitTimeout = options.MessageWaitTimeout }); } }
public static Task StartAsync(this ISessionMessagePump pump, OnSessionMessage messageHandler, OnSessionMessageException exception) { return(pump.StartAsync(messageHandler, exception, null)); }
public static Task StartAsync(this ISessionMessagePump pump, OnSessionMessage messageHandler, OnSessionMessageException exception) { return pump.StartAsync(messageHandler, exception, null); }