2

I have a very simple Request-Response architecture on which I am getting a "Request timed out" exception. First I am sending a message to a Windows Service from a Web API controller like this:

using (var messageBus = RabbitHutch.CreateBus("host=localhost;timeout=120"))
{
    ReportData1 data = new ReportData1();

    // Populate data
    data.clientIds.Add(client.Id);
    data.incidentIds.Add(incidentId);
    data.clientNames.Add(client.Name);
    data.clientNetworkPaths.Add(client.NetworkPath);
    data.formatDescriptions.Add(EnumUtils.GetDescription(format));
    data.reportFormats.Add(format.ToString());               

    messageBus.Publish(data);
}

Where ReportData1 is:

public class ReportData1
{
    public List<int> clientIds { get; set; }
    public List<int> incidentIds { get; set; }
    public List<string> clientNames { get; set; }
    public List<string> clientNetworkPaths { get; set; }
    public List<string> formatDescriptions { get; set; }
    public List<string> reportFormats { get; set; }

    public ReportData1()
    {
        this.clientIds = new List<int>();
        this.incidentIds = new List<int>();
        this.clientNames = new List<string>();
        this.clientNetworkPaths = new List<string>();
        this.formatDescriptions = new List<string>();
        this.reportFormats = new List<string>();
    }
}

Then in a Windows Service application i subscribe to messages of type ReportData1 and also send a synchronous request to a second Windows Service:

protected override void OnStart(string[] args)
{
    Library.WriteErrorLog("Report Publish Service started", "PublisherLogFile");

    this.bus = RabbitHutch.CreateBus("host=localhost;timeout=120");

    this.bus.Subscribe<ReportData1>("reportHandling", this.Test);
}

    private void Test(ReportData1 reportData1)
    {
        Library.WriteErrorLog(count + " report requests found.", "PublisherLogFile");

            ReportData data1 = new ReportData();
            data1.clientId = reportData1.clientIds[0];
            data1.incidentId = reportData1.incidentIds[0];
            data1.clientName = reportData1.clientNames[0];
            data1.clientNetworkPath = reportData1.clientNetworkPaths[0];
            data1.formatDescription = reportData1.formatDescriptions[0];
            data1.reportFormat = reportData1.reportFormats[0];

            Library.WriteErrorLog("Sending request for Client Id: " + data1.clientId + " and Incident Id: " + data1.incidentId, "PublisherLogFile");

            var response = this.bus.Request<ReportData, TestResponse>(data1);

            Library.WriteErrorLog("receiving request for " + response.Response, "PublisherLogFile");
    } 

My second Windows Service that receives the request and sends a response back looks like this:

protected override void OnStart(string[] args)
{
    Library.WriteErrorLog("Report Subscriber Service started", "SubscriberLogFile");

    // Initialize the bus
    this.bus = RabbitHutch.CreateBus("host=localhost;timeout=120");

    this.bus.Respond<ReportData, TestResponse>(this.Response);

}

protected override void OnStop()
{
    Library.WriteErrorLog("Exiting Report Subscribe Service", "SubscriberLogFile");

    this.bus.Dispose();
}

private TestResponse Response(ReportData request)
{
    int clientId = request.clientId;
    int incidentId = request.incidentId;
    string clientName = request.clientName;
    string clientNetworkPath = request.clientNetworkPath;
    string formatDescription = request.formatDescription;
    string reportFormat = request.reportFormat;

    Library.WriteErrorLog("Received report request for clientId: " + clientId + ", incident Id: " + incidentId + ", client: " + clientName + ", clientNetworkPath: " + clientNetworkPath + ", format description: " + formatDescription + ", and format: " + reportFormat, "SubscriberLogFile");

    return new TestResponse { Response = " ***** Response to Request ***** "     };

And that's all. After I run this I get this exception:

System.AggregateException: One or more errors occurred. ---> System.TimeoutException: Request timed out. CorrelationId: 6efb3905-c2a2-4482-a758-a8ba42a5b4c4
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at EasyNetQ.RabbitBus.Request[TRequest,TResponse](TRequest request)
   at CMR.Messaging.PublisherService.CreateRequestService.Test(ReportData1 reportData1) in    ..CreateRequestService.cs:line 63
   at EasyNetQ.RabbitBus.<>c__DisplayClassc`1.<>c__DisplayClasse.<Subscribe>b__b()
   at EasyNetQ.Internals.TaskHelpers.ExecuteSynchronously(Action action)
   --- End of inner exception stack trace ---

Line 63 is this:

var response = this.bus.Request<ReportData, TestResponse>(data1);

My PublisherLogFile:

06/06/2016 13:49:57: Report Publish Service started
06/06/2016 13:50:14: 4 report requests found.
06/06/2016 13:50:14: Sending request for Client Id: 1 and Incident Id: 12345

And the SubscriberLogFile:

06/06/2016 13:49:55: Report Subscriber Service started
06/06/2016 13:50:14: Received report request for clientId: 1, incident Id: 12345, client: ABC, clientNetworkPath: \\Client Files\ABC\, format description: Image, and format: TIFF

So it looks like the request is received and a response is sent back, but then nothing happens. I just get an error in the RabbitMQ Management Console. Why am I getting this error?

lukegf
  • 2,147
  • 3
  • 26
  • 39

0 Answers0