public SqlTimeoutStorage(ISerializeObjects objectSerializer, ISerializeMessages messageSerializer)
 {
     this.objectSerializer = objectSerializer;
     this.messageSerializer = messageSerializer;
     connectionString = Settings.GetSetting(SqlTransportConfiguration.MessagingConnectionStringKey);
     CreateTableIfNecessary();
 }
Beispiel #2
0
 public App(ILog logger, IDataHandler dataHandler, IValidationHandler rowValidator, ISerializeObjects objectSerializer)
 {
     this.logger            = logger;
     this.dataHandler       = dataHandler;
     this.validationHandler = rowValidator;
     this.objectSerializer  = objectSerializer;
 }
 public WhenSendingMessages()
 {
     serializer    = new BinarySerializer();
     messageSender = new MessageSender <String>(TestMessageQueue.Path, serializer);
     testQueue     = TestMessageQueue.Create();
     testQueue.EnsureQueueExists();
     testQueue.Purge();
 }
 public WhenSendingMessages()
 {
     serializer = new BinarySerializer();
     messageSender = new MessageSender<String>(TestMessageQueue.Path, serializer);
     testQueue = TestMessageQueue.Create();
     testQueue.EnsureQueueExists();
     testQueue.Purge();
 }
        /// <summary>
        /// Deserializes a binary field in to an object graph.
        /// </summary>
        /// <param name="serializer">The <see cref="ISerializeObjects"/> implementation being extended.</param>
        /// <param name="buffer">The binary data to be deserialized in to an object graph.</param>
        public static T Deserialize <T>(this ISerializeObjects serializer, Byte[] buffer)
        {
            using (var stream = new MemoryStream(buffer, writable: false))
            {
                var result = serializer.Deserialize <T>(stream);

                return(result);
            }
        }
        /// <summary>
        /// Deserializes a binary field in to an object graph.
        /// </summary>
        /// <param name="serializer">The <see cref="ISerializeObjects"/> implementation being extended.</param>
        /// <param name="buffer">The binary data to be deserialized in to an object graph.</param>
        /// <param name="type">The <see cref="Type"/> of object being deserialized.</param>
        public static Object Deserialize(this ISerializeObjects serializer, Byte[] buffer, Type type)
        {
            using (var stream = new MemoryStream(buffer, writable: false))
            {
                var result = serializer.Deserialize(stream, type);

                return(result);
            }
        }
        /// <summary>
        /// Serializes an object graph to binary data.
        /// </summary>
        /// <param name="serializer">The <see cref="ISerializeObjects"/> implementation being extended.</param>
        /// <param name="graph">The object graph to serialize.</param>
        public static Byte[] Serialize <T>(this ISerializeObjects serializer, T graph)
        {
            using (var stream = new MemoryStream())
            {
                serializer.Serialize(stream, graph);

                return(stream.ToArray());
            }
        }
        /// <summary>
        /// Initializes a new instance of <see cref="SqlSagaStore"/>.
        /// </summary>
        /// <param name="dialect">The database dialect associated with this <see cref="SqlSagaStore"/>.</param>
        /// <param name="serializer">The <see cref="ISerializeObjects"/> used to store binary data.</param>
        /// <param name="typeLocator">The type locator use to retrieve all known <see cref="Saga"/> types.</param>
        public SqlSagaStore(ISagaStoreDialect dialect, ISerializeObjects serializer, ILocateTypes typeLocator)
        {
            Verify.NotNull(typeLocator, nameof(typeLocator));
            Verify.NotNull(serializer, nameof(serializer));
            Verify.NotNull(dialect, nameof(dialect));

            this.dialect = dialect;
            this.serializer = serializer;
            this.typeToGuidMap = GetKnownSagas(typeLocator);
            this.guidToTypeMap = typeToGuidMap.ToDictionary(item => item.Value, item => item.Key);

            Initialize();
        }
