本文整理汇总了C#中IConnectionFactory类的典型用法代码示例。如果您正苦于以下问题:C# IConnectionFactory类的具体用法?C# IConnectionFactory怎么用?C# IConnectionFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IConnectionFactory类属于命名空间,在下文中一共展示了IConnectionFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RabbitResourceHolder
public RabbitResourceHolder(IConnectionFactory connectionFactory, IConnection connection, IModel channel)
{
this.connectionFactory = connectionFactory;
AddConnection(connection);
AddChannel(channel);
this.frozen = true;
}
示例2: SharedConnectionPoolFactory
public SharedConnectionPoolFactory(
IConnectionFactory connectionFactory,
ConnectionPoolSettings connectionPoolSettings)
{
_connectionFactory = Ensure.IsNotNull(connectionFactory, "connectionFactory");
_connectionPoolSettings = Ensure.IsNotNull(connectionPoolSettings, "connectionPoolSettings");
}
示例3: PersistentConnection
public PersistentConnection(IConnectionFactory connectionFactory, IEasyNetQLogger logger)
{
this.connectionFactory = connectionFactory;
this.logger = logger;
TryToConnect(null);
}
示例4: Db
/// <summary>
/// Instantiate Db with connectionString and a custom IConnectionFactory
/// </summary>
/// <param name="connectionString">the connection string</param>
/// <param name="config"></param>
/// <param name="connectionFactory">the connection factory</param>
internal Db(string connectionString, DbConfig config, IConnectionFactory connectionFactory = null)
{
_connectionString = connectionString;
_connectionFactory = connectionFactory ?? new AdoNetProviderFactory(config.ProviderName);
_connection = new Lazy<IDbConnection>(CreateConnection);
Config = config;
}
示例5: Setup
public void Setup()
{
factory = A.Fake<IConnectionFactory>();
fakeHttp = A.Fake<ISimpleHttpGetRequest>();
fakeWebSocket = A.Fake<IWebSocket>();
heartBeatSignaler = A.Fake<IHeartBeatSignaler>();
A.CallTo(() => factory.CreateHttpRequest(A<string>._)).Returns(fakeHttp);
A.CallTo(() => fakeHttp.Execute()).ReturnsLazily(() => handshakeResponse);
A.CallTo(() => factory.CreateWebSocket(A<string>._)).Returns(fakeWebSocket);
A.CallTo(() => fakeWebSocket.Connected).ReturnsLazily(() => isConnected);
A.CallTo(() => fakeWebSocket.Open()).Invokes(() =>
{
isConnected = true;
fakeWebSocket.Opened += Raise.With(fakeWebSocket, EventArgs.Empty).Now;
});
A.CallTo(() => fakeWebSocket.Close()).Invokes(() =>
{
isConnected = false;
fakeWebSocket.Closed += Raise.With(fakeWebSocket, EventArgs.Empty).Now;
});
io = new SocketIOClient(factory, heartBeatSignaler);
socket = io.Connect("http://localhost:3000");
}
示例6: InheritedSqlPersistenceEngine
public InheritedSqlPersistenceEngine(
IConnectionFactory connectionFactory,
ISqlDialect dialect,
ISerialize serializer,
TransactionScopeOption scopeOption, int pageSize)
: base(connectionFactory, dialect, serializer, scopeOption, pageSize)
{}
示例7: LinearBlockIdGenerator
public LinearBlockIdGenerator(IConnectionFactory connectionFactory, int range, string dimension, string tablePrefix)
{
_connectionFactory = connectionFactory;
_range = range;
_tablePrefix = tablePrefix;
_dimension = dimension;
}
示例8: CreateMocks
private void CreateMocks()
{
mockConnectionFactory = (IConnectionFactory) mocks.CreateMock(typeof (IConnectionFactory));
mockConnection = (IConnection) mocks.CreateMock(typeof (IConnection));
mockSession = (ISession) mocks.CreateMock(typeof (ISession));
TIBCO.EMS.Queue queue = new TIBCO.EMS.Queue("test"); //(Queue) mocks.CreateMock(typeof (Queue));
Expect.Call(mockConnectionFactory.CreateConnection()).Return(mockConnection).Repeat.Once();
if (UseTransactedTemplate)
{
Expect.Call(mockConnection.CreateSession(true, Session.SESSION_TRANSACTED)).Return(mockSession).Repeat.
Once();
}
else
{
Expect.Call(mockConnection.CreateSession(false, Session.AUTO_ACKNOWLEDGE)).Return(mockSession).
Repeat.
Once();
}
Expect.Call(mockSession.Transacted).Return(true);
mockDestinationResolver =
(IDestinationResolver) mocks.CreateMock(typeof (IDestinationResolver));
mockDestinationResolver.ResolveDestinationName(mockSession, "testDestination", false);
LastCall.Return(queue).Repeat.Any();
}
示例9: PersistentConnection
public PersistentConnection(IConnectionFactory connectionFactory, TimeSpan retryDelay)
{
this.connectionFactory = connectionFactory;
this.retryDelay = retryDelay;
TryToConnect(null);
}
示例10: ServerFactory
// constructors
public ServerFactory(ServerSettings settings, IConnectionPoolFactory connectionPoolFactory, IConnectionFactory heartbeatConnectionFactory, IServerListener listener)
{
_settings = Ensure.IsNotNull(settings, "settings");
_connectionPoolFactory = Ensure.IsNotNull(connectionPoolFactory, "connectionPoolFactory");
_heartbeatConnectionFactory = Ensure.IsNotNull(heartbeatConnectionFactory, "heartbeatConnectionFactory");
_listener = listener;
}
示例11: ConnectionPool
public ConnectionPool( RedisConfiguration configuration, IConnectionFactory connectionFactory )
{
Configuration = configuration;
ConnectionFactory = connectionFactory;
AvailableConnections = new ConcurrentQueue<IConnection>();
ReservedConnections = new ConcurrentDictionary<IConnection, IConnection>();
}
示例12: CustomerAgent
public CustomerAgent(IConnectionFactory ConnectionFactory,
CustomerFactory Factory, CustomerAppService CustomerAppService)
{
this.Factory = Factory;
this.ConnectionFactory = ConnectionFactory;
this.CustomerAppService = CustomerAppService;
}
示例13: Connection
/// <summary>
/// Initializes a new instance of the <see cref="Connection"/> class.
/// </summary>
/// <param name="factory">The pool.</param>
public Connection(IConnectionFactory factory)
{
if (factory == null)
throw new ArgumentNullException ("factory");
_factory = factory;
}
示例14: ExclusiveConnectionPool
// constructors
public ExclusiveConnectionPool(
ServerId serverId,
EndPoint endPoint,
ConnectionPoolSettings settings,
IConnectionFactory connectionFactory,
IEventSubscriber eventSubscriber)
{
_serverId = Ensure.IsNotNull(serverId, nameof(serverId));
_endPoint = Ensure.IsNotNull(endPoint, nameof(endPoint));
_settings = Ensure.IsNotNull(settings, nameof(settings));
_connectionFactory = Ensure.IsNotNull(connectionFactory, nameof(connectionFactory));
Ensure.IsNotNull(eventSubscriber, nameof(eventSubscriber));
_connectionHolder = new ListConnectionHolder(eventSubscriber);
_poolQueue = new WaitQueue(settings.MaxConnections);
_waitQueue = new SemaphoreSlim(settings.WaitQueueSize);
_maintenanceCancellationTokenSource = new CancellationTokenSource();
_state = new InterlockedInt32(State.Initial);
eventSubscriber.TryGetEventHandler(out _checkingOutConnectionEventHandler);
eventSubscriber.TryGetEventHandler(out _checkedOutConnectionEventHandler);
eventSubscriber.TryGetEventHandler(out _checkingOutConnectionFailedEventHandler);
eventSubscriber.TryGetEventHandler(out _checkingInConnectionEventHandler);
eventSubscriber.TryGetEventHandler(out _checkedInConnectionEventHandler);
eventSubscriber.TryGetEventHandler(out _addingConnectionEventHandler);
eventSubscriber.TryGetEventHandler(out _addedConnectionEventHandler);
eventSubscriber.TryGetEventHandler(out _openingEventHandler);
eventSubscriber.TryGetEventHandler(out _openedEventHandler);
eventSubscriber.TryGetEventHandler(out _closingEventHandler);
eventSubscriber.TryGetEventHandler(out _closedEventHandler);
eventSubscriber.TryGetEventHandler(out _addingConnectionEventHandler);
eventSubscriber.TryGetEventHandler(out _addedConnectionEventHandler);
}
示例15: Queue
public Queue(MsgDeliveryMode mode = MsgDeliveryMode.NonPersistent)
{
Uri msgQueue = new Uri("activemq:tcp://localhost:61616");
_factory = new ConnectionFactory(msgQueue);
try
{
_connection = _factory.CreateConnection();
}
catch (NMSConnectionException ex)
{
Log.FatalException("Error connecting to MQ server", ex);
throw;
}
// TODO check _connection for null
_connection.RequestTimeout = TimeSpan.FromSeconds(60);
Session = _connection.CreateSession();
// TODO need to find out if queue exists.
// It creates a new queue if it doesn't exist.
_destination = Session.GetDestination("queue://TwitterSearchStream");
_consumer = Session.CreateConsumer(_destination);
_producer = Session.CreateProducer(_destination);
_producer.RequestTimeout = TimeSpan.FromSeconds(60);
_producer.DeliveryMode = mode;
_connection.Start();
_connection.ExceptionListener += _connection_ExceptionListener;
_connection.ConnectionInterruptedListener += _connection_ConnectionInterruptedListener;
}