private static void SendMultipleMessages(IRpcQueue <TTResponse, TTMessage> queue, int number) { //send a bunch of messages var numberOfJobs = number; var jobs = Enumerable.Range(0, numberOfJobs) .Select(i => new TTMessage()); Parallel.ForEach(jobs, job => { try { var message = queue.Send(job, TimeSpan.FromSeconds(60)); if (message == null) { throw new DotNetWorkQueueException("The response timed out"); } if (message.Body == null) { //RPC call failed //do we have an exception? var error = message.GetHeader(queue.Configuration.HeaderNames.StandardHeaders.RpcConsumerException); if (error != null) { throw new DotNetWorkQueueException("The consumer encountered an error trying to process our request"); } throw new DotNetWorkQueueException("A null reply was received, but no error information was found. Examine the log to see if additional information can be found"); } } catch (TimeoutException) { throw new DotNetWorkQueueException("The request has timed out"); } }); }
/// <summary> /// Initializes a new instance of the <see cref="RpcMethodQueue" /> class. /// </summary> /// <param name="queue">The queue.</param> /// <param name="serializer">The serializer.</param> /// <param name="compositeSerialization">The composite serialization.</param> public RpcMethodQueue(IRpcQueue <object, MessageExpression> queue, IExpressionSerializer serializer, ICompositeSerialization compositeSerialization) { Guard.NotNull(() => queue, queue); Guard.NotNull(() => serializer, serializer); Guard.NotNull(() => compositeSerialization, compositeSerialization); _queue = queue; _serializer = serializer; _compositeSerialization = compositeSerialization; }
/// <summary> /// Initializes a new instance of the <see cref="RpcMethodQueue" /> class. /// </summary> /// <param name="queue">The queue.</param> /// <param name="serializer">The serializer.</param> /// <param name="compositeSerialization">The composite serialization.</param> public RpcMethodQueue(IRpcQueue<object, MessageExpression> queue, IExpressionSerializer serializer, ICompositeSerialization compositeSerialization) { Guard.NotNull(() => queue, queue); Guard.NotNull(() => serializer, serializer); Guard.NotNull(() => compositeSerialization, compositeSerialization); _queue = queue; _serializer = serializer; _compositeSerialization = compositeSerialization; }