public ChannelWrapper() { IMessagingSystemFactory anInternalMessaging = new SynchronousMessagingSystemFactory(); // The service receives messages via one channel (i.e. it listens on one address). // The incoming messages are unwrapped on the server side. // Therefore the client must use wrapper to send messages via one channel. IChannelWrapperFactory aChannelWrapperFactory = new ChannelWrapperFactory(); myDuplexChannelWrapper = aChannelWrapperFactory.CreateDuplexChannelWrapper(); // To connect message senders and the wrapper with duplex channels we can use the following helper class. IConnectionProviderFactory aConnectionProviderFactory = new ConnectionProviderFactory(); IConnectionProvider aConnectionProvider = aConnectionProviderFactory.CreateConnectionProvider(anInternalMessaging); // Factory to create message senders. // Sent messages will be serialized in Xml. IDuplexTypedMessagesFactory aCommandsFactory = new DuplexTypedMessagesFactory(); plusSender = aCommandsFactory.CreateDuplexTypedMessageSender <TestOutput, TestInput>(); plusSender.ResponseReceived += (s, e) => { Console.WriteLine("CW.V+: " + e.ResponseMessage.Value); }; // attach method handling the request aConnectionProvider.Connect(myDuplexChannelWrapper, plusSender, "plus"); // attach the input channel to get messages from unwrapper minusSender = aCommandsFactory.CreateDuplexTypedMessageSender <TestOutput, TestInput>(); minusSender.ResponseReceived += (s, e) => { Console.WriteLine("CW.V-: " + e.ResponseMessage.Value); }; // attach method handling the request aConnectionProvider.Connect(myDuplexChannelWrapper, minusSender, "minus"); // attach the input channel to get messages from unwrapper dotSender = aCommandsFactory.CreateDuplexTypedMessageSender <TestOutput, TestInput>(); dotSender.ResponseReceived += (s, e) => { Console.WriteLine("CW.V.: " + e.ResponseMessage.Value); }; // attach method handling the request aConnectionProvider.Connect(myDuplexChannelWrapper, dotSender, "dot"); // attach the input channel to get messages from unwrapper IMessagingSystemFactory aTcpMessagingSystem = new TcpMessagingSystemFactory(); // Create output channel to send requests to the service. IDuplexOutputChannel anOutputChannel = aTcpMessagingSystem.CreateDuplexOutputChannel("tcp://127.0.0.1:8091/"); // Attach the output channel to the wrapper - so that we are able to send messages // and receive response messages. // Note: The service has the coresponding unwrapper. myDuplexChannelWrapper.AttachDuplexOutputChannel(anOutputChannel); }
public TableWriter(IShellContext context, IConnectionProvider connection, NameWithSchema name, TableInfo inputRowFormat, CopyTableTargetOptions options, TableInfo destinationTableOverride = null, LinkedDatabaseInfo linkedInfo = null, DataFormatSettings sourceDataFormat = null) { _connectionProvider = connection; _linkedInfo = linkedInfo; _name = name; _inputRowFormat = inputRowFormat; _queue = new CdlDataQueue(inputRowFormat); _context = context; _inserter = connection.Factory.CreateBulkInserter(); _inserter.SourceDataFormat = sourceDataFormat; _connection = _connectionProvider.Connect(); _inserter.Connection = _connection; _inserter.Factory = connection.Factory; _inserter.LinkedInfo = _linkedInfo; var db = context.GetDatabaseStructure(connection.ProviderString); _inserter.DestinationTable = destinationTableOverride ?? db.FindTableLike(_name.Schema, _name.Name); _inserter.CopyOptions = options; _inserter.MessageLogger = _context; _inserter.ServiceProvider = context.ServiceProvider; _thread = new Thread(Run); _thread.Start(); }
private ICdlReader CreateTableReader(TableInfo table, out DbCommand cmd) { string sql = GenerateSqlScript(dmp => { dmp.Put("^select "); bool was = false; foreach (var col in table.Columns) { if (was) { dmp.Put(","); } dmp.ColumnReadableValue(col); was = true; } dmp.Put(" ^from %f", table.FullName); }); var dda = _factory.CreateDataAdapter(); var conn = _provider.Connect(); cmd = conn.CreateCommand(); cmd.CommandTimeout = 3600; cmd.CommandText = sql; _cancelable?.AddCancelMethod(cmd, cmd.Cancel); var reader = cmd.ExecuteReader(); var result = dda.AdaptReader(reader, command: cmd); result.Disposing += () => { reader.Dispose(); conn.Dispose(); }; return(result); }
public Bootstrapper(IConnectionProvider connectionProvider, MessageSettings messageSettings, ISolver solver) { this.getDataInputConsumer = connectionProvider.Connect(messageSettings.InputData); this.postResultProducer = connectionProvider.Open(messageSettings.Result); this.postIsSolvedProducer = connectionProvider.Open(messageSettings.IsSolved); this.solver = solver; }
public async Task Connect() { IpAddress = await _connectionProvider.Connect(this, _id); if (IpAddress == null) { throw new AuthenticationException("Couldn't connect to router!"); } }
private IObservable <ConnectResult> Connect() { if (_model.ConnectionInfo != null) { return(_connectionProvider.Reconnect( _model.ConnectionInfo, _model.ConnectionName, _model.ConnectionString) .Select(connectionInfo => new ConnectResult.Created(connectionInfo)) .Catch <ConnectResult, Exception>(e => Observable.Return(new ConnectResult.Failed(e)))); } return(_connectionProvider.Connect(_model.ConnectionName, _model.ConnectionString) .Select(c => new ConnectResult.Created(c)) .Catch <ConnectResult, Exception>(e => Observable.Return(new ConnectResult.Failed(e)))); }
// CONSTRUCTORS public MessageService(IConnectionProvider connectionProvider, IConfiguration configuration) { this.configuration = configuration; Settings settings = new Settings(); // create producer configuration.Bind("RabbitMq:FromWorkerToServer", settings); producer = connectionProvider.Open(settings); // open consumer configuration.Bind("RabbitMq:FromServerToWorker", settings); consumer = connectionProvider.Connect(settings); }
public FileOutput DequeueData() { using (IConsumer consumer = factory.Connect(downloadFileSetting)) { ReceiveData receiveData = consumer.Receive(500); if (receiveData == null) { return(null); } consumer.SetAcknowledge(receiveData.DeliveryTag, processed: true); return(receiveData.GetObject <FileOutput>()); } }
private void Reconnect() { try { _connection.Dispose(); } catch (Exception) { Logger.Info("Error Dispose durante la reconexion, se procede a la reconexion"); } _connection = _connectionProvider.Connect(); CreateBasicConsumer(); }
public DatabaseInfo GetDatabaseStructure(string connectionKey) { if (!_dbCache.ContainsKey(connectionKey)) { IConnectionProvider connection = ConnectionProvider.FromString(ServiceProvider, connectionKey); _logger.LogInformation("DBSH-00076 Downloading structure for connection {connection}", connection); this.Info(String.Format("DBSH-00149 Downloading structure for connection {0}", connection)); var analyser = connection.Factory.CreateAnalyser(); using (var conn = connection.Connect()) { analyser.Connection = conn; analyser.FullAnalysis(); _dbCache[connectionKey] = analyser.Structure; } } return(_dbCache[connectionKey]); }
public TableWriter(IShellContext context, IConnectionProvider connection, NameWithSchema name, TableInfo inputRowFormat, CopyTableTargetOptions options, TableInfo destinationTableOverride = null, LinkedDatabaseInfo linkedInfo = null, DataFormatSettings sourceDataFormat = null) { _connectionProvider = connection; _linkedInfo = linkedInfo; _name = name; _inputRowFormat = inputRowFormat; _queue = new CdlDataQueue(inputRowFormat); _context = context; _inserter = connection.Factory.CreateBulkInserter(); _inserter.SourceDataFormat = sourceDataFormat; _connection = _connectionProvider.Connect(); _inserter.Connection = _connection; _inserter.Factory = connection.Factory; _inserter.LinkedInfo = _linkedInfo; var db = context.GetDatabaseStructure(connection.ProviderString); _inserter.DestinationTable = destinationTableOverride ?? db.FindTableLike(_name.Schema, _name.Name); _inserter.CopyOptions = options; _inserter.Log += _inserter_Log; _thread = new Thread(Run); _thread.Start(); }
public IsSolvedService(IHubContext <Hubs.OrToolsHub> hubContext, IConnectionProvider factory, IOptionsMonitor <Settings> options) { this.consumer = factory.Connect(options.Get("IsSolvedQueue")); this.hubContext = hubContext; }
/// <summary> /// Initializes a new instance of the <see cref="RabbitWrapper"/> class. /// </summary> /// <param name="connectionProvider">The connection provider.</param> /// <param name="rabbitWrapperType">Type of the rabbit wrapper.</param> internal RabbitWrapper(IConnectionProvider <IRabbitConnection> connectionProvider, RabbitWrapperType rabbitWrapperType) { _connectionProvider = connectionProvider; _rabbitWrapperType = rabbitWrapperType; _connection = _connectionProvider.Connect(); }
/// <summary> /// Initializes a new instance of the <see cref="RabbitWrapper"/> class. /// </summary> /// <param name="connectionProvider">The connection provider.</param> /// <param name="rabbitWrapperType">Type of the rabbit wrapper.</param> internal RabbitWrapper(IConnectionProvider<IRabbitConnection> connectionProvider, RabbitWrapperType rabbitWrapperType) { _connectionProvider = connectionProvider; _rabbitWrapperType = rabbitWrapperType; _connection = _connectionProvider.Connect(); }