Exemple #1
0
        public T Execute <T>(ClientSessionCallbackDelegate <T> action)
        {
            AssertUtils.ArgumentNotNull(action, "Callback object must not be null");
            IClient        clientToClose  = null;
            IClientSession sessionToClose = null;

            try
            {
                IClientSession channelToUse = ClientFactoryUtils
                                              .DoGetTransactionalSession(ClientFactory,
                                                                         this.transactionalResourceFactory);
                if (channelToUse == null)
                {
                    clientToClose  = CreateClient();
                    sessionToClose = CreateChannel(clientToClose);
                    channelToUse   = sessionToClose;
                }
                if (logger.IsDebugEnabled)
                {
                    logger.Debug("Executing callback on RabbitMQ Channel: " + channelToUse);
                }
                return(action(channelToUse));
            }
            catch (Exception ex)
            {
                throw;
                //TOOD convertRabbitAccessException(ex) ?
            }
            finally
            {
                QpidUtils.CloseChannel(sessionToClose);
                ClientFactoryUtils.ReleaseConnection(clientToClose, ClientFactory);
            }
        }
Exemple #2
0
 protected bool ChannelLocallyTransacted(IClientSession channel)
 {
     return(ChannelTransacted &&
            !ClientFactoryUtils.IsChannelTransactional(channel, ClientFactory));
 }