/// <summary> /// Initialize a DomainEventMessage originating from an Aggregate using existing data. The timestamp of the event is /// supplied lazily to prevent unnecessary deserialization of the timestamp. /// </summary> /// <param name="type">The domain type</param> /// <param name="aggregateIdentifier">The identifier of the aggregate generating this message</param> /// <param name="sequenceNumber">The message's sequence number</param> /// <param name="delegate">The delegate message providing the payload, metadata and identifier of the event</param> /// <param name="timestamp">The event's timestamp supplier</param> public GenericDomainEventMessage(string type, string aggregateIdentifier, long sequenceNumber, IMessage <T> @delegate, CachingSupplier <InternalDateTimeOffset> timestamp) : base(@delegate, timestamp) { _type = type; _aggregateIdentifier = aggregateIdentifier; _sequenceNumber = sequenceNumber; }
/// <summary> /// Returns the given {@code deadlineName} and {@code messageOrPayload} as a DeadlineMessage which expires at the /// given {@code expiryTime}. If the {@code messageOrPayload} parameter is of type {@link Message}, a new /// {@code DeadlineMessage} instance will be created using the payload and meta data of the given message. /// Otherwise, the given {@code messageOrPayload} is wrapped into a {@code GenericDeadlineMessage} as its payload. /// </summary> /// <param name="deadlineName">A {@link String} denoting the deadline's name</param> /// <param name="messageOrPayload">A {@link Message} or payload to wrap as a DeadlineMessage</param> /// <param name="expiryTime">The timestamp at which the deadline expires</param> /// <typeparam name="T">The generic type of the expected payload of the resulting object</typeparam> /// <returns>a DeadlineMessage using the {@code deadlineName} as its deadline name and containing the given /// {@code messageOrPayload} as the payload</returns> public static IDeadlineMessage <T> AsDeadlineMessage(string deadlineName, object messageOrPayload, InternalDateTimeOffset expiryTime) { return(messageOrPayload is IMessage <T> message ? new GenericDeadlineMessage <T>(deadlineName, message, CachingSupplier <InternalDateTimeOffset> .Of(() => expiryTime)) : new GenericDeadlineMessage <T>(deadlineName, new GenericMessage <T>((T)messageOrPayload), CachingSupplier <InternalDateTimeOffset> .Of(() => expiryTime))); }
/// <summary> /// Initialize a DomainEventMessage originating from an Aggregate using existing data. The timestamp of the event is /// supplied lazily to prevent unnecessary deserialization of the timestamp. /// </summary> /// <param name="trackingToken">Tracking token of the event</param> /// <param name="type">The domain type</param> /// <param name="aggregateIdentifier">The identifier of the aggregate generating this message</param> /// <param name="sequenceNumber">The message's sequence number</param> /// <param name="delegate">The delegate message providing the payload, metadata and identifier of the event</param> /// <param name="timestamp">The event's timestamp supplier</param> public GenericTrackedDomainEventMessage( ITrackingToken trackingToken, string type, string aggregateIdentifier, long sequenceNumber, IMessage <T> @delegate, CachingSupplier <InternalDateTimeOffset> timestamp ) : base(type, aggregateIdentifier, sequenceNumber, @delegate, timestamp) { _trackingToken = trackingToken; }
protected GenericEventMessage(IMessage <T> @delegate, InternalDateTimeOffset?timestamp) : this(@delegate, CachingSupplier <InternalDateTimeOffset> .Of(timestamp)) { }
public GenericEventMessage(IMessage <T> @delegate, CachingSupplier <InternalDateTimeOffset> timestampSupplier) : base(@delegate) { TimestampSupplier = timestampSupplier; }
/// <summary> /// Constructor to reconstruct a DeadlineMessage using existing data. The timestamp of the event is supplied lazily /// to prevent unnecessary deserialization of the timestamp. /// </summary> /// <param name="deadlineName">A {@link String} denoting the deadline's name</param> /// <param name="delegate">The identifier of type {@link String} for the Message</param> /// <param name="timestampSupplier">{@link Supplier} for the timestamp of the Message creation</param> public GenericDeadlineMessage(string deadlineName, IMessage <T> @delegate, CachingSupplier <InternalDateTimeOffset> timestampSupplier) : base(@delegate, timestampSupplier) { _deadlineName = deadlineName; }