internal RabbitMQTaskQueueListenerAdapterInstance(Func<IListenerAdapter> listenerAdapterFactory, Func<IRabbitMQQueueMonitor> queueMionitorFactory) { using (var proc = Process.GetCurrentProcess()) { if (proc.SessionId > 0) { _messagePublicationNotificationServiceUri = new Uri($"net.tcp://localhost:41781/RabbitMQTaskQueueListenerAdapter_{Guid.NewGuid():N}"); } } _queueMon = queueMionitorFactory(); _queueMon.MessagePublished += QueueMonitor_MessagePublished; _msgPubNotificationSvc = new MessagePublicationNotificationService(_queueMon); _msgPubNotificationSvcHost = new ServiceHost(_msgPubNotificationSvc, _messagePublicationNotificationServiceUri); _msgPubNotificationSvcHost.AddServiceEndpoint(typeof(IWasInteropService), BindingFactory.Create(_messagePublicationNotificationServiceUri), string.Empty); _msgPubNotificationSvcHost.Open(); TraceInformation($"Created callback queue on {_messagePublicationNotificationServiceUri}.", GetType()); _listenerAdapter = listenerAdapterFactory(); _listenerAdapter.ApplicationCreated += ListenerAdapter_ApplicationCreated; _listenerAdapter.ApplicationDeleted += ListenerAdapter_ApplicationDeleted; _listenerAdapter.ApplicationRequestBlockedStateChanged += ListenerAdapter_ApplicationRequestBlockedStateChanged; _listenerAdapter.ApplicationPoolCanOpenNewListenerChannelInstance += ListenerAdapter_ApplicationPoolCanOpenNewListenerChannelInstance; _listenerAdapter.ApplicationPoolListenerChannelInstancesStopped += ListenerAdapter_ApplicationPoolListenerChannelInstancesStopped; _listenerAdapter.ApplicationPoolStateChanged += ListenerAdapter_ApplicationPoolStateChanged; _listenerAdapter.ApplicationAppPoolChanged += ListenerAdapter_ApplicationAppPoolChanged; _listenerAdapter.ApplicationPoolCreated += ListenerAdapter_ApplicationPoolCreated; _listenerAdapter.ApplicationPoolDeleted += ListenerAdapter_ApplicationPoolDeleted; }
internal MessagePublicationNotificationService(IRabbitMQQueueMonitor queueMonitor, Func<IWasInteropServiceCallback> getCallbackFunc) { _getCallbackFunc = getCallbackFunc; _queueMon = queueMonitor; _queueMon.MessagePublished += QueueMonitor_MessagePublished; var keepAliveInterval = TimeSpan.FromMinutes(1); _keepAliveTimer = new Timer(state => FireKeepAlive(), null, TimeSpan.Zero, keepAliveInterval); }
public MessagePublicationNotificationService(IRabbitMQQueueMonitor queueMonitor) : this(queueMonitor, () => OperationContext.Current.GetCallbackChannel<IWasInteropServiceCallback>()) { }