/// <summary>
 /// Initialize the handler factory.
 /// </summary>
 /// <param name="receiverNamespace"></param>
 /// <param name="receiverPath"></param>
 /// <param name="messageHandler"></param>
 /// <param name="options"></param>
 public SessionMessageAsyncHandlerFactory(string receiverNamespace, string receiverPath, OnSessionMessage messageHandler, OnSessionMessageOptions options)
 {
     _receiverNamespace = receiverNamespace;
     _receiverPath = receiverPath;
     _messageHandler = messageHandler;
     _options = options;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Initialize the handler factory.
 /// </summary>
 /// <param name="receiverNamespace"></param>
 /// <param name="receiverPath"></param>
 /// <param name="messageHandler"></param>
 /// <param name="options"></param>
 public SessionMessageAsyncHandlerFactory(string receiverNamespace, string receiverPath, OnSessionMessage messageHandler, OnSessionMessageOptions options)
 {
     _receiverNamespace = receiverNamespace;
     _receiverPath      = receiverPath;
     _messageHandler    = messageHandler;
     _options           = options;
 }
Exemplo n.º 3
0
 public SessionMessageAsyncHandler(string receiverNamespace, string receiverPath, MessageSession session, OnSessionMessage messageHandler, OnSessionMessageOptions options)
 {
     _receiverNamespace = receiverNamespace;
     _receiverPath = receiverPath;
     _session = session;
     _messageHandler = messageHandler;
     _options = options;
 }
Exemplo n.º 4
0
 public SessionMessageAsyncHandler(string receiverNamespace, string receiverPath, MessageSession session, OnSessionMessage messageHandler, OnSessionMessageOptions options)
 {
     _receiverNamespace = receiverNamespace;
     _receiverPath      = receiverPath;
     _session           = session;
     _messageHandler    = messageHandler;
     _options           = options;
 }
        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
                });
            }
        }
Exemplo n.º 6
0
 public QueueSessionMessagePump(QueueClient client, OnSessionMessageOptions options = null)
     : base(client, client.Mode, client.MessagingFactory.GetShortNamespaceName(), client.Path, options)
 {
     _client = client;
 }
 public static Task StartAsync(this ISessionMessagePump pump, OnSessionMessage messageHandler, OnSessionMessageOptions options)
 {
     return(pump.StartAsync(messageHandler, null, options));
 }
 public SubscriptionSessionMessagePump(SubscriptionClient client, OnSessionMessageOptions options = null)
     : base(client, client.Mode, client.MessagingFactory.GetShortNamespaceName(), client.TopicPath + "/" + client.Name, options)
 {
     _client = client;
 }
 public SubscriptionSessionMessagePump(SubscriptionClient client, OnSessionMessageOptions options = null)
     : base(client, client.Mode, client.MessagingFactory.GetShortNamespaceName(), client.TopicPath + "/" + client.Name, options)
 {
     _client = client;
 }
Exemplo n.º 10
0
 protected EventDrivenSessionMessagePump(MessageClientEntity messageClient, ReceiveMode mode, string @namespace, string path, OnSessionMessageOptions defaultOptions)
     : base(mode, @namespace, path)
 {
     _messageClient = messageClient;
     _defaultOptions = defaultOptions ?? new OnSessionMessageOptions();
 }
Exemplo n.º 11
0
 public QueueSessionMessagePump(QueueClient client, OnSessionMessageOptions options = null)
     : base(client, client.Mode, client.MessagingFactory.GetShortNamespaceName(), client.Path, options)
 {
     _client = client;
 }
Exemplo n.º 12
0
        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
                }));
            }
        }
Exemplo n.º 13
0
 protected EventDrivenSessionMessagePump(MessageClientEntity messageClient, ReceiveMode mode, string @namespace, string path, OnSessionMessageOptions defaultOptions)
     : base(mode, @namespace, path)
 {
     _messageClient  = messageClient;
     _defaultOptions = defaultOptions ?? new OnSessionMessageOptions();
 }
 public static Task StartAsync(this ISessionMessagePump pump, OnSessionMessage messageHandler, OnSessionMessageOptions options)
 {
     return pump.StartAsync(messageHandler, null, options);
 }