Beispiel #9
0
        /// <summary>
        /// Initializes a new instance of <see cref="SqlSagaStore"/>.
        /// </summary>
        /// <param name="dialect">The database dialect associated with this <see cref="SqlSagaStore"/>.</param>
        /// <param name="serializer">The <see cref="ISerializeObjects"/> used to store binary data.</param>
        /// <param name="typeLocator">The type locator use to retrieve all known <see cref="Saga"/> types.</param>
        public SqlSagaStore(ISagaStoreDialect dialect, ISerializeObjects serializer, ILocateTypes typeLocator)
        {
            Verify.NotNull(typeLocator, nameof(typeLocator));
            Verify.NotNull(serializer, nameof(serializer));
            Verify.NotNull(dialect, nameof(dialect));

            this.dialect       = dialect;
            this.serializer    = serializer;
            this.typeToGuidMap = GetKnownSagas(typeLocator);
            this.guidToTypeMap = typeToGuidMap.ToDictionary(item => item.Value, item => item.Key);

            Initialize();
        }
        /// <summary>
        /// Initializes a new instance of <see cref="SqlSnapshotStore"/> with a custom <see cref="ISnapshotStoreDialect"/>.
        /// </summary>
        /// <param name="serializer">The <see cref="ISerializeObjects"/> used to store binary data.</param>
        /// <param name="settings">The snapshot store settings.</param>
        /// <param name="dialect">The database dialect associated with this <see cref="SqlSnapshotStore"/>.</param>
        internal SqlSnapshotStore(ISnapshotStoreDialect dialect, ISerializeObjects serializer, IStoreSnapshotSettings settings)
        {
            Verify.NotNull(serializer, nameof(serializer));
            Verify.NotNull(settings, nameof(settings));
            Verify.NotNull(dialect, nameof(dialect));

            this.dialect = dialect;
            this.serializer = serializer;
            this.useAsyncWrite = settings.Async;
            this.replaceExisting = settings.ReplaceExisting;
            this.buffer = settings.Async ? CreateBuffer(settings, dialect) : null;

            Initialize();
        }
        /// <summary>
        /// Initializes a new instance of <see cref="SqlSnapshotStore"/> with a custom <see cref="ISnapshotStoreDialect"/>.
        /// </summary>
        /// <param name="serializer">The <see cref="ISerializeObjects"/> used to store binary data.</param>
        /// <param name="settings">The snapshot store settings.</param>
        /// <param name="dialect">The database dialect associated with this <see cref="SqlSnapshotStore"/>.</param>
        internal SqlSnapshotStore(ISnapshotStoreDialect dialect, ISerializeObjects serializer, IStoreSnapshotSettings settings)
        {
            Verify.NotNull(serializer, nameof(serializer));
            Verify.NotNull(settings, nameof(settings));
            Verify.NotNull(dialect, nameof(dialect));

            this.dialect         = dialect;
            this.serializer      = serializer;
            this.useAsyncWrite   = settings.Async;
            this.replaceExisting = settings.ReplaceExisting;
            this.buffer          = settings.Async ? CreateBuffer(settings, dialect) : null;

            Initialize();
        }
        /// <summary>
        /// Initializes a new instance of <see cref="SqlEventStore"/> with a custom <see cref="IEventStoreDialect"/>.
        /// </summary>
        /// <param name="dialect">The database dialect associated with this <see cref="SqlEventStore"/>.</param>
        /// <param name="serializer">The <see cref="ISerializeObjects"/> used to store binary data.</param>
        /// <param name="settings">The event store settings.</param>
        internal SqlEventStore(IEventStoreDialect dialect, ISerializeObjects serializer, IStoreEventSettings settings)
        {
            Verify.NotNull(serializer, nameof(serializer));
            Verify.NotNull(settings, nameof(settings));
            Verify.NotNull(dialect, nameof(dialect));

            this.dialect = dialect;
            this.serializer = serializer;
            this.pageSize = settings.PageSize;
            this.useAsyncWrite = settings.Async;
            this.detectDuplicateCommits = settings.DetectDuplicateCommits;
            this.dispatchedBuffer = settings.Async ? CreateBuffer(settings, dialect) : null;

            Initialize();
        }
