Exemplo n.º 1
0
        public static LogEntry For(RepublishRequest request)
        {
            LogEntry entry = new LogEntry("RepublishRequest");

            entry.Add("RequestHeader", For(request.RequestHeader));
            entry.Add("SubscriptionId", For(request.SubscriptionId));
            entry.Add("RetransmitSequenceNumber", For(request.RetransmitSequenceNumber));
            return(entry);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Republish([FromBody] RepublishRequest model)
        {
            var arId = AggregateUrn.Parse(model.Id, Urn.Uber);

            if (model.IsPublicEvent)
            {
                IPublicEvent @event = await _eventExplorer.FindPublicEventAsync(arId, model.CommitRevision, model.EventPosition);

                if (@event is null)
                {
                    return(BadRequest("Event not found"));
                }

                Dictionary <string, string> headers = new Dictionary <string, string>()
                {
                    { MessageHeader.AggregateRootId, arId.ToBase64() }
                };

                publicPublisher.Publish(@event, headers);
            }
            else
            {
                IEvent @event = await _eventExplorer.FindEventAsync(arId, model.CommitRevision, model.EventPosition);

                if (@event is null)
                {
                    return(BadRequest("Event not found"));
                }

                string recipientHandlers = ConcatRecipientHandlers(model.RecipientHandlers);

                Dictionary <string, string> headers = new Dictionary <string, string>()
                {
                    { MessageHeader.AggregateRootId, arId.ToBase64() },
                    { MessageHeader.AggregateRootRevision, model.CommitRevision.ToString() },
                    { MessageHeader.AggregateRootEventPosition, model.EventPosition.ToString() },
                    { MessageHeader.RecipientHandlers, string.Join(',', recipientHandlers) }
                };

                publisher.Publish(@event, headers);
            }

            return(new OkObjectResult(new ResponseResult()));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Requests the Server to republish a NotificationMessage from its retransmission queue.
        /// </summary>
        /// <param name="channel">A instance of <see cref="IRequestChannel"/>.</param>
        /// <param name="request">A <see cref="RepublishRequest"/>.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation that returns a <see cref="RepublishResponse"/>.</returns>
        internal static async Task <RepublishResponse> RepublishAsync(this IRequestChannel channel, RepublishRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            return((RepublishResponse)await channel.RequestAsync(request).ConfigureAwait(false));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Begins an asynchronous invocation of the Republish service.
        /// </summary>
        public IAsyncResult BeginRepublish(
            RequestHeader requestHeader,
            uint          subscriptionId,
            uint          retransmitSequenceNumber,
            AsyncCallback callback,
            object        asyncState)
        {
            RepublishRequest request = new RepublishRequest();

            request.RequestHeader            = requestHeader;
            request.SubscriptionId           = subscriptionId;
            request.RetransmitSequenceNumber = retransmitSequenceNumber;

            UpdateRequestHeader(request, requestHeader == null, "Republish");

            if (UseTransportChannel)
            {
                return TransportChannel.BeginSendRequest(request, callback, asyncState);
            }

            return InnerChannel.BeginRepublish(new RepublishMessage(request), callback, asyncState);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Invokes the Republish service.
        /// </summary>
        public virtual ResponseHeader Republish(
            RequestHeader           requestHeader,
            uint                    subscriptionId,
            uint                    retransmitSequenceNumber,
            out NotificationMessage notificationMessage)
        {
            RepublishRequest request = new RepublishRequest();
            RepublishResponse response = null;

            request.RequestHeader            = requestHeader;
            request.SubscriptionId           = subscriptionId;
            request.RetransmitSequenceNumber = retransmitSequenceNumber;

            UpdateRequestHeader(request, requestHeader == null, "Republish");

            try
            {
                if (UseTransportChannel)
                {
                    IServiceResponse genericResponse = TransportChannel.SendRequest(request);

                    if (genericResponse == null)
                    {
                        throw new ServiceResultException(StatusCodes.BadUnknownResponse);
                    }

                    ValidateResponse(genericResponse.ResponseHeader);
                    response = (RepublishResponse)genericResponse;
                }
                else
                {
                    RepublishResponseMessage responseMessage = InnerChannel.Republish(new RepublishMessage(request));

                    if (responseMessage == null || responseMessage.RepublishResponse == null)
                    {
                        throw new ServiceResultException(StatusCodes.BadUnknownResponse);
                    }

                    response = responseMessage.RepublishResponse;
                    ValidateResponse(response.ResponseHeader);
                }

                notificationMessage = response.NotificationMessage;
            }
            finally
            {
                RequestCompleted(request, response, "Republish");
            }

            return response.ResponseHeader;
        }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes the message with the body.
 /// </summary>
 public RepublishMessage(RepublishRequest RepublishRequest)
 {
     this.RepublishRequest = RepublishRequest;
 }