Esempio n. 1
0
        public ICallback Send(params object[] messages)
        {
            var destinations = GetAddressForMessages(messages)
                               .Distinct()
                               .ToList();

            if (destinations.Count > 1)
            {
                throw new InvalidOperationException("Sends can only target one address.");
            }

            if (destinations.Count == 0)
            {
                var messageType = "none";

                if (messages != null && messages.Length >= 1)
                {
                    messageType = messages[0].GetType().ToString();
                }
                var error = string.Format("No destination could be found for message type {0}. Check the <MessageEndpointMappings> section of the configuration of this endpoint for an entry either for this specific message type or for its assembly.", messageType);
                throw new InvalidOperationException(error);
            }

            var destination = destinations[0];

            return(SendMessages(new SendOptions(destination), LogicalMessageFactory.CreateMultiple(messages)));
        }
Esempio n. 2
0
        public void Reply(params object[] messages)
        {
            var options = SendOptions.ReplyTo(MessageBeingProcessed.ReplyToAddress);

            options.CorrelationId = !string.IsNullOrEmpty(MessageBeingProcessed.CorrelationId) ? MessageBeingProcessed.CorrelationId : MessageBeingProcessed.Id;

            SendMessages(options, LogicalMessageFactory.CreateMultiple(messages));
        }
Esempio n. 3
0
        public ICallback Send(Address address, string correlationId, params object[] messages)
        {
            var options = new SendOptions(address)
            {
                CorrelationId = correlationId
            };

            return(SendMessages(options, LogicalMessageFactory.CreateMultiple(messages)));
        }
Esempio n. 4
0
 public ICallback SendLocal(params object[] messages)
 {
     //if we're a worker, send to the distributor data bus
     if (Configure.Instance.WorkerRunsOnThisEndpoint())
     {
         return(SendMessages(new SendOptions(MasterNodeAddress), LogicalMessageFactory.CreateMultiple(messages)));
     }
     return(SendMessages(new SendOptions(Address.Local), LogicalMessageFactory.CreateMultiple(messages)));
 }
Esempio n. 5
0
        public ICallback Send(string destination, string correlationId, object message)
        {
            var options = new SendOptions(destination)
            {
                CorrelationId = correlationId
            };

            return(SendMessages(options, LogicalMessageFactory.CreateMultiple(message)));
        }
Esempio n. 6
0
        public ICallback Send <T>(Address address, string correlationId, Action <T> messageConstructor)
        {
            var options = new SendOptions(address)
            {
                CorrelationId = correlationId
            };

            return(SendMessages(options, LogicalMessageFactory.CreateMultiple(CreateInstance(messageConstructor))));
        }
Esempio n. 7
0
        public ICallback Defer(DateTime processAt, params object[] messages)
        {
            var options = new SendOptions(Address.Local)
            {
                DeliverAt = processAt,
                EnforceMessagingBestPractices = false
            };

            return(SendMessages(options, LogicalMessageFactory.CreateMultiple(messages)));
        }
Esempio n. 8
0
        public ICallback Defer(TimeSpan delay, params object[] messages)
        {
            var options = new SendOptions(Address.Local)
            {
                DelayDeliveryWith             = delay,
                EnforceMessagingBestPractices = false
            };

            return(SendMessages(options, LogicalMessageFactory.CreateMultiple(messages)));
        }
Esempio n. 9
0
        public ICallback Send(params object[] messages)
        {
            var destinations = GetAddressForMessages(messages)
                               .Distinct()
                               .ToList();

            if (destinations.Count > 1)
            {
                throw new InvalidOperationException("Sends can only target one address.");
            }

            var destination = destinations.SingleOrDefault();

            return(SendMessages(new SendOptions(destination), LogicalMessageFactory.CreateMultiple(messages)));
        }
Esempio n. 10
0
        public ICallback Defer(DateTime processAt, params object[] messages)
        {
            SendOptions options;

            if (Configure.Instance.WorkerRunsOnThisEndpoint())
            {
                options = new SendOptions(MasterNodeAddress);
            }
            else
            {
                options = new SendOptions(Address.Local);
            }

            options.DeliverAt = processAt;
            options.EnforceMessagingBestPractices = false;

            return(SendMessages(options, LogicalMessageFactory.CreateMultiple(messages)));
        }
Esempio n. 11
0
        /// <summary>
        /// Publishes the messages to all subscribers of the first message's type.
        /// </summary>
        public virtual void Publish <T>(params T[] messages)
        {
            if (messages == null || messages.Length == 0)
            {
                return;
            }

            var messagesToPublish = messages.Cast <object>().ToList();

            var sendOptions = new SendOptions
            {
                Intent = MessageIntentEnum.Publish
            };

            var context = InvokeSendPipeline(sendOptions, LogicalMessageFactory.CreateMultiple(messagesToPublish));

            if (!context.Get <bool>("SubscribersFound") && NoSubscribersForMessage != null)
            {
                NoSubscribersForMessage(this, new MessageEventArgs(messagesToPublish.First()));
            }
        }
Esempio n. 12
0
        public ICallback SendToSites(IEnumerable <string> siteKeys, params object[] messages)
        {
            Headers.SetMessageHeader(messages[0], Headers.DestinationSites, string.Join(",", siteKeys.ToArray()));

            return(SendMessages(new SendOptions(MasterNodeAddress.SubScope("gateway")), LogicalMessageFactory.CreateMultiple(messages)));
        }
Esempio n. 13
0
 public ICallback Send(Address address, params object[] messages)
 {
     return(SendMessages(new SendOptions(address), LogicalMessageFactory.CreateMultiple(messages)));
 }
Esempio n. 14
0
 public ICallback Send(string destination, params object[] messages)
 {
     return(SendMessages(new SendOptions(destination), LogicalMessageFactory.CreateMultiple(messages)));
 }
Esempio n. 15
0
 public ICallback Send <T>(Address address, Action <T> messageConstructor)
 {
     return(SendMessages(new SendOptions(address), LogicalMessageFactory.CreateMultiple(CreateInstance(messageConstructor))));
 }
Esempio n. 16
0
 public ICallback Send <T>(string destination, Action <T> messageConstructor)
 {
     return(SendMessages(new SendOptions(destination), LogicalMessageFactory.CreateMultiple(CreateInstance(messageConstructor))));
 }