public void Create(IMessageOptions options = null) { if (options != null) { if (options.Timeout > 0) { this._timeout = options.Timeout; } } var nodeAddress = this.ParseRpcNodeAddress(this._amqpNode); this._amqpNode = nodeAddress.Address; if (!string.IsNullOrEmpty(nodeAddress.Subject)) { this._subject = nodeAddress.Subject; } var _receiverSource = new Source() { Dynamic = true, Address = nodeAddress.Address }; this._receiver = this._session.CreateReceiver(name: $"AmqpNetLiteRpcClientReceiver-{this._amqpNode}", source: _receiverSource, onAttached: OnReceiverLinkAttached); this._receiver.Start(credit: int.MaxValue, onMessage: this.processResponse); this._sender = this._session.CreateSender(name: $"AmqpNetLiteRpcClientSender-{this._amqpNode}", target: new Target(), onAttached: OnSenderLinkAttached); if (!_receiverAttached.WaitOne(this._receiverAttacheTimeout)) { throw new Exception($"Failed to create receiver connection in {this._receiverAttacheTimeout}"); } }
public IRpcClient CreateAmqpRpcClient(string amqpNode, IMessageOptions options = null) { if (this._connection == null) { throw new Exception("Please initiate connection using InitiateAmqpRpc"); } if (this._session == null) { throw new Exception("Please initiate session using InitiateAmqpRpc"); } IRpcClient _client = null; if (!this._clientMap.TryGetValue(amqpNode, out _client)) { _client = new RpcClient(amqpNode, this._session); _client.Create(options); this._clientMap.Add(amqpNode, _client); } return(_client); }