예제 #1
0
        public MessageSubscribtionInfo(DataContractKey contractKey, ICallHandler handler, XmlObjectSerializer serializer, bool receiveSelfPublish, IEnumerable<BusHeader> filterHeaders)
        {
            _handler = handler;
            _serializer = serializer;

            _filterInfo = new MessageFilterInfo(contractKey, receiveSelfPublish, filterHeaders);
        }
예제 #2
0
 public bool Register(Type type, MessageFilterInfo filterInfo, ICallHandler handler)
 {
     return _subscriptions.TryAdd(type, new SubscriptionInfo
     {
         FilterInfo = filterInfo,
         Handler = handler
     });
 }
예제 #3
0
        private bool IsMessageSurvivesFilter(MessageFilterInfo filterInfo, RawBusMessage busMessage)
        {
            // TODO: Add header filtering

            if (filterInfo.ReceiveSelfPublish) return true;

            bool selfPublished = Equals(busMessage.BusId, _busId);

            return !selfPublished;
        }
예제 #4
0
        public static void QueueBind(this IModel model, string queue, string exchange, string routingKey, MessageFilterInfo filterInfo)
        {
            IDictionary<string, object> arguments = new Dictionary<string, object>();

            arguments.Add(MessagingConstants.HeaderNames.Name, filterInfo.ContractKey.Name);
            arguments.Add(MessagingConstants.HeaderNames.NameSpace, filterInfo.ContractKey.Ns);

            foreach (BusHeader header in filterInfo.FilterHeaders)
            {
                arguments.Add(header.Name, header.Value);
            }

            model.QueueBind(queue, exchange, routingKey, arguments);
        }
예제 #5
0
        public bool Subscribe(Type dataType, ICallHandler handler, IEnumerable<BusHeader> filter)
        {
            DataContractKey key = dataType.GetDataContractKey();

            MessageFilterInfo filterInfo = new MessageFilterInfo(key, filter ?? Enumerable.Empty<BusHeader>());

            return _registrationAction(dataType, filterInfo, handler);
        }