Request timeout error for Request/Response model

855 views
Skip to first unread message

chaitanya bhatt

unread,
May 14, 2012, 9:14:19 AM5/14/12
to masstransit-discuss
Hello,

I have to implement Request/Response model using MassTransit. I got
following link from docs for same :-
http://readthedocs.org/docs/masstransit/en/develop/overview/request.html

But i am getting error of request timeout every time.
Here is my code :-

BasicRequest :-
public class BasicRequest : CorrelatedBy<Guid>
{
public Guid CorrelationId { get; set; }
public string Text { get; set; }
}

BasicResponse :-
public class BasicResponse : CorrelatedBy<Guid>
{
public Guid CorrelationId { get; set; }
public string Text { get; set; }
}

Responder :-
Bus.Initialize(sbc =>
{
sbc.UseMsmq();
sbc.VerifyMsmqConfiguration();
sbc.UseMulticastSubscriptionClient();
sbc.ReceiveFrom("msmq://localhost/message_responder");
sbc.Subscribe(subs =>
{
subs.Handler<BasicRequest>(msg =>
Bus.Instance.MessageContext<BasicRequest>().Respond(new BasicResponse
{ Text = "RESP" + msg.Text }));
});
});

Requester :-
Bus.Initialize(sbc =>
{
sbc.UseMsmq();
sbc.VerifyMsmqConfiguration();
sbc.UseMulticastSubscriptionClient();
sbc.ReceiveFrom("msmq://localhost/message_requestor");
});

Bus.Instance.PublishRequest(new BasicRequest()
{ CorrelationId = Guid.NewGuid() }, x =>
{
x.Handle<BasicResponse>(message =>
Console.WriteLine(message.Text));
x.SetTimeout(30.Seconds());
});

Error :-
The request timed out: 08ceffea-50b7-b9e7-18f4-6ae60c700000

StackTrace :-
at MassTransit.RequestResponse.RequestImpl`1.Wait()
at MassTransit.RequestResponseExtensions.PublishRequest[TRequest]
(IServiceBus bus, TRequest message, Action`1 configureCallback)
at Requester.Program.Main(String[] args) in C:\Projects\MassTransit
\RequestResponseTest\ConsoleApplication1\Requester\Program.cs:line 23
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly,
String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()


Can you please guide me what is missing in this code ?

Dru Sellers

unread,
May 14, 2012, 9:44:23 AM5/14/12
to masstrans...@googlegroups.com
In your 'responder'

try using the message context instead.

sbc.Subscribe(subs =>
{
    subs.Handler<IConsumeContext<BasicRequest>>(cxt =>
    {
        cxt.Respond(new BasicResponse{ Text = "RESP" + msg.Text }));
    });
});




--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstrans...@googlegroups.com.
To unsubscribe from this group, send email to masstransit-dis...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/masstransit-discuss?hl=en.


chaitanya bhatt

unread,
May 14, 2012, 2:16:17 PM5/14/12
to masstrans...@googlegroups.com
Thanks for your response.

I tried your suggestion but it still throwing same error.

Here is responder code look now :
Bus.Initialize(sbc =>
            {
                sbc.UseMsmq();
                sbc.VerifyMsmqConfiguration();
                sbc.UseMulticastSubscriptionClient();
                sbc.ReceiveFrom("msmq://localhost/message_responder"
);
                sbc.Subscribe(subs =>
                {
                    subs.Handler<IConsumeContext<BasicRequest>>(cxt => {
                        cxt.Respond(new BasicResponse() { Text = "RESP" + cxt.Message.Text });
                    });
                });
            });

Please guide on what is missing here.


Thanks & Regards
Chaitanya Bhatt

schaibaa

unread,
May 14, 2012, 4:51:44 PM5/14/12
to masstransit-discuss
Are you on different machines? Try using .SetNetwork - I had that
issue with MSMQ

chaitanya bhatt

unread,
May 15, 2012, 12:52:34 AM5/15/12
to masstrans...@googlegroups.com
Requester & Responder both are on same machine. So i think no need to do set network, right ?

Dru Sellers

unread,
May 15, 2012, 9:17:36 AM5/15/12
to masstrans...@googlegroups.com
That's correct.

Do you have a sample project on github that we can pull down and run? Due to the complexity of what we are trying to achieve this is often times the easiest way to go about it.

-d

Chris Patterson

unread,
May 15, 2012, 12:39:25 PM5/15/12
to masstrans...@googlegroups.com
sub.Handler<BasicRequest>((context, message) => context.Respond());

Is the proper syntax, not Handler<IConsumeContext<BasicRequest>>()...

Dru Sellers

unread,
May 15, 2012, 3:04:18 PM5/15/12
to masstrans...@googlegroups.com
my bad, thanks Chris,

-d
Reply all
Reply to author
Forward
0 new messages