@@ -66,20 +66,8 @@ internal static List<SubscriptionWorker> ConfigureSubscriptions(ISubscriptionRep
6666 KeyValuePair < String , IDomainEventHandlerResolver > ehr = eventHandlerResolvers . SingleOrDefault ( e => e . Key == "Ordered" ) ;
6767
6868 if ( ehr . Value != null ) {
69- SubscriptionWorker worker = SubscriptionWorker . CreateOrderedSubscriptionWorker ( eventStoreConnectionString ,
70- ehr . Value ,
71- subscriptionRepository ,
72- configuration . PersistentSubscriptionPollingInSeconds ) ;
73- worker . Trace += ( _ ,
74- args ) => traceHandler ( TraceEventType . Information , "ORDERED" , args . Message ) ;
75- worker . Warning += ( _ ,
76- args ) => traceHandler ( TraceEventType . Warning , "ORDERED" , args . Message ) ;
77- worker . Error += ( _ ,
78- args ) => traceHandler ( TraceEventType . Error , "ORDERED" , args . Message ) ;
79- worker . SetIgnoreGroups ( configurationSubscriptionWorker . IgnoreGroups ) ;
80- worker . SetIgnoreStreams ( configurationSubscriptionWorker . IgnoreStreams ) ;
81- worker . SetIncludeGroups ( configurationSubscriptionWorker . IncludeGroups ) ;
82- worker . SetIncludeStreams ( configurationSubscriptionWorker . IncludeStreams ) ;
69+ SubscriptionWorker worker = ConfigureSubscriptionWorker ( subscriptionRepository , configuration ,
70+ eventStoreConnectionString , traceHandler , ehr , configurationSubscriptionWorker , "ORDERED" ) ;
8371 workers . Add ( worker ) ;
8472 }
8573 }
@@ -88,20 +76,9 @@ internal static List<SubscriptionWorker> ConfigureSubscriptions(ISubscriptionRep
8876
8977 if ( ehr . Value != null )
9078 {
91- for ( Int32 i = 0 ; i < configurationSubscriptionWorker . InstanceCount ; i ++ )
92- {
93- SubscriptionWorker worker = SubscriptionWorker . CreateSubscriptionWorker ( eventStoreConnectionString , ehr . Value , subscriptionRepository , configurationSubscriptionWorker . InflightMessages , configuration . PersistentSubscriptionPollingInSeconds ) ;
94-
95- worker . Trace += ( _ ,
96- args ) => traceHandler ( TraceEventType . Information , "DOMAIN" , args . Message ) ;
97- worker . Warning += ( _ ,
98- args ) => traceHandler ( TraceEventType . Warning , "DOMAIN" , args . Message ) ;
99- worker . Error += ( _ ,
100- args ) => traceHandler ( TraceEventType . Error , "DOMAIN" , args . Message ) ;
101- worker . SetIgnoreGroups ( configurationSubscriptionWorker . IgnoreGroups ) ;
102- worker . SetIgnoreStreams ( configurationSubscriptionWorker . IgnoreStreams ) ;
103- worker . SetIncludeGroups ( configurationSubscriptionWorker . IncludeGroups ) ;
104- worker . SetIncludeStreams ( configurationSubscriptionWorker . IncludeStreams ) ;
79+ for ( Int32 i = 0 ; i < configurationSubscriptionWorker . InstanceCount ; i ++ ) {
80+ SubscriptionWorker worker = ConfigureSubscriptionWorker ( subscriptionRepository , configuration ,
81+ eventStoreConnectionString , traceHandler , ehr , configurationSubscriptionWorker , "DOMAIN" ) ;
10582
10683 workers . Add ( worker ) ;
10784 }
@@ -113,22 +90,8 @@ internal static List<SubscriptionWorker> ConfigureSubscriptions(ISubscriptionRep
11390 {
11491 for ( Int32 i = 0 ; i < configurationSubscriptionWorker . InstanceCount ; i ++ )
11592 {
116- SubscriptionWorker worker = SubscriptionWorker . CreateSubscriptionWorker ( eventStoreConnectionString ,
117- ehr . Value ,
118- subscriptionRepository ,
119- configurationSubscriptionWorker . InflightMessages ,
120- configuration . PersistentSubscriptionPollingInSeconds ) ;
121-
122- worker . Trace += ( _ ,
123- args ) => traceHandler ( TraceEventType . Information , "MAIN" , args . Message ) ;
124- worker . Warning += ( _ ,
125- args ) => traceHandler ( TraceEventType . Warning , "MAIN" , args . Message ) ;
126- worker . Error += ( _ ,
127- args ) => traceHandler ( TraceEventType . Error , "MAIN" , args . Message ) ;
128- worker . SetIgnoreGroups ( configurationSubscriptionWorker . IgnoreGroups ) ;
129- worker . SetIgnoreStreams ( configurationSubscriptionWorker . IgnoreStreams ) ;
130- worker . SetIncludeGroups ( configurationSubscriptionWorker . IncludeGroups ) ;
131- worker . SetIncludeStreams ( configurationSubscriptionWorker . IncludeStreams ) ;
93+ SubscriptionWorker worker = ConfigureSubscriptionWorker ( subscriptionRepository , configuration ,
94+ eventStoreConnectionString , traceHandler , ehr , configurationSubscriptionWorker , "MAIN" ) ;
13295
13396 workers . Add ( worker ) ;
13497 }
@@ -138,5 +101,28 @@ internal static List<SubscriptionWorker> ConfigureSubscriptions(ISubscriptionRep
138101
139102 return workers ;
140103 }
104+
105+ private static SubscriptionWorker ConfigureSubscriptionWorker ( ISubscriptionRepository subscriptionRepository ,
106+ SubscriptionWorkersRoot configuration ,
107+ String eventStoreConnectionString ,
108+ Action < TraceEventType , String , String > traceHandler ,
109+ KeyValuePair < String , IDomainEventHandlerResolver > ehr ,
110+ SubscriptionWorkerConfig configurationSubscriptionWorker ,
111+ String type ) {
112+ SubscriptionWorker worker = SubscriptionWorker . CreateSubscriptionWorker ( eventStoreConnectionString , ehr . Value , subscriptionRepository , configurationSubscriptionWorker . InflightMessages , configuration . PersistentSubscriptionPollingInSeconds ) ;
113+
114+ worker . Trace += ( _ ,
115+ args ) => traceHandler ( TraceEventType . Information , type , args . Message ) ;
116+ worker . Warning += ( _ ,
117+ args ) => traceHandler ( TraceEventType . Warning , type , args . Message ) ;
118+ worker . Error += ( _ ,
119+ args ) => traceHandler ( TraceEventType . Error , type , args . Message ) ;
120+ worker . SetIgnoreGroups ( configurationSubscriptionWorker . IgnoreGroups ) ;
121+ worker . SetIgnoreStreams ( configurationSubscriptionWorker . IgnoreStreams ) ;
122+ worker . SetIncludeGroups ( configurationSubscriptionWorker . IncludeGroups ) ;
123+ worker . SetIncludeStreams ( configurationSubscriptionWorker . IncludeStreams ) ;
124+ return worker ;
125+ }
126+
141127 #endregion
142128}
0 commit comments