Example #1
0
        public void Send(object message, IDictionary <string, string> headers)
        {
            // create an envelope for the message
            Envelope newEnvelope = new Envelope();

            newEnvelope.Headers = headers ?? new Dictionary <string, string>();

            // create a message context for message processing
            MessageContext ctx = new MessageContext(
                MessageContext.Directions.Out, newEnvelope, message);

            // process the message
            this.ProcessMessage(ctx, () =>
            {
                try
                {
                    _envelopeSender.Send(ctx.Envelope);
                }
                catch (Exception ex)
                {
                    string msg = "Failed to send an envelope.";
                    Log.Error(msg, ex);
                    throw new MessageException(msg, ex);
                }
            });
        }
Example #2
0
 public void Send(Envelope envelope)
 {
     try
     {
         if (envelope.Callback != null && envelope.Callback.SupportsSend)
         {
             _sender.Send(envelope, envelope.Callback);
         }
         else
         {
             _sender.Send(envelope);
         }
     }
     catch (Exception e)
     {
         // TODO -- we really, really have to do something here
         Logger.LogException(e, envelope.CorrelationId, "Failure while trying to send a cascading message");
     }
 }
        public virtual void SendSubscriptionChangedToPeer(TransportNode node)
        {
            var envelope = new Envelope
            {
                Message     = new SubscriptionsChanged(),
                Destination = node.ControlChannel
            };

            _sender.Send(envelope);
        }
        public virtual void SendSubscriptionChangedToPeer(TransportNode node)
        {
            var envelope = new Envelope
            {
                Message     = new SubscriptionsChanged(),
                Destination = node.Addresses.FirstOrDefault()
            };

            _sender.Send(envelope);
        }
Example #5
0
 public void Send(Envelope envelope)
 {
     try
     {
         _sender.Send(envelope);
     }
     catch (Exception e)
     {
         // TODO -- we really, really have to do something here
         _logger.Error(envelope.OriginalId, "Failure while trying to send a cascading message", e);
     }
 }
Example #6
0
        public Task Send(Envelope envelope)
        {
            try
            {
                if (envelope.Callback != null && envelope.Callback.SupportsSend)
                {
                    return(_sender.Send(envelope, envelope.Callback));
                }
                else
                {
                    return(_sender.Send(envelope));
                }
            }
            catch (Exception e)
            {
                Logger.Undeliverable(envelope);
                Logger.LogException(e, envelope.CorrelationId, "Failure while trying to send a cascading message");
            }

            return(Task.CompletedTask);
        }
Example #7
0
        public Task <TResponse> Request <TResponse>(object request, RequestOptions options = null)
        {
            options = options ?? new RequestOptions();

            var envelope = new Envelope
            {
                Message        = request,
                ReplyRequested = typeof(TResponse).Name
            };

            if (options.Destination != null)
            {
                envelope.Destination = options.Destination;
            }


            var task = _watcher.StartWatch <TResponse>(envelope.CorrelationId, options.Timeout);

            _sender.Send(envelope);

            return(task);
        }
Example #8
0
        private void sendSubscriptionsToSource(Uri destination, IEnumerable <Subscription> subscriptions)
        {
            var envelope = new Envelope
            {
                Message = new SubscriptionRequested
                {
                    Subscriptions = subscriptions.ToArray()
                },
                Destination = destination
            };

            _sender.Send(envelope);
        }
Example #9
0
        public Task Send(Envelope envelope)
        {
            try
            {
                return(_sender.Send(envelope));
            }
            catch (Exception e)
            {
                Logger.LogException(e, envelope.Id, "Failure while trying to send a cascading message");
            }

            return(Task.CompletedTask);
        }
Example #10
0
        // The destination override is tested as part of the monitoring integration
        public Task <TResponse> Request <TResponse>(object request, RequestOptions options = null)
        {
            options = options ?? new RequestOptions();

            var envelope = new Envelope
            {
                Message        = request,
                ReplyRequested = typeof(TResponse).Name
            };

            if (options.Destination != null)
            {
                envelope.Destination = options.Destination;
            }

            var listener = new ReplyListener <TResponse>(_events, envelope.CorrelationId, options.Timeout);

            _events.AddListener(listener);

            _sender.Send(envelope);

            return(listener.Completion);
        }
Example #11
0
        public async Task <TResponse> Request <TResponse>(object request, TimeSpan timeout = default(TimeSpan), Action <Envelope> configure = null)
        {
            var envelope = EnvelopeForRequestResponse <TResponse>(request);

            configure?.Invoke(envelope);

            timeout = timeout == default(TimeSpan) ? 10.Seconds() : timeout;

            var watcher = _watcher.StartWatch <TResponse>(envelope.Id, timeout);

            await _sender.Send(envelope);

            return(await watcher);
        }
Example #12
0
        public async Task <TResponse> Request <TResponse>(object request, RequestOptions options = null)
        {
            options = options ?? new RequestOptions();

            var envelope = EnvelopeForRequestResponse <TResponse>(request);

            if (options.Destination != null)
            {
                envelope.Destination = options.Destination;
            }


            var watcher = _watcher.StartWatch <TResponse>(envelope.CorrelationId, options.Timeout);

            await _sender.Send(envelope);

            return(await watcher);
        }