コード例 #1
0
 protected List getMessages() throws Exception {
   QueueSession qs = connector.getQueueSession();
   Queue queue = qs.getQueue(endpoint.getEndpointURI().getAddress());
   UMOEvent event = (UMOEvent) queue.poll(connector.getQueueTimeout());
   if (event != null) {
     routeMessage(new MuleMessage(event.getTransformedMessage(), event.getMessage()));
   }
   return null;
 }
コード例 #2
0
 protected void enqueue(MuleEvent event) throws Exception {
   QueueSession session = muleContext.getQueueManager().getQueueSession();
   Queue queue = session.getQueue(name);
   if (queue == null) {
     throw new InitialisationException(
         MessageFactory.createStaticMessage("Queue " + name + " not created for service " + name),
         this);
   }
   if (logger.isDebugEnabled()) {
     logger.debug("Service " + name + " putting event on queue " + name + ": " + event);
   }
   queue.put(event);
 }
コード例 #3
0
 public int getQueueSize() {
   QueueSession session = muleContext.getQueueManager().getQueueSession();
   Queue queue = session.getQueue(name);
   if (queue == null) {
     logger.warn(
         new InitialisationException(
             MessageFactory.createStaticMessage(
                 "Queue " + name + " not created for service " + name),
             this));
     return -1;
   }
   return queue.size();
 }
コード例 #4
0
 protected void doConnect() throws Exception {
   if (connector.isQueueEvents()) {
     // Ensure we can create a vm queue
     QueueSession queueSession = connector.getQueueSession();
     Queue q = queueSession.getQueue(endpoint.getEndpointURI().getAddress());
     if (logger.isDebugEnabled()) {
       logger.debug(
           "Current queue depth for queue: "
               + endpoint.getEndpointURI().getAddress()
               + " is: "
               + q.size());
     }
   }
 }
コード例 #5
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);
   }
 }
コード例 #6
0
 /*
  * (non-Javadoc)
  *
  * @see org.mule.umo.UMOEventListener#onEvent(org.mule.umo.UMOEvent)
  */
 public void onEvent(UMOEvent event) throws UMOException {
   if (connector.isQueueEvents()) {
     QueueSession queueSession = connector.getQueueSession();
     Queue queue = queueSession.getQueue(endpoint.getEndpointURI().getAddress());
     try {
       queue.put(event);
     } catch (InterruptedException e) {
       throw new MuleException(
           CoreMessages.interruptedQueuingEventFor(this.endpoint.getEndpointURI()), e);
     }
   } else {
     UMOMessage msg = new MuleMessage(event.getTransformedMessage(), event.getMessage());
     synchronized (lock) {
       routeMessage(msg);
     }
   }
 }
コード例 #7
0
 protected void doRollback() throws TransactionException {
   try {
     if (resource != null) {
       ((QueueSession) resource).rollback();
     }
   } catch (ResourceManagerException e) {
     throw new TransactionException(CoreMessages.transactionRollbackFailed(), e);
   }
 }
コード例 #8
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);
     }
   }
 }
コード例 #9
0
 public void bindResource(Object key, Object resource) throws TransactionException {
   if (!(key instanceof QueueManager) || !(resource instanceof QueueSession)) {
     throw new IllegalTransactionStateException(
         CoreMessages.transactionCanOnlyBindToResources("QueueManager/QueueSession"));
   }
   super.bindResource(key, resource);
   try {
     ((QueueSession) resource).begin();
   } catch (ResourceManagerException e) {
     throw new TransactionException(CoreMessages.cannotStartTransaction("VMTransaction"), e);
   }
 }