@@ -22,7 +22,7 @@ public class DefaultEventQueue : IEventQueue {
22
22
private DateTime ? _suspendProcessingUntil ;
23
23
private DateTime ? _discardQueuedItemsUntil ;
24
24
25
- public DefaultEventQueue ( ExceptionlessConfiguration config , IExceptionlessLog log , ISubmissionClient client , IObjectStorage objectStorage , IJsonSerializer serializer ) : this ( config , log , client , objectStorage , serializer , null , null ) { }
25
+ public DefaultEventQueue ( ExceptionlessConfiguration config , IExceptionlessLog log , ISubmissionClient client , IObjectStorage objectStorage , IJsonSerializer serializer ) : this ( config , log , client , objectStorage , serializer , null , null ) { }
26
26
27
27
public DefaultEventQueue ( ExceptionlessConfiguration config , IExceptionlessLog log , ISubmissionClient client , IObjectStorage objectStorage , IJsonSerializer serializer , TimeSpan ? processQueueInterval , TimeSpan ? queueStartDelay ) {
28
28
_log = log ;
@@ -86,52 +86,43 @@ public Task Process() {
86
86
var response = _client . PostEvents ( events , _config , _serializer ) ;
87
87
if ( response . Success ) {
88
88
_log . FormattedInfo ( typeof ( DefaultEventQueue ) , "Sent {0} events to \" {1}\" ." , batch . Count , _config . ServerUrl ) ;
89
- }
90
- else if ( response . ServiceUnavailable ) {
89
+ } else if ( response . ServiceUnavailable ) {
91
90
// You are currently over your rate limit or the servers are under stress.
92
91
_log . Error ( typeof ( DefaultEventQueue ) , "Server returned service unavailable." ) ;
93
92
SuspendProcessing ( ) ;
94
93
deleteBatch = false ;
95
- }
96
- else if ( response . PaymentRequired ) {
94
+ } else if ( response . PaymentRequired ) {
97
95
// If the organization over the rate limit then discard the event.
98
96
_log . Warn ( typeof ( DefaultEventQueue ) , "Too many events have been submitted, please upgrade your plan." ) ;
99
97
SuspendProcessing ( discardFutureQueuedItems : true , clearQueue : true ) ;
100
- }
101
- else if ( response . UnableToAuthenticate ) {
98
+ } else if ( response . UnableToAuthenticate ) {
102
99
// The api key was suspended or could not be authorized.
103
100
_log . Error ( typeof ( DefaultEventQueue ) , "Unable to authenticate, please check your configuration. The event will not be submitted." ) ;
104
101
SuspendProcessing ( TimeSpan . FromMinutes ( 15 ) ) ;
105
- }
106
- else if ( response . NotFound || response . BadRequest ) {
102
+ } else if ( response . NotFound || response . BadRequest ) {
107
103
// The service end point could not be found.
108
104
_log . FormattedError ( typeof ( DefaultEventQueue ) , "Error while trying to submit data: {0}" , response . Message ) ;
109
105
SuspendProcessing ( TimeSpan . FromHours ( 4 ) ) ;
110
- }
111
- else if ( response . RequestEntityTooLarge ) {
106
+ } else if ( response . RequestEntityTooLarge ) {
112
107
if ( batchSize > 1 ) {
113
108
_log . Error ( typeof ( DefaultEventQueue ) , "Event submission discarded for being too large. The event will be retried with a smaller batch size." ) ;
114
109
batchSize = Math . Max ( 1 , ( int ) Math . Round ( batchSize / 1.5d , 0 ) ) ;
115
110
deleteBatch = false ;
116
- }
117
- else {
111
+ } else {
118
112
_log . Error ( typeof ( DefaultEventQueue ) , "Event submission discarded for being too large. The event will not be submitted." ) ;
119
113
}
120
- }
121
- else if ( ! response . Success ) {
114
+ } else if ( ! response . Success ) {
122
115
_log . Error ( typeof ( DefaultEventQueue ) , String . Concat ( "An error occurred while submitting events: " , response . Message ) ) ;
123
116
SuspendProcessing ( ) ;
124
117
deleteBatch = false ;
125
118
}
126
119
127
120
OnEventsPosted ( new EventsPostedEventArgs { Events = events , Response = response } ) ;
128
- }
129
- catch ( AggregateException ex ) {
121
+ } catch ( AggregateException ex ) {
130
122
_log . Error ( typeof ( DefaultEventQueue ) , ex , String . Concat ( "An error occurred while submitting events: " , ex . Flatten ( ) . Message ) ) ;
131
123
SuspendProcessing ( ) ;
132
124
deleteBatch = false ;
133
- }
134
- catch ( Exception ex ) {
125
+ } catch ( Exception ex ) {
135
126
_log . Error ( typeof ( DefaultEventQueue ) , ex , String . Concat ( "An error occurred while submitting events: " , ex . Message ) ) ;
136
127
SuspendProcessing ( ) ;
137
128
deleteBatch = false ;
@@ -147,12 +138,10 @@ public Task Process() {
147
138
148
139
batch = _storage . GetEventBatch ( _config . GetQueueName ( ) , _serializer , batchSize , maxCreatedDate ) ;
149
140
}
150
- }
151
- catch ( Exception ex ) {
141
+ } catch ( Exception ex ) {
152
142
_log . Error ( typeof ( DefaultEventQueue ) , ex , String . Concat ( "An error occurred while processing the queue: " , ex . Message ) ) ;
153
143
SuspendProcessing ( ) ;
154
- }
155
- finally {
144
+ } finally {
156
145
tcs . SetResult ( true ) ;
157
146
lock ( sync ) {
158
147
_processingQueueTask = null ;
@@ -188,8 +177,7 @@ public void SuspendProcessing(TimeSpan? duration = null, bool discardFutureQueue
188
177
#pragma warning disable 4014
189
178
_storage . CleanupQueueFiles ( _config . GetQueueName ( ) , TimeSpan . Zero ) ;
190
179
#pragma warning restore 4014
191
- }
192
- catch ( Exception ) { }
180
+ } catch ( Exception ) { }
193
181
}
194
182
195
183
public event EventHandler < EventsPostedEventArgs > EventsPosted ;
@@ -198,8 +186,7 @@ protected virtual void OnEventsPosted(EventsPostedEventArgs e) {
198
186
try {
199
187
if ( EventsPosted != null )
200
188
EventsPosted . Invoke ( this , e ) ;
201
- }
202
- catch ( Exception ex ) {
189
+ } catch ( Exception ex ) {
203
190
_log . Error ( typeof ( DefaultEventQueue ) , ex , "Error while calling OnEventsPosted event handlers." ) ;
204
191
}
205
192
}
0 commit comments