/// <summary> /// Unsubscribes the specified subscriber. /// </summary> /// <typeparam name="T">The type of message being unsubscribed from</typeparam> /// <param name="subscriber">The subscriber.</param> public void Unsubscribe <T>(IHandleMessage <T> subscriber) { IList <WeakReference> subscribers; lock (_subscriptions) { if (!_subscriptions.TryGetValue(typeof(T), out subscribers)) { return; } lock (subscribers) { for (int i = 0; i < subscribers.Count; i++) { if (object.ReferenceEquals(subscribers[i].Target, subscriber)) { subscribers.RemoveAt(i); break; } } if (subscribers.Count == 0) { _subscriptions.Remove(typeof(T)); } } } }
public RemoveFromReadQueueAspect(IHandleMessage <Message> action, IReadMessageContext context, IBusConfig config, ILogMessages logger) { _context = context; _config = config; _logger = logger; _inner = action; }
public QueuedHandler(IHandleMessage <Message> handler, string name, int maxCount = 0) { _handler = handler; _name = name; _maxCount = maxCount; _messageQueue = new ConcurrentQueue <Message>(); _stopped = new AutoResetEvent(false); }
/// <summary> /// Subscribes the specified subscriber. /// </summary> /// <typeparam name="T">The type of message being subscribed to</typeparam> /// <param name="subscriber">The subscriber.</param> public void Subscribe <T>(IHandleMessage <T> subscriber) { IList <object> subscribers; if (!_subscriptions.TryGetValue(typeof(T), out subscribers)) { subscribers = new List <object>(); _subscriptions.Add(typeof(T), subscribers); } subscribers.Add(subscriber); }
/// <summary> /// Initializes a new instance of the <see cref="ProcessMessageAsync"/> class. /// </summary> /// <param name="handler">The handler.</param> /// <param name="heartBeatWorkerFactory">The heart beat worker factory.</param> /// <param name="messageExceptionHandler">The message exception handler.</param> /// <param name="commitMessage">The commit message.</param> public ProcessMessageAsync(IHandleMessage handler, IHeartBeatWorkerFactory heartBeatWorkerFactory, MessageExceptionHandler messageExceptionHandler, ICommitMessage commitMessage) { Guard.NotNull(() => handler, handler); Guard.NotNull(() => heartBeatWorkerFactory, heartBeatWorkerFactory); Guard.NotNull(() => messageExceptionHandler, messageExceptionHandler); Guard.NotNull(() => commitMessage, commitMessage); _messageExceptionHandler = messageExceptionHandler; _methodToRun = handler; _heartBeatWorkerFactory = heartBeatWorkerFactory; _commitMessage = commitMessage; }
/// <summary> /// Initializes a new instance of the <see cref="ProcessMessage"/> class. /// </summary> /// <param name="handler">The handler.</param> /// <param name="heartBeatWorkerFactory">The heart beat worker factory.</param> /// <param name="messageExceptionHandler">The message exception handler.</param> /// <param name="commitMessage">The commit message.</param> public ProcessMessage(IHandleMessage handler, IHeartBeatWorkerFactory heartBeatWorkerFactory, MessageExceptionHandler messageExceptionHandler, ICommitMessage commitMessage) { Guard.NotNull(() => handler, handler); Guard.NotNull(() => heartBeatWorkerFactory, heartBeatWorkerFactory); Guard.NotNull(() => messageExceptionHandler, messageExceptionHandler); Guard.NotNull(() => commitMessage, commitMessage); _messageExceptionHandler = messageExceptionHandler; _methodToRun = handler; _heartBeatWorkerFactory = heartBeatWorkerFactory; _commitMessage = commitMessage; }
private void Subscribe <T>(string topic, IHandleMessage <T> handler) where T : Message { var narrowingHandler = new MessageHandler <T>(handler); _topicHandlers.AddOrUpdate( topic, x => new List <IWrapHandler>() { narrowingHandler }, (s, list) => new List <IWrapHandler>(list) { narrowingHandler }); }
/// <summary> /// Unsubscribes the specified subscriber. /// </summary> /// <typeparam name="T">The type of message being unsubscribed from</typeparam> /// <param name="subscriber">The subscriber.</param> public void Unsubscribe <T>(IHandleMessage <T> subscriber) { IList <object> subscribers; if (!_subscriptions.TryGetValue(typeof(T), out subscribers)) { return; } subscribers.Remove(subscriber); if (subscribers.Count == 0) { _subscriptions.Remove(typeof(T)); } }
/// <summary> /// Unsubscribes a given IHandleMessage implementation to the channels it returns. /// </summary> /// <param name="implementation">An instance of IHandleMessage.</param> /// <exception cref="ArgumentNullException">Throws ArgumentNullException if implementation is null</exception> public void Unsubscribe(IHandleMessage implementation) { if (implementation == null) { throw new ArgumentNullException(); } var tobeRemoved = (IncomingLeadHandler)implementation; // if tobeRemoved is already on the subscribed list, remove it from the list var existing = SubscribedList.Subscriptions.FirstOrDefault(x => x.Subscriber == tobeRemoved.Subscriber); if (existing != null) { SubscribedList.Subscriptions.Remove(existing); } }
/// <summary> /// Subscribes a given IHandleMessage implementation to the channels it returns. /// </summary> /// <param name="implementation">An instance of IHandleMessage.</param> /// <exception cref="ArgumentNullException">Throws ArgumentNullException if implementation is null</exception> public void Subscribe(IHandleMessage implementation) { if (implementation == null) { throw new ArgumentNullException(); } var incoming = (IncomingLeadHandler)implementation; // if incoming is not on the subscribed list, add it to the list. var previouslySubscribed = SubscribedList.Subscriptions.Where(x => x.Subscriber == incoming.Subscriber).ToList().Count; if (previouslySubscribed == 0) { SubscribedList.Subscriptions.Add(incoming); } }
/// <summary> /// Subscribes the specified subscriber. /// </summary> /// <typeparam name="T">The type of message being subscribed to</typeparam> /// <param name="subscriber">The subscriber.</param> public void Subscribe <T>(IHandleMessage <T> subscriber) { IList <WeakReference> subscribers; lock (_subscriptions) { if (!_subscriptions.TryGetValue(typeof(T), out subscribers)) { subscribers = new List <WeakReference>(); _subscriptions.Add(typeof(T), subscribers); } lock (subscribers) { subscribers.Add(new WeakReference(subscriber)); } } }
public UserController(IServiceAppUser serviceAppUser, UserManager <User> userManager, RoleManager <Role> roleManager, SignInManager <User> signInManager, IMapper mapper, IConfiguration config, IServiceAppCompany serviceAppCompany, IServiceAppCompanySubjectIssue serviceAppCompanySubjectIssue, IHandleMessage <UserSummary> handleMessageUserSummary, IServiceAppCompanyRate serviceAppCompanyRate, IHandleMessage <UserDetailsDTO> handleMessageUser) { _serviceAppUser = serviceAppUser; _userManager = userManager; _roleManager = roleManager; _signInManager = signInManager; _mapper = mapper; _config = config; _serviceAppCompanySubjectIssue = serviceAppCompanySubjectIssue; _handleMessageUserSummary = handleMessageUserSummary; _handleMessageUser = handleMessageUser; _serviceAppCompany = serviceAppCompany; _serviceAppCompanyRate = serviceAppCompanyRate; }
public CompanyController(IHandleMessage <List <CompanyDTO> > handleMessageUser, IHandleMessage <CompanySubjectTellUsDTO> handleMessageCompanySubjectTellUs, IHandleMessage <List <SubjectDTO> > handleMessageSubject, IHandleMessage <List <SubjectIssueDTO> > handleMessageSubjectIssue, IServiceAppCompany serviceAppCompany, IServiceAppCompanyRate serviceAppCompanyRate, IServiceAppSubject serviceAppSubject, IServiceAppSubjectIssue serviceAppSubjectIssue, IServiceAppCompanySubjectIssue serviceAppCompanySubjectIssue, IMapper mapper) { _handleMessageUser = handleMessageUser; _handleMessageCompanySubjectTellUs = handleMessageCompanySubjectTellUs; _handleMessageSubject = handleMessageSubject; _handleMessageSubjectIssue = handleMessageSubjectIssue; _serviceAppCompany = serviceAppCompany; _serviceAppCompanyRate = serviceAppCompanyRate; _serviceAppSubject = serviceAppSubject; _serviceAppSubjectIssue = serviceAppSubjectIssue; _serviceAppCompanySubjectIssue = serviceAppCompanySubjectIssue; _mapper = mapper; }
public TimeToLiveHandler(IHandleMessage <Message> handler) { _handler = handler; }
public static IHandleMessageAsync <TMessage> AsAsync <TMessage>(this IHandleMessage <TMessage> handler) { return(new SyncAsAsyncHandlerDecorator <TMessage>(handler)); }
public MessageHandler(IHandleMessage <T> handle) : base(handle) { _handle = handle; }
public SyncAsAsyncHandlerDecorator(IHandleMessage <TMessage> handler) { this.handler = handler; }
public void Subscribe <T>(IHandleMessage <T> handler) where T : Message { Subscribe(typeof(T).Name, handler); }
public MoveToErrorQueueAspect(IHandleMessage <Message> action, IReadMessageContext context, ILogMessages logger) { _context = context; _logger = logger; _inner = action; }
/// <summary> /// Overrides the default comparison logic to properly define the equality for IHandleMessage type. /// </summary> /// <param name="obj"></param> /// <returns>Returns true if the current object is equal to the other parameter; otherwise, false.</returns> public override bool Equals(object obj) { IHandleMessage handle = obj as IHandleMessage; return(handle != null && handle.Subscriber == Subscriber); }
public AlertMonitor(IHandleMessage <Message> handler, IThreshold threshold, IAppBus bus) { _bus = bus; _threshold = threshold; _handler = handler; }
public LoggingAspect(IHandleMessage <Message> action, string operation, ILogMessages logger) { _inner = action; _logger = logger; _operation = operation; }
public FailFastAspect(IHandleMessage <Message> action, IBusConfig config, ILogMessages logger) { _inner = action; _config = config; _logger = logger; }
public void RegisterHandler <T>(IHandleMessage <T> handler) where T : IMessage { m_callbackDict.Add(typeof(T), (message) => handler.Handle((T)message)); }
public RegisterMessageHandler(IHandleMessage handler, IProvideServiceBusConnection bus) { this.handler = handler; this.bus = bus; }
public RegisterHandler(IHandleMessage <T> handler, IProvideServiceBusConnection <T> bus) { bus.QueueClient.RegisterMessageHandler(handler.HandleAsync, handler.HandleOption); }
public NarrowingHandler(IHandleMessage <TDerived> handle) { _handle = handle; }
/// <summary> /// Takes user-defined message handlers implementing the IHandleMessage /// of T interface and stores them to be invoked later when the Receive /// method is called. /// </summary> public void RegisterHandler <T>(IHandleMessage <T> handler) { _handlers.Add(new Action <T>(handler.Handle)); }
public WideningHandler(IHandleMessage <TBase> handler) { _handler = handler; }
public void Subscribe(IHandleMessage handler) { MessageReceived += handler.Handle; }
private static UserRule ToUserRule(this IHandleMessage handleMessage) { return(JsonConvert.DeserializeObject <UserRule>(handleMessage.Message)); }