コード例 #1
0
 public SqlTimeoutStorage(ISerializeObjects objectSerializer, ISerializeMessages messageSerializer)
 {
     this.objectSerializer = objectSerializer;
     this.messageSerializer = messageSerializer;
     connectionString = Settings.GetSetting(SqlTransportConfiguration.MessagingConnectionStringKey);
     CreateTableIfNecessary();
 }
コード例 #2
0
 public App(ILog logger, IDataHandler dataHandler, IValidationHandler rowValidator, ISerializeObjects objectSerializer)
 {
     this.logger            = logger;
     this.dataHandler       = dataHandler;
     this.validationHandler = rowValidator;
     this.objectSerializer  = objectSerializer;
 }
コード例 #3
0
 public WhenSendingMessages()
 {
     serializer    = new BinarySerializer();
     messageSender = new MessageSender <String>(TestMessageQueue.Path, serializer);
     testQueue     = TestMessageQueue.Create();
     testQueue.EnsureQueueExists();
     testQueue.Purge();
 }
コード例 #4
0
 public WhenSendingMessages()
 {
     serializer = new BinarySerializer();
     messageSender = new MessageSender<String>(TestMessageQueue.Path, serializer);
     testQueue = TestMessageQueue.Create();
     testQueue.EnsureQueueExists();
     testQueue.Purge();
 }
コード例 #5
0
        /// <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);
            }
        }
コード例 #6
0
        /// <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);
            }
        }
コード例 #7
0
        /// <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());
            }
        }
コード例 #8
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();
        }
コード例 #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();
        }
コード例 #10
0
        /// <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();
        }
コード例 #11
0
        /// <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();
        }
コード例 #12
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();
        }
コード例 #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();
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        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();
        }
コード例 #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)
 {
 }
コード例 #17
0
        /// <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)));
        }
コード例 #18
0
ファイル: UnitTest1.cs プロジェクト: AdrianFreemantle/Hermes
        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());
        }
コード例 #19
0
        /// <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));
        }
コード例 #20
0
ファイル: SqlMessageSender.cs プロジェクト: kehinze/Hermes
 public SqlMessageSender(ISerializeObjects objectSerializer)
 {
     this.objectSerializer = objectSerializer;
     connectionString = Settings.GetSetting<string>(SqlTransportConfiguration.MessagingConnectionStringKey);
 }
コード例 #21
0
        /// <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;
        }
コード例 #22
0
 /// <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)
 {
 }
コード例 #23
0
 /// <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)
 {
 }
コード例 #24
0
 public SqlErrorQueueManager(ISerializeObjects serializer, ISendMessages messageSender)
 {
     this.serializer = serializer;
     this.messageSender = messageSender;
     connectionString = Settings.GetSetting(SqlTransportConfiguration.MessagingConnectionStringKey);
 }
コード例 #25
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)
 {
 }
コード例 #26
0
        /// <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;
        }
コード例 #27
0
 public KeyValueStorePersister(IRepositoryFactory repositoryFactory, ISerializeObjects serializer)
 {
     this.repositoryFactory = repositoryFactory;
     this.serializer = serializer;
 }
コード例 #28
0
 public SqlMessageDequeStrategy(ISerializeObjects objectSerializer)
 {
     connectionString = Settings.GetSetting<string>(SqlTransportConfiguration.MessagingConnectionStringKey);
     this.objectSerializer = objectSerializer;
 }