public MessageEnvelope CallRaw(byte[] data, string routingKey = "", IBasicProperties properties = null, RpcSendOptions options = null) { Argument.NotNull(routingKey, "routingKey"); properties = properties ?? _model.CreateBasicProperties(); return(_rpcHelper.CallRaw(data, routingKey, properties, options)); }
public TResponse Call <TRequest, TResponse>(TRequest request, string routingKey = "", IBasicProperties properties = null, RpcSendOptions options = null) where TRequest : class where TResponse : class { Argument.NotNull(routingKey, "routingKey"); properties = properties ?? _model.CreateBasicProperties(); return(_rpcHelper.CallTyped <TRequest, TResponse>(request, routingKey, properties, options)); }
public MessageEnvelope CallRaw(byte[] data, string routingKey, IBasicProperties messageProperties, RpcSendOptions options) { // CreateBasicProperties doesnt need the lock var prop = messageProperties ?? _model.CreateBasicProperties(); using (var @event = new AutoResetEvent(false)) { prop.CorrelationId = Guid.NewGuid().ToString(); prop.Expiration = options.Timeout.TotalMilliseconds.ToString(); _waits[prop.CorrelationId] = @event; lock (_model) { var returnQueue = GetOrCreateReturnQueue(routingKey); prop.ReplyTo = returnQueue; } lock (_model) { _model.BasicPublish(_exchange, routingKey, prop, data); } if ([email protected](options.Timeout)) { MessageEnvelope val; _replyData.TryRemove(prop.CorrelationId, out val); LogAdapter.LogDebug("RpcHelper", "Timeout'ed correlation id " + prop.CorrelationId + " for " + routingKey); throw new TimeoutException("Timeout waiting for reply."); } MessageEnvelope reply; _replyData.TryRemove(prop.CorrelationId, out reply); return(reply); } }
public TResponse CallTyped <TRequest, TResponse>(TRequest request, string routingKey, IBasicProperties properties, RpcSendOptions options) { options = options ?? RpcSendOptions.Default; try { var data = _serializer.TypedSerialize(request, properties); var reply = this.CallRaw(data, routingKey, properties, options); if (ErrorResponse.IsHeaderErrorFlag(reply.Properties)) { HandleError(reply); } return(_serializer.TypedDeserialize <TResponse>(reply.Body, reply.Properties)); } catch (TimeoutException) { throw new TimeoutException("Timeout waiting for reply for Rpc call: " + typeof(TRequest).FullName); } }
protected bool Equals(RpcSendOptions other) { return(base.Equals(other) && Timeout.Equals(other.Timeout)); }