private synchronized void grabMessage() { ready = true; channel.deliver(this);
private synchronized javax.jms.Message grabMessage() throws JMSException { if (closed) { if (log.isTraceEnabled()) { log.trace("consumer " + this + " closed, rejecting message" ); } throw new IllegalStateException("Consumer is closed"); }  Message message = null;   if (started) {  MessageReference ref = null;  try { ref = channel.getFirst(); } catch (Throwable t) {  String msg = "Failed to get ref from channel"; log.error(msg, t); throw new JMSException(msg); } if (ref != null) { Delivery delivery = null; message = ref.getMessage();  message = JBossMessage.copy((javax.jms.Message)message);  if (log.isTraceEnabled()) { log.trace("dereferenced message: " + message); }  boolean accept = this.accept(message); delivery = new SimpleDelivery(channel, ref); if (!accept) { if (log.isTraceEnabled()) { log.trace("consumer DOES NOT accept the message"); }  try {     channel.add(delivery); boolean cancelled = delivery.cancel(); } catch (Throwable t) { String msg = "Failed to cancel delivery"; log.error(msg, t); throw new JMSException(msg); } message = null; } else { if (ref.isRedelivered()) { message.setRedelivered(true); if (log.isTraceEnabled()) { log.trace("set the redelivered flag to true"); } }  try { channel.add(delivery); } catch (Throwable t) { String msg = "Failed to add delivery to channel"; log.error(msg, t); throw new JMSException(msg); } deliveries.add(delivery); } } }   if (message == null) { ready = true; channel.deliver(this); return null; } else { return (javax.jms.Message)message; }
   private synchronized void grabMessage()   {      ready = true;      channel.deliver(this);   }