locked
How to send synchronous message to the service? RRS feed

  • Question

  • Hi All!

    I'm using CSF 3.0 Developer Edition Full.

    I've tried to send a synchronous message from one servcie to another through a CSF session, but it hasn't worked. On this forum I read, that CSF doesn't support synchronous exchange between services, but there wasn't explanation why. And in the development guide it is said that synchronous exchange is possible.

    Here is my code:

    Header header = new Header();
    header.Addressing = new Microsoft.ConnectedServices.Sdk.Addressing.AddressingHeaders(MyURI);
    header.Addressing.To = SessionUri;
    header.CsfProperties.SessionId = SessionId;

    header.Addressing.Action = MyAction;

    Message request = Message.CreateMessage(header, MyRequestType);

    MyResponseType response = sender.SendSync<MyResponseType>(request);

    What is wrong?
    Does anybody know how to send synchronous message to the service from another service through CSF session? Or is it impossible?

    Thank you in advance.
    Friday, October 6, 2006 10:02 AM

Answers

  • Hello - There are architectural reasons why we designed the Route Message as an Asynchronous API. The primary reason being, the participating services could take days to respond back to Session. Session cannot wait for such a long time to deliver the response synchronously. That approach will quickly exhaust the resources in Session.

    We understand your concern and that's the reason why we have shipped a sample which explains how to achieve this. Please take a look at the Sync Session sample. That will give you an idea on how to achieve this.

    Thanks

    Thursday, October 12, 2006 5:18 AM

All replies

  • Hi Vova,

    Let me share my understanding. When you try to send a syncronous message to another service through CSF session, you typically set a Action, and when CSF session receives your message, it examines the (Soap)Action in the message and routes the message to the sevice for which criteria evaluates to true (the channel used for sending this initial message is kept open as it is a syncronous call).

    Now when the second service receives this message, it sends back response to CSF Session, but with its own Action (typically MethodNameResponse). When CSF Session intercepts this response from second service, it will route this message to the participant for which routing critiria evaluates to true. And here the syncronus call you made in begining will never get any response as the response sent by CSF session will be on a different channel.

    To make sure that CSF returned a response, you can check the _OutputTrace.webconfig file. 

    I think synshronous messaging works only when two services interact directly and not through CSF Session.

    Thanks,

    Ashish Malhotra

     

     

     

    Monday, October 9, 2006 4:05 AM
  • Hello Vova,

    The code you have implemented is perfectly fine.

    But I want you to go through the following check lists:

    1. Check whether the service returns void or MyResponseType. sender.SendSync works when the function returns some object other than void.
    2. Does the end service use any policies? If yes, then you need to send security tokens to the end service.
    3. Also enable trace in Session service. Modify its web.config file to enable input and output trace. If possible implement traces in the end service as well.

    I hope that would help you in tracking the solution to the problem.

    Regards,

    Vikram

    Monday, October 9, 2006 5:28 AM
  • Hi Ashish,

    Seems your considerations are correct.

    I've performed some additional tests. Here are my results:
    1. In the session traces all responses are present.
    2. Synchronous messages works well, if service interacts directly with another service.

    Thank you for explanation.

    It's very strange that CSF doesn't support synchronous calls through a session, because sometimes it is very useful.
    Does Microsoft have plans to add this functionality in the future releases of the CSF. Does anybody know?

    Monday, October 9, 2006 2:43 PM
  • Hello - There are architectural reasons why we designed the Route Message as an Asynchronous API. The primary reason being, the participating services could take days to respond back to Session. Session cannot wait for such a long time to deliver the response synchronously. That approach will quickly exhaust the resources in Session.

    We understand your concern and that's the reason why we have shipped a sample which explains how to achieve this. Please take a look at the Sync Session sample. That will give you an idea on how to achieve this.

    Thanks

    Thursday, October 12, 2006 5:18 AM