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); } }
protected bool ChannelLocallyTransacted(IClientSession channel) { return(ChannelTransacted && !ClientFactoryUtils.IsChannelTransactional(channel, ClientFactory)); }