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 ?