예제 #1
0
        //This is a shortcut method that should wrap a transformer
        public static Subject <TOutput> OutputToReactive <TOutput>(this IMessageQueueSource queueSource, ISerializer <TOutput> serializer)
        {
            var rx = new Subject <TOutput>();

            queueSource.StartMessagePump(message =>
            {
                var stream = message.GetBody <Stream>();
                var objs   = serializer.Deserialize(stream);
                foreach (var obj in objs)
                {
                    rx.OnNext(obj);
                }
            });

            return(rx);
        }
예제 #2
0
 public static void OutputToRaw <TOutput>(this IMessageQueueSource queueSource, ISerializer <TOutput> serializer, Action <IEnumerable <TOutput> > action)
 {
     queueSource.StartMessagePump(message =>
     {
         try
         {
             var stream = message.GetBody <Stream>();
             var objs   = serializer.Deserialize(stream);
             action(objs);
             message.Complete();
         }
         catch (Exception ex)
         {
             Log.Error("Exception processing message", ex);
             message.Abandon();
         }
     });
 }
예제 #3
0
        public static ProcessorWrapper ProcessWith(this IMessageQueueSource queueSource, IQueueProcessor queueProcessor)
        {
            var messageQueueProcessor = new ProcessorWrapper(queueSource, queueProcessor);

            return(messageQueueProcessor);
        }
예제 #4
0
        public static ProcessorWrapper ProcessWith <TProcessorType>(this IMessageQueueSource queueSource) where TProcessorType : IQueueProcessor
        {
            var queueProcessor = (IQueueProcessor)ServiceLocator.Current.GetInstance(typeof(TProcessorType));

            return(queueSource.ProcessWith(queueProcessor));
        }
예제 #5
0
 public static IMessageQueueSource WithMaxConcurrency(this IMessageQueueSource queueSource, int threads)
 {
     queueSource.MaxConcurrency = threads;
     return(queueSource);
 }
 public ProcessorWrapper(IMessageQueueSource queueSource, IQueueProcessor queueProcessor)
 {
     QueueSource    = queueSource;
     QueueProcessor = queueProcessor;
 }