forked from hornetq/hornetq
/
ClientConsumerImpl.java
1094 lines (869 loc) · 29.2 KB
/
ClientConsumerImpl.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright 2009 Red Hat, Inc.
* Red Hat licenses this file to you under the Apache License, version
* 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package org.hornetq.core.client.impl;
import java.io.File;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Iterator;
import java.util.concurrent.Executor;
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.client.ClientMessage;
import org.hornetq.api.core.client.MessageHandler;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.protocol.core.Channel;
import org.hornetq.core.protocol.core.impl.wireformat.SessionConsumerCloseMessage;
import org.hornetq.core.protocol.core.impl.wireformat.SessionConsumerFlowCreditMessage;
import org.hornetq.core.protocol.core.impl.wireformat.SessionQueueQueryResponseMessage;
import org.hornetq.core.protocol.core.impl.wireformat.SessionReceiveContinuationMessage;
import org.hornetq.core.protocol.core.impl.wireformat.SessionReceiveLargeMessage;
import org.hornetq.utils.Future;
import org.hornetq.utils.PriorityLinkedList;
import org.hornetq.utils.PriorityLinkedListImpl;
import org.hornetq.utils.TokenBucketLimiter;
/**
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
* @author <a href="mailto:ovidiu@feodorov.com">Ovidiu Feodorov</a>
* @author <a href="mailto:jmesnil@redhat.com">Jeff Mesnil</a>
* @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
* @author <a href="mailto:ataylor@redhat.com">Andy Taylor</a>
* @version <tt>$Revision: 3603 $</tt> $Id: ClientConsumerImpl.java 3603 2008-01-21 18:49:20Z timfox $
*/
public class ClientConsumerImpl implements ClientConsumerInternal
{
// Constants
// ------------------------------------------------------------------------------------
private static final Logger log = Logger.getLogger(ClientConsumerImpl.class);
private static final boolean isTrace = log.isTraceEnabled();
private static final boolean trace = ClientConsumerImpl.log.isTraceEnabled();
public static final long CLOSE_TIMEOUT_MILLISECONDS = 10000;
public static final int NUM_PRIORITIES = 10;
public static final SimpleString FORCED_DELIVERY_MESSAGE = new SimpleString("_hornetq.forced.delivery.seq");
// Attributes
// -----------------------------------------------------------------------------------
private final ClientSessionInternal session;
private final Channel channel;
private final long id;
private final SimpleString filterString;
private final SimpleString queueName;
private final boolean browseOnly;
private final Executor sessionExecutor;
private final int clientWindowSize;
private final int ackBatchSize;
private final PriorityLinkedList<ClientMessageInternal> buffer = new PriorityLinkedListImpl<ClientMessageInternal>(ClientConsumerImpl.NUM_PRIORITIES);
private final Runner runner = new Runner();
private LargeMessageControllerImpl currentLargeMessageController;
// When receiving LargeMessages, the user may choose to not read the body, on this case we need to discard the body
// before moving to the next message.
private ClientMessageInternal largeMessageReceived;
private final TokenBucketLimiter rateLimiter;
private volatile Thread receiverThread;
private volatile Thread onMessageThread;
private volatile MessageHandler handler;
private volatile boolean closing;
private volatile boolean closed;
private volatile int creditsToSend;
private volatile boolean failedOver;
private volatile Exception lastException;
private volatile int ackBytes;
private volatile ClientMessageInternal lastAckedMessage;
private boolean stopped = false;
private long forceDeliveryCount;
private final SessionQueueQueryResponseMessage queueInfo;
private volatile boolean ackIndividually;
private final ClassLoader contextClassLoader;
// Constructors
// ---------------------------------------------------------------------------------
public ClientConsumerImpl(final ClientSessionInternal session,
final long id,
final SimpleString queueName,
final SimpleString filterString,
final boolean browseOnly,
final int clientWindowSize,
final int ackBatchSize,
final TokenBucketLimiter rateLimiter,
final Executor executor,
final Channel channel,
final SessionQueueQueryResponseMessage queueInfo,
final ClassLoader contextClassLoader)
{
this.id = id;
this.queueName = queueName;
this.filterString = filterString;
this.browseOnly = browseOnly;
this.channel = channel;
this.session = session;
this.rateLimiter = rateLimiter;
sessionExecutor = executor;
this.clientWindowSize = clientWindowSize;
this.ackBatchSize = ackBatchSize;
this.queueInfo = queueInfo;
this.contextClassLoader = contextClassLoader;
}
// ClientConsumer implementation
// -----------------------------------------------------------------
private ClientMessage receive(final long timeout, final boolean forcingDelivery) throws HornetQException
{
checkClosed();
if (largeMessageReceived != null)
{
// Check if there are pending packets to be received
largeMessageReceived.discardBody();
largeMessageReceived = null;
}
if (rateLimiter != null)
{
rateLimiter.limit();
}
if (handler != null)
{
throw new HornetQException(HornetQException.ILLEGAL_STATE,
"Cannot call receive(...) - a MessageHandler is set");
}
if (clientWindowSize == 0)
{
startSlowConsumer();
}
receiverThread = Thread.currentThread();
// To verify if deliveryForced was already call
boolean deliveryForced = false;
// To control when to call deliveryForce
boolean callForceDelivery = false;
long start = -1;
long toWait = timeout == 0 ? Long.MAX_VALUE : timeout;
try
{
while (true)
{
ClientMessageInternal m = null;
synchronized (this)
{
while ((stopped || (m = buffer.poll()) == null) && !closed && toWait > 0)
{
if (start == -1)
{
start = System.currentTimeMillis();
}
if (m == null && forcingDelivery)
{
if (stopped)
{
break;
}
// we only force delivery once per call to receive
if (!deliveryForced)
{
callForceDelivery = true;
break;
}
}
try
{
wait(toWait);
}
catch (InterruptedException e)
{
}
if (m != null || closed)
{
break;
}
long now = System.currentTimeMillis();
toWait -= now - start;
start = now;
}
}
if (failedOver)
{
if (m == null)
{
// if failed over and the buffer is null, we reset the state and try it again
failedOver = false;
deliveryForced = false;
toWait = timeout == 0 ? Long.MAX_VALUE : timeout;
continue;
}
else
{
failedOver = false;
}
}
if (callForceDelivery)
{
if (isTrace)
{
log.trace("Forcing delivery");
}
// JBPAPP-6030 - Calling forceDelivery outside of the lock to avoid distributed dead locks
session.forceDelivery(id, forceDeliveryCount++);
callForceDelivery = false;
deliveryForced = true;
continue;
}
if (m != null)
{
session.workDone();
if (m.containsProperty(ClientConsumerImpl.FORCED_DELIVERY_MESSAGE))
{
long seq = m.getLongProperty(ClientConsumerImpl.FORCED_DELIVERY_MESSAGE);
// Need to check if forceDelivery was called at this call
// As we could be receiving a message that came from a previous call
if (forcingDelivery && deliveryForced && seq == forceDeliveryCount - 1)
{
// forced delivery messages are discarded, nothing has been delivered by the queue
resetIfSlowConsumer();
if (isTrace)
{
log.trace("There was nothing on the queue, leaving it now:: returning null");
}
return null;
}
else
{
if (isTrace)
{
log.trace("Ignored force delivery answer as it belonged to another call");
}
// Ignore the message
continue;
}
}
// if we have already pre acked we cant expire
boolean expired = m.isExpired();
flowControlBeforeConsumption(m);
if (expired)
{
m.discardBody();
session.expire(id, m.getMessageID());
if (clientWindowSize == 0)
{
startSlowConsumer();
}
if (toWait > 0)
{
continue;
}
else
{
return null;
}
}
if (m.isLargeMessage())
{
largeMessageReceived = m;
}
if (isTrace)
{
log.trace("Returning " + m);
}
return m;
}
else
{
if (isTrace)
{
log.trace("Returning null");
}
resetIfSlowConsumer();
return null;
}
}
}
finally
{
receiverThread = null;
}
}
public ClientMessage receive(final long timeout) throws HornetQException
{
ClientMessage msg = receive(timeout, false);
if (msg == null && !closed)
{
msg = receive(0, true);
}
return msg;
}
public ClientMessage receive() throws HornetQException
{
return receive(0, false);
}
public ClientMessage receiveImmediate() throws HornetQException
{
return receive(0, true);
}
public MessageHandler getMessageHandler() throws HornetQException
{
checkClosed();
return handler;
}
// Must be synchronized since messages may be arriving while handler is being set and might otherwise end
// up not queueing enough executors - so messages get stranded
public synchronized void setMessageHandler(final MessageHandler theHandler) throws HornetQException
{
checkClosed();
if (receiverThread != null)
{
throw new HornetQException(HornetQException.ILLEGAL_STATE,
"Cannot set MessageHandler - consumer is in receive(...)");
}
boolean noPreviousHandler = handler == null;
if (handler != theHandler && clientWindowSize == 0)
{
startSlowConsumer();
}
handler = theHandler;
// if no previous handler existed queue up messages for delivery
if (handler != null && noPreviousHandler)
{
requeueExecutors();
}
// if unsetting a previous handler may be in onMessage so wait for completion
else if (handler == null && !noPreviousHandler)
{
waitForOnMessageToComplete(true);
}
}
public void close() throws HornetQException
{
doCleanUp(true);
}
public void cleanUp()
{
try
{
doCleanUp(false);
}
catch (HornetQException e)
{
ClientConsumerImpl.log.warn("problem cleaning up: " + this);
}
}
public boolean isClosed()
{
return closed;
}
public void stop() throws HornetQException
{
stop(true);
}
public void stop(final boolean waitForOnMessage) throws HornetQException
{
waitForOnMessageToComplete(waitForOnMessage);
synchronized (this)
{
if (stopped)
{
return;
}
stopped = true;
}
}
public void clearAtFailover()
{
clearBuffer();
lastAckedMessage = null;
creditsToSend = 0;
failedOver = true;
ackIndividually = false;
}
public synchronized void start()
{
stopped = false;
requeueExecutors();
}
public Exception getLastException()
{
return lastException;
}
// ClientConsumerInternal implementation
// --------------------------------------------------------------
public ClientSessionInternal getSession()
{
return session;
}
public SessionQueueQueryResponseMessage getQueueInfo()
{
return queueInfo;
}
public long getID()
{
return id;
}
public SimpleString getFilterString()
{
return filterString;
}
public SimpleString getQueueName()
{
return queueName;
}
public boolean isBrowseOnly()
{
return browseOnly;
}
public synchronized void handleMessage(final ClientMessageInternal message) throws Exception
{
if (closing)
{
// This is ok - we just ignore the message
return;
}
ClientMessageInternal messageToHandle = message;
if (messageToHandle.getAddress() == null)
{
messageToHandle.setAddressTransient(queueInfo.getAddress());
}
messageToHandle.onReceipt(this);
if (message.getPriority() != 4)
{
// We have messages of different priorities so we need to ack them individually since the order
// of them in the ServerConsumerImpl delivery list might not be the same as the order they are
// consumed in, which means that acking all up to won't work
ackIndividually = true;
}
// Add it to the buffer
buffer.addTail(messageToHandle, messageToHandle.getPriority());
if (handler != null)
{
// Execute using executor
if (!stopped)
{
queueExecutor();
}
}
else
{
notify();
}
}
public synchronized void handleLargeMessage(final SessionReceiveLargeMessage packet) throws Exception
{
if (closing)
{
// This is ok - we just ignore the message
return;
}
// Flow control for the first packet, we will have others
flowControl(packet.getPacketSize(), false);
ClientLargeMessageInternal currentChunkMessage = (ClientLargeMessageInternal)packet.getLargeMessage();
currentChunkMessage.setDeliveryCount(packet.getDeliveryCount());
File largeMessageCache = null;
if (session.isCacheLargeMessageClient())
{
largeMessageCache = File.createTempFile("tmp-large-message-" + currentChunkMessage.getMessageID() + "-",
".tmp");
largeMessageCache.deleteOnExit();
}
currentLargeMessageController = new LargeMessageControllerImpl(this, packet.getLargeMessageSize(), 5, largeMessageCache);
if (currentChunkMessage.isCompressed())
{
currentChunkMessage.setLargeMessageController(new CompressedLargeMessageControllerImpl(currentLargeMessageController));
}
else
{
currentChunkMessage.setLargeMessageController(currentLargeMessageController);
}
currentChunkMessage.setFlowControlSize(0);
handleMessage(currentChunkMessage);
}
public synchronized void handleLargeMessageContinuation(final SessionReceiveContinuationMessage chunk) throws Exception
{
if (closing)
{
return;
}
if (currentLargeMessageController == null)
{
if (log.isTraceEnabled())
{
log.trace("Sending back credits for largeController = null " + chunk.getPacketSize());
}
flowControl(chunk.getPacketSize(), false);
}
else
{
currentLargeMessageController.addPacket(chunk);
}
}
public void clear(boolean waitForOnMessage) throws HornetQException
{
synchronized (this)
{
// Need to send credits for the messages in the buffer
Iterator<ClientMessageInternal> iter = buffer.iterator();
while (iter.hasNext())
{
try
{
ClientMessageInternal message = iter.next();
if (message.isLargeMessage())
{
ClientLargeMessageInternal largeMessage = (ClientLargeMessageInternal)message;
largeMessage.getLargeMessageController().cancel();
}
flowControlBeforeConsumption(message);
}
catch (Exception e)
{
log.warn(e.getMessage(), e);
}
}
clearBuffer();
try
{
if (currentLargeMessageController != null)
{
currentLargeMessageController.cancel();
currentLargeMessageController = null;
}
}
catch (Throwable e)
{
// nothing that could be done here
log.warn(e.getMessage(), e);
}
}
// Need to send credits for the messages in the buffer
waitForOnMessageToComplete(waitForOnMessage);
}
public int getClientWindowSize()
{
return clientWindowSize;
}
public int getBufferSize()
{
return buffer.size();
}
public void acknowledge(final ClientMessage message) throws HornetQException
{
ClientMessageInternal cmi = (ClientMessageInternal)message;
if (ackIndividually)
{
if (lastAckedMessage != null)
{
flushAcks();
}
session.individualAcknowledge(id, message.getMessageID());
}
else
{
ackBytes += message.getEncodeSize();
if (ackBytes >= ackBatchSize)
{
doAck(cmi);
}
else
{
lastAckedMessage = cmi;
}
}
}
public void flushAcks() throws HornetQException
{
if (lastAckedMessage != null)
{
doAck(lastAckedMessage);
}
}
/**
*
* LargeMessageBuffer will call flowcontrol here, while other handleMessage will also be calling flowControl.
* So, this operation needs to be atomic.
*
* @param discountSlowConsumer When dealing with slowConsumers, we need to discount one credit that was pre-sent when the first receive was called. For largeMessage that is only done at the latest packet
*/
public void flowControl(final int messageBytes, final boolean discountSlowConsumer) throws HornetQException
{
if (clientWindowSize >= 0)
{
creditsToSend += messageBytes;
if (log.isTraceEnabled())
{
log.trace(this + "::FlowControl::creditsToSend=" + creditsToSend + ", clientWindowSize = " + clientWindowSize + " messageBytes = " + messageBytes);
}
if (creditsToSend >= clientWindowSize)
{
if (clientWindowSize == 0 && discountSlowConsumer)
{
if (ClientConsumerImpl.trace)
{
ClientConsumerImpl.log.trace("FlowControl::Sending " + creditsToSend + " -1, for slow consumer");
}
// sending the credits - 1 initially send to fire the slow consumer, or the slow consumer would be
// always buffering one after received the first message
final int credits = creditsToSend - 1;
creditsToSend = 0;
if (credits > 0)
{
sendCredits(credits);
}
}
else
{
if (ClientConsumerImpl.trace)
{
ClientConsumerImpl.log.trace("Sending " + messageBytes + " from flow-control");
}
final int credits = creditsToSend;
creditsToSend = 0;
if (credits > 0)
{
sendCredits(credits);
}
}
}
}
}
// Public
// ---------------------------------------------------------------------------------------
// Package protected
// ---------------------------------------------------------------------------------------
// Protected
// ---------------------------------------------------------------------------------------
// Private
// ---------------------------------------------------------------------------------------
/**
* Sending a initial credit for slow consumers
* */
private void startSlowConsumer()
{
if (ClientConsumerImpl.trace)
{
ClientConsumerImpl.log.trace("Sending 1 credit to start delivering of one message to slow consumer");
}
sendCredits(1);
}
private void resetIfSlowConsumer()
{
if (clientWindowSize == 0)
{
sendCredits(0);
}
}
private void requeueExecutors()
{
for (int i = 0; i < buffer.size(); i++)
{
queueExecutor();
}
}
private void queueExecutor()
{
if (ClientConsumerImpl.trace)
{
ClientConsumerImpl.log.trace("Adding Runner on Executor for delivery");
}
sessionExecutor.execute(runner);
}
/**
* @param credits
*/
private void sendCredits(final int credits)
{
channel.send(new SessionConsumerFlowCreditMessage(id, credits));
}
private void waitForOnMessageToComplete(boolean waitForOnMessage)
{
if (handler == null)
{
return;
}
if (!waitForOnMessage || Thread.currentThread() == onMessageThread)
{
// If called from inside onMessage then return immediately - otherwise would block
return;
}
org.hornetq.utils.Future future = new Future();
sessionExecutor.execute(future);
boolean ok = future.await(ClientConsumerImpl.CLOSE_TIMEOUT_MILLISECONDS);
if (!ok)
{
ClientConsumerImpl.log.warn("Timed out waiting for handler to complete processing");
}
}
private void checkClosed() throws HornetQException
{
if (closed)
{
throw new HornetQException(HornetQException.OBJECT_CLOSED, "Consumer is closed");
}
}
private void callOnMessage() throws Exception
{
if (closing || stopped)
{
return;
}
session.workDone();
// We pull the message from the buffer from inside the Runnable so we can ensure priority
// ordering. If we just added a Runnable with the message to the executor immediately as we get it
// we could not do that
ClientMessageInternal message;
// Must store handler in local variable since might get set to null
// otherwise while this is executing and give NPE when calling onMessage
MessageHandler theHandler = handler;
if (theHandler != null)
{
if (rateLimiter != null)
{
rateLimiter.limit();
}
failedOver = false;
synchronized (this)
{
message = buffer.poll();
}
if (message != null)
{
if (message.containsProperty(ClientConsumerImpl.FORCED_DELIVERY_MESSAGE))
{
//Ignore, this could be a relic from a previous receiveImmediate();
return;
}
boolean expired = message.isExpired();
flowControlBeforeConsumption(message);
if (!expired)
{
onMessageThread = Thread.currentThread();
if (ClientConsumerImpl.trace)
{
ClientConsumerImpl.log.trace("Calling handler.onMessage");
}
final ClassLoader originalLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
{
public ClassLoader run()
{
ClassLoader originalLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(contextClassLoader);
return originalLoader;
}
});
try
{
theHandler.onMessage(message);
}
finally
{
AccessController.doPrivileged(new PrivilegedAction<Object>()
{
public Object run()
{
Thread.currentThread().setContextClassLoader(originalLoader);
return null;
}
});
}
if (ClientConsumerImpl.trace)
{
ClientConsumerImpl.log.trace("Handler.onMessage done");
}
if (message.isLargeMessage())
{
message.discardBody();
}
}
else
{
session.expire(id, message.getMessageID());
}
// If slow consumer, we need to send 1 credit to make sure we get another message
if (clientWindowSize == 0)
{
startSlowConsumer();
}
}
}
}
/**
* @param message
* @throws HornetQException
*/
private void flowControlBeforeConsumption(final ClientMessageInternal message) throws HornetQException
{
// Chunk messages will execute the flow control while receiving the chunks
if (message.getFlowControlSize() != 0)
{
flowControl(message.getFlowControlSize(), true);