Ejemplo n.º 1
0
 public MessageExchange accept(long timeout) throws MessagingException {
   if (this.closed) {
     throw new MessagingException("Channel is closed");
   }
   try {
     QueueSession qs = container.getQueueSession();
     Queue queue = qs.getQueue(componentName);
     MessageExchange me = (MessageExchange) queue.poll(timeout);
     if (me != null) {
       handleReceive(me);
     }
     return me;
   } catch (InterruptedException e) {
     throw new MessagingException(e);
   }
 }
Ejemplo n.º 2
0
 public void enqueue(MessageExchange exchange) throws MessagingException {
   if (!(exchange instanceof MessageExchangeProxy)) {
     throw new MessagingException("exchange should be created with MessageExchangeFactory");
   }
   MessageExchangeProxy me = (MessageExchangeProxy) exchange;
   if (me.getSyncState() == MessageExchangeProxy.SYNC_STATE_SYNC_SENT) {
     synchronized (me) {
       me.setSyncState(MessageExchangeProxy.SYNC_STATE_SYNC_RECEIVED);
       me.notify();
     }
   } else {
     try {
       QueueSession qs = container.getQueueSession();
       Queue queue = qs.getQueue(componentName);
       queue.put(me);
     } catch (InterruptedException e) {
       logger.error(e);
     }
   }
 }