@@ -65,7 +65,8 @@ public void Process() {
65
65
_storage . ReleaseStaleLocks ( _config . GetQueueName ( ) ) ;
66
66
67
67
DateTime maxCreatedDate = DateTime . Now ;
68
- var batch = _storage . GetEventBatch ( _config . GetQueueName ( ) , _serializer , _config . SubmissionBatchSize , maxCreatedDate ) ;
68
+ int batchSize = _config . SubmissionBatchSize ;
69
+ var batch = _storage . GetEventBatch ( _config . GetQueueName ( ) , _serializer , batchSize , maxCreatedDate ) ;
69
70
while ( batch . Any ( ) ) {
70
71
bool deleteBatch = true ;
71
72
@@ -90,6 +91,14 @@ public void Process() {
90
91
// The service end point could not be found.
91
92
_log . FormattedError ( typeof ( DefaultEventQueue ) , "Error while trying to submit data: {0}" , response . Message ) ;
92
93
SuspendProcessing ( TimeSpan . FromHours ( 4 ) ) ;
94
+ } else if ( response . RequestEntityTooLarge ) {
95
+ if ( batchSize > 1 ) {
96
+ _log . Error ( typeof ( DefaultEventQueue ) , "Event submission discarded for being too large. The event will be retried with a smaller batch size." ) ;
97
+ batchSize = Math . Max ( 1 , ( int ) Math . Round ( batchSize / 1.5d , 0 ) ) ;
98
+ deleteBatch = false ;
99
+ } else {
100
+ _log . Error ( typeof ( DefaultEventQueue ) , "Event submission discarded for being too large. The event will not be submitted." ) ;
101
+ }
93
102
} else if ( ! response . Success ) {
94
103
_log . Error ( typeof ( DefaultEventQueue ) , String . Format ( "An error occurred while submitting events: {0}" , response . Message ) ) ;
95
104
SuspendProcessing ( ) ;
@@ -113,7 +122,7 @@ public void Process() {
113
122
if ( ! deleteBatch || IsQueueProcessingSuspended )
114
123
break ;
115
124
116
- batch = _storage . GetEventBatch ( _config . GetQueueName ( ) , _serializer , _config . SubmissionBatchSize , maxCreatedDate ) ;
125
+ batch = _storage . GetEventBatch ( _config . GetQueueName ( ) , _serializer , batchSize , maxCreatedDate ) ;
117
126
}
118
127
} catch ( Exception ex ) {
119
128
_log . Error ( typeof ( DefaultEventQueue ) , ex , String . Concat ( "An error occurred while processing the queue: " , ex . Message ) ) ;
0 commit comments