/* */ }
/* */
/* */ public MessageProxy receive(long timeout)
/* */ throws JMSException
/* */ {
/* 385 */ MessageProxy m = null;
/* */
/* 387 */ synchronized (this.mainLock)
/* */ {
/* 389 */ if (trace) log.trace(this + " receiving, timeout = " + timeout);
/* */
/* 391 */ if (this.closed)
/* */ {
/* 394 */ if (trace) log.trace(this + " closed, returning null");
/* 395 */ return null;
/* */ }
/* */
/* 398 */ if (this.listener != null)
/* */ {
/* 400 */ throw new JMSException("The consumer has a MessageListener set, cannot call receive(..)");
/* */ }
/* */
/* 404 */ this.receiverThread = Thread.currentThread();
/* */
/* 406 */ long startTimestamp = System.currentTimeMillis();
/* */ try
/* */ {
/* */ while (true)
/* */ {
/* */ Object localObject1;
/* 412 */ if (timeout == 0L)
/* */ {
/* 414 */ if (trace) log.trace(this + ": receive, no timeout");
/* */
/* 416 */ m = getMessage(0L);
/* */
/* 418 */ if (m == null)
/* */ {
/* 420 */ localObject1 = null;
/* */
/* 507 */ this.receiverThread = null;
/* 508 */ return localObject1;
/* */ }
/* */ }
/* 423 */ else if (timeout == -1L)
/* */ {
/* 426 */ if (trace) log.trace(this + ": receive, noWait");
/* */
/* 428 */ m = getMessage(-1L);
/* */
/* 430 */ if (m == null)
/* */ {
/* 432 */ if (trace) log.trace(this + ": no message available");
/* 433 */ localObject1 = null;
/* */
/* 507 */ this.receiverThread = null;
/* 508 */ return localObject1;
/* */ }
/* */ }
/* */ else
/* */ {
/* 438 */ if (trace) log.trace(this + ": receive, timeout " + timeout + " ms, blocking poll on queue");
/* */
/* 440 */ m = getMessage(timeout);
/* */
/* 442 */ if (m == null)
/* */ {
/* 445 */ if (trace) log.trace(this + ": " + timeout + " ms timeout expired");
/* */
/* 447 */ localObject1 = null;
/* */
/* 507 */ this.receiverThread = null;
/* 508 */ return localObject1;
/* */ }
/* */ }
/* 451 */ if (trace) log.trace(this + " received " + m + " after being blocked on buffer");
/* */
/* 453 */ boolean ignore = checkExpiredOrReachedMaxdeliveries(m, this.sessionDelegate, this.maxDeliveries, this.shouldAck);
/* */
/* 456 */ if ((!this.isConnectionConsumer) && (!ignore))
/* */ {
/* 458 */ DeliveryInfo info = new DeliveryInfo(m, this.consumerID, this.queueName, null, this.shouldAck);
/* */
/* 460 */ this.sessionDelegate.preDeliver(info);
/* */
/* 467 */ ignore = !this.sessionDelegate.postDeliver();
/* */
/* 469 */ if (trace)
/* */ {
/* 471 */ log.trace("Post deliver returned " + (!ignore));
/* */ }
/* */
/* 474 */ if (!ignore)
/* */ {
/* 476 */ m.incDeliveryCount();
/* */ }
/* */ }
/* */
/* 480 */ if (!ignore)
/* */ {