Beispiel #13
0
        /// <summary>
        /// Initializes a new instance of <see cref="SqlEventStore"/> with a custom <see cref="IEventStoreDialect"/>.
        /// </summary>
        /// <param name="dialect">The database dialect associated with this <see cref="SqlEventStore"/>.</param>
        /// <param name="serializer">The <see cref="ISerializeObjects"/> used to store binary data.</param>
        /// <param name="settings">The event store settings.</param>
        internal SqlEventStore(IEventStoreDialect dialect, ISerializeObjects serializer, IStoreEventSettings settings)
        {
            Verify.NotNull(serializer, nameof(serializer));
            Verify.NotNull(settings, nameof(settings));
            Verify.NotNull(dialect, nameof(dialect));

            this.dialect                = dialect;
            this.serializer             = serializer;
            this.pageSize               = settings.PageSize;
            this.useAsyncWrite          = settings.Async;
            this.detectDuplicateCommits = settings.DetectDuplicateCommits;
            this.dispatchedBuffer       = settings.Async ? CreateBuffer(settings, dialect) : null;

            Initialize();
        }
        public static TransportMessage BuildTransportMessage(this SqlDataReader dataReader, ISerializeObjects objectSerializer)
        {
            var timeTolive = GetTimeTolive(dataReader);

            if (timeTolive == TimeSpan.Zero)
            {
                return TransportMessage.Undefined;
            }

            var messageId = dataReader.GetGuid(MessageIdIndex);
            var correlationId = dataReader.IsDBNull(CorrelationIdIndex) ? Guid.Empty : Guid.Parse(dataReader.GetString(CorrelationIdIndex));
            var replyToAddress = dataReader.GetString(ReplyToAddressIndex);
            var headers = objectSerializer.DeserializeObject<Dictionary<string, string>>(dataReader.GetString(HeadersIndex));
            var body = dataReader.IsDBNull(BodyIndex) ? null : dataReader.GetSqlBinary(BodyIndex).Value;

            return new TransportMessage(messageId, correlationId, Address.Parse(replyToAddress), timeTolive, headers, body);
        }
        public SqlTransportPerfomanceMonitor(ISerializeObjects serializer)
        {
            this.serializer = serializer;
            connectionString = ConfigurationManager.ConnectionStrings["SqlTransport"].ConnectionString;

            timer = new Timer
            {
                Interval = monitoringPeriod.TotalMilliseconds,
                AutoReset = true,
            };

            timer.Elapsed += Elapsed;
            timer.Start();

            previousAudit = GetCurrentAuditMessageCount();
            previousError = GetCurrentErrorMessageCount();
        }
Beispiel #16
0
 /// <summary>
 /// Initializes a new instance of <see cref="SqlEventStore"/>.
 /// </summary>
 /// <param name="dialect">The database dialect associated with this <see cref="SqlEventStore"/>.</param>
 /// <param name="serializer">The <see cref="ISerializeObjects"/> used to store binary data.</param>
 public SqlEventStore(IEventStoreDialect dialect, ISerializeObjects serializer)
     : this(dialect, serializer, Settings.EventStore)
 {
 }
        /// <summary>
        /// Deserialize an object graph from the speciied <paramref name="stream"/>.
        /// </summary>
        /// <param name="serializer">The <see cref="ISerializeObjects"/> implementation being extended.</param>
        /// <param name="stream">The <see cref="Stream"/> from which to deserialize an object graph.</param>
        public static T Deserialize <T>(this ISerializeObjects serializer, Stream stream)
        {
            Verify.NotNull(serializer, nameof(serializer));

            return((T)serializer.Deserialize(stream, typeof(T)));
        }
Beispiel #18
0
        public static void Startup(TestContext context)
        {
            messageMapper = new TypeMapper();
            messageSerializer = new JsonMessageSerializer(messageMapper);
            objectSerializer = new JsonObjectSerializer();

            testMessage = new MyEventMessage(DateTime.Now, Guid.NewGuid(), "Hello there");

            messageMapper.Initialize(testMessage.GetType().GetInterfaces());
        }
        /// <summary>
        /// Serializes the object graph to the specified <paramref name="stream"/>.
        /// </summary>
        /// <param name="serializer">The <see cref="ISerializeObjects"/> implementation being extended.</param>
        /// <param name="stream">The <see cref="Stream"/> on which to serialize the object <paramref name="graph"/>.</param>
        /// <param name="graph">The object to serialize.</param>
        public static void Serialize <T>(this ISerializeObjects serializer, Stream stream, T graph)
        {
            Verify.NotNull(serializer, nameof(serializer));

            serializer.Serialize(stream, graph, typeof(T));
        }
Beispiel #20
0
 public SqlMessageSender(ISerializeObjects objectSerializer)
 {
     this.objectSerializer = objectSerializer;
     connectionString = Settings.GetSetting<string>(SqlTransportConfiguration.MessagingConnectionStringKey);
 }
        /// <summary>
        /// Initializes a new instance of <see cref="GZipSerializer"/>.
        /// </summary>
        /// <param name="serializer">The base serializer to wrap with GZip compression.</param>
        public GZipSerializer(ISerializeObjects serializer)
        {
            Verify.NotNull(serializer, nameof(serializer));

            this.serializer = serializer;
        }
 /// <summary>
 /// Initializes a new instance of <see cref="SqlSnapshotStore"/>.
 /// </summary>
 /// <param name="dialect">The database dialect associated with this <see cref="SqlSnapshotStore"/>.</param>
 /// <param name="serializer">The <see cref="ISerializeObjects"/> used to store binary data.</param>
 public SqlSnapshotStore(ISnapshotStoreDialect dialect, ISerializeObjects serializer)
     : this(dialect, serializer, Settings.SnapshotStore)
 {
 }
 /// <summary>
 /// Initializes a new instance of <see cref="SqlSnapshotStore"/>.
 /// </summary>
 /// <param name="dialect">The database dialect associated with this <see cref="SqlSnapshotStore"/>.</param>
 /// <param name="serializer">The <see cref="ISerializeObjects"/> used to store binary data.</param>
 public SqlSnapshotStore(ISnapshotStoreDialect dialect, ISerializeObjects serializer)
     : this(dialect, serializer, Settings.SnapshotStore)
 {
 }
 public SqlErrorQueueManager(ISerializeObjects serializer, ISendMessages messageSender)
 {
     this.serializer = serializer;
     this.messageSender = messageSender;
     connectionString = Settings.GetSetting(SqlTransportConfiguration.MessagingConnectionStringKey);
 }
 /// <summary>
 /// Initializes a new instance of <see cref="SqlEventStore"/>.
 /// </summary>
 /// <param name="dialect">The database dialect associated with this <see cref="SqlEventStore"/>.</param>
 /// <param name="serializer">The <see cref="ISerializeObjects"/> used to store binary data.</param>
 public SqlEventStore(IEventStoreDialect dialect, ISerializeObjects serializer)
     : this(dialect, serializer, Settings.EventStore)
 {
 }
        /// <summary>
        /// Initializes a new instance of <see cref="GZipSerializer"/>.
        /// </summary>
        /// <param name="serializer">The base serializer to wrap with GZip compression.</param>
        public GZipSerializer(ISerializeObjects serializer)
        {
            Verify.NotNull(serializer, nameof(serializer));

            this.serializer = serializer;
        }
 public KeyValueStorePersister(IRepositoryFactory repositoryFactory, ISerializeObjects serializer)
 {
     this.repositoryFactory = repositoryFactory;
     this.serializer = serializer;
 }
 public SqlMessageDequeStrategy(ISerializeObjects objectSerializer)
 {
     connectionString = Settings.GetSetting<string>(SqlTransportConfiguration.MessagingConnectionStringKey);
     this.objectSerializer = objectSerializer;
 }