public SqlQueuesTransport(Uri queueEndpoint,
            IEndpointRouter endpointRouter,
            IMessageSerializer messageSerializer,
            int threadCount,
            string connectionString,
            int numberOfRetries,
            IMessageBuilder<MessagePayload> messageBuilder)
        {
            this.queueEndpoint = queueEndpoint;
            this.numberOfRetries = numberOfRetries;
            this.messageBuilder = messageBuilder;
            this.endpointRouter = endpointRouter;
            this.messageSerializer = messageSerializer;
            this.threadCount = threadCount;
            this.connectionString = connectionString;

            queueName = queueEndpoint.GetQueueName();

            threads = new Thread[threadCount];

            // This has to be the first subscriber to the transport events
            // in order to successfuly handle the errors semantics
            new ErrorAction(numberOfRetries).Init(this);
            messageBuilder.Initialize(Endpoint);
        }
Пример #2
0
        public RhinoQueuesTransport(
            Uri endpoint,
            IEndpointRouter endpointRouter,
            IMessageSerializer messageSerializer,
            int threadCount,
            string path,
            IsolationLevel queueIsolationLevel,
            int numberOfRetries)
        {
            this.endpoint = endpoint;
            this.queueIsolationLevel = queueIsolationLevel;
            this.numberOfRetries = numberOfRetries;
            this.endpointRouter = endpointRouter;
            this.messageSerializer = messageSerializer;
            this.threadCount = threadCount;
            this.path = path;

            queueName = endpoint.GetQueueName();

            threads = new Thread[threadCount];

            // This has to be the first subscriber to the transport events
            // in order to successfuly handle the errors semantics
            new ErrorAction(numberOfRetries).Init(this);
        }
Пример #3
0
        public RhinoFilesTransport(Uri endpoint,
            IEndpointRouter endpointRouter,
            IMessageSerializer messageSerializer,
            int threadCount,
            string path,
            IsolationLevel queueIsolationLevel,
            int numberOfRetries,
            bool enablePerformanceCounters,
            IMessageBuilder<MessagePayload> messageBuilder,
            QueueManagerConfiguration queueManagerConfiguration)
        {
            _endpoint = endpoint;
            _queueIsolationLevel = queueIsolationLevel;
            _numberOfRetries = numberOfRetries;
            _enablePerformanceCounters = enablePerformanceCounters;
            _messageBuilder = messageBuilder;
            _queueManagerConfiguration = queueManagerConfiguration;
            _endpointRouter = endpointRouter;
            _messageSerializer = messageSerializer;
            _threadCount = threadCount;
            _path = path;

            _queueName = endpoint.GetQueueName();

            _threads = new Thread[threadCount];

            // This has to be the first subscriber to the transport events in order to successfully handle the errors semantics
            new ErrorAction(numberOfRetries).Init(this);
            messageBuilder.Initialize(Endpoint);
        }
        public void Send(Uri uri, MessagePayload payload)
        {
	        using (new internalTransactionScope(this))
	        {
		        using (var command = SqlTransactionContext.Current.Connection.CreateCommand())
				{
					command.CommandTimeout = 60;
			        command.CommandText = "Queue.EnqueueMessage";
			        command.CommandType = CommandType.StoredProcedure;
			        command.Transaction = SqlTransactionContext.Current.Transaction;
			        command.Parameters.AddWithValue("@Endpoint", uri.ToString());
			        command.Parameters.AddWithValue("@Queue", uri.GetQueueName());
			        command.Parameters.AddWithValue("@SubQueue", DBNull.Value);

			        var contents = new RawMessage
				        {
					        CreatedAt = payload.SentAt,
					        Payload = payload.Data,
					        ProcessingUntil = payload.SentAt
				        };
			        contents.SetHeaders(payload.Headers);

			        command.Parameters.AddWithValue("@CreatedAt", contents.CreatedAt);
			        command.Parameters.AddWithValue("@Payload", contents.Payload);
			        command.Parameters.AddWithValue("@ExpiresAt", DBNull.Value);
			        command.Parameters.AddWithValue("@ProcessingUntil", contents.CreatedAt);
			        command.Parameters.AddWithValue("@Headers", contents.Headers);

			        if (Logger.IsDebugEnabled)
			        {
				        Logger.DebugFormat("Sending message to {0} on {1}. Headers are '{2}'.", uri, uri.GetQueueName(),
				                           contents.Headers);
			        }

			        command.ExecuteNonQuery();
		        }
	        }
        }