Example #1
0
        public SqlServerCallbackTests()
        {
            // SAMPLE: SqlServer-RebuildMessageStorage
            theRuntime = JasperRuntime.For(_ =>
            {
                _.Settings.PersistMessagesWithSqlServer(ConnectionSource.ConnectionString);
            });

            theRuntime.RebuildMessageStorage();
            // ENDSAMPLE

            theEnvelope        = ObjectMother.Envelope();
            theEnvelope.Status = TransportConstants.Incoming;



            thePersistor = theRuntime.Get <SqlServerEnvelopePersistor>();
            thePersistor.StoreIncoming(theEnvelope).Wait(3.Seconds());


            var logger = TransportLogger.Empty();

            theRetries = new EnvelopeRetries(thePersistor, logger, new MessagingSettings());



            theCallback = new DurableCallback(theEnvelope, Substitute.For <IWorkerQueue>(), thePersistor, theRetries, logger);
        }
Example #2
0
        public outbox_usage()
        {
            theSender   = JasperRuntime.For <ItemSender>();
            theReceiver = JasperRuntime.For <ItemReceiver>();
            theTracker  = theReceiver.Get <MessageTracker>();

            theSender.RebuildMessageStorage();
            theReceiver.RebuildMessageStorage();

            thePersistor = theReceiver.Get <SqlServerEnvelopePersistor>();

            using (var conn = new SqlConnection(ConnectionSource.ConnectionString))
            {
                conn.Open();

                conn.CreateCommand(@"
IF OBJECT_ID('receiver.item_created', 'U') IS NOT NULL
  drop table receiver.item_created;

").ExecuteNonQuery();

                conn.CreateCommand(@"
create table receiver.item_created
(
	id uniqueidentifier not null
		primary key,
	name varchar(100) not null
);

").ExecuteNonQuery();
            }
        }
 public SqlServerEnveloperPersistorTests()
 {
     thePersistor
         = new SqlServerEnvelopePersistor(new SqlServerSettings
     {
         ConnectionString = Servers.SqlServerConnectionString
     });
 }
Example #4
0
        private async Task markOwnership(SqlConnection conn, SqlTransaction tx, Envelope[] outgoing)
        {
            var cmd = conn.CreateCommand(tx, $"{_mssqlSettings.SchemaName}.uspMarkOutgoingOwnership");

            cmd.CommandType = CommandType.StoredProcedure;
            var list = cmd.Parameters.AddWithValue("IDLIST", SqlServerEnvelopePersistor.BuildIdTable(outgoing));

            list.SqlDbType = SqlDbType.Structured;
            list.TypeName  = $"{_mssqlSettings.SchemaName}.EnvelopeIdList";
            cmd.Parameters.AddWithValue("owner", _settings.UniqueNodeId).SqlDbType = SqlDbType.Int;

            await cmd.ExecuteNonQueryAsync();
        }
Example #5
0
        private async Task <Envelope[]> filterExpired(SqlConnection conn, SqlTransaction tx, IEnumerable <Envelope> outgoing)
        {
            var expiredMessages = outgoing.Where(x => x.IsExpired()).ToArray();

            _logger.DiscardedExpired(expiredMessages);

            var cmd = conn.CreateCommand(tx, $"{_mssqlSettings.SchemaName}.uspDeleteOutgoingEnvelopes");

            cmd.CommandType = CommandType.StoredProcedure;
            var list = cmd.Parameters.AddWithValue("IDLIST", SqlServerEnvelopePersistor.BuildIdTable(expiredMessages));

            list.SqlDbType = SqlDbType.Structured;
            list.TypeName  = $"{_mssqlSettings.SchemaName}.EnvelopeIdList";

            await cmd.ExecuteNonQueryAsync();

            return(outgoing.Where(x => !x.IsExpired()).ToArray());
        }
Example #6
0
        public SqlServerBackedListenerContext()
        {
            new SchemaLoader(ConnectionSource.ConnectionString).RecreateAll();

            theWorkerQueue = Substitute.For <IWorkerQueue>();

            theSettings = new MessagingSettings();

            mssqlSettings = new SqlServerSettings
            {
                ConnectionString = ConnectionSource.ConnectionString
            };

            thePersistor = new SqlServerEnvelopePersistor(mssqlSettings);

            retries = new EnvelopeRetries(thePersistor, TransportLogger.Empty(), theSettings);


            theListener = new DurableListener(
                Substitute.For <IListeningAgent>(),
                theWorkerQueue,
                TransportLogger.Empty(), theSettings, retries, thePersistor);
        }
Example #7
0
 public static void post_clear(SqlServerEnvelopePersistor persistor)
 {
     persistor.ClearAllStoredMessages();
 }