Пример #1
0
        void TransmittDataBusProperties(string remoteUrl, NameValueCollection headers)
        {
            var headersToSend = new NameValueCollection {
                headers
            };


            foreach (string headerKey in headers.Keys)
            {
                if (headerKey.Contains(DATABUS_PREFIX))
                {
                    if (DataBus == null)
                    {
                        throw new InvalidOperationException("Can't send a message with a databus property without a databus configured");
                    }

                    headersToSend[GatewayHeaders.DatabusKey] = headerKey;

                    using (var stream = DataBus.Get(headers[headerKey]))
                    {
                        var buffer = new byte[stream.Length];
                        stream.Read(buffer, 0, (int)stream.Length);

                        MakeHttpRequest(remoteUrl, CallType.DatabusProperty, headersToSend, buffer);
                    }
                }
            }
        }
Пример #2
0
        public void Invoke(ReceiveLogicalMessageContext context, Action next)
        {
            var message = context.LogicalMessage.Instance;


            foreach (var property in GetDataBusProperties(message))
            {
                var propertyValue = property.GetValue(message, null);

                var    dataBusProperty = propertyValue as IDataBusProperty;
                string headerKey;

                if (dataBusProperty != null)
                {
                    headerKey = dataBusProperty.Key;
                }
                else
                {
                    headerKey = String.Format("{0}.{1}", message.GetType().FullName, property.Name);
                }

                string dataBusKey;

                if (!context.LogicalMessage.Headers.TryGetValue(HeaderMapper.DATABUS_PREFIX + headerKey, out dataBusKey))
                {
                    continue;
                }

                using (new TransactionScope(TransactionScopeOption.Suppress))
                    using (var stream = DataBus.Get(dataBusKey))
                    {
                        var value = DataBusSerializer.Deserialize(stream);

                        if (dataBusProperty != null)
                        {
                            dataBusProperty.SetValue(value);
                        }
                        else
                        {
                            property.SetValue(message, value, null);
                        }
                    }
            }

            next();
        }
Пример #3
0
        private void TransmittDataBusProperties(IChannelSender channelSender, Site targetSite,
                                                IDictionary<string, string> headers)
        {
            var headersToSend = new Dictionary<string, string>(headers);

            foreach (string headerKey in headers.Keys.Where(headerKey => headerKey.StartsWith(DATABUS_PREFIX)))
            {
                if (DataBus == null)
                    throw new InvalidOperationException(
                        "Can't send a message with a databus property without a databus configured");

                headersToSend[GatewayHeaders.DatabusKey] = headerKey;

                using (var stream = DataBus.Get(headers[headerKey]))
                    Transmit(channelSender, targetSite, CallType.DatabusProperty, headersToSend, stream);
            }
        }