MSMQBusAdapter and Message ID

KABOUTERKABOUTER Member Posts: 30
I have to get the message ID from a message sent to a Navision MSMQ-BA queue and then send a reply message including this ID. It seems CPHandler OR MSMQBusAdapter cant handle this. Is there anybody that can help?

Comments

  • IHateLinuxIHateLinux Member Posts: 223
    Hi,

    sorry but i do not fully understand what you try to do.
    MSMQBusAdapter will always send a reply message and set the property correlation id to the previously incoming message.

    Sample:
    Web Service with MSMQ writing
    Service writes to Job Queue and therefore knows the message id, NAS picks up message with MSMQBusAdapter, NAS will process the message and if you use the MSMQBus to reply, the property correlation id of the outgoing message is set to the id of the incoming message. The WebService can now look in the reply queue, waiting for a response message where the correlation id is the same as the message id he sent out.

    HTH,
    Rainer
  • KABOUTERKABOUTER Member Posts: 30
    I have an ASP.NET application that sends me a message to private queue "tonavision", body is in XML format. This application expects a reply from NAS and MQBus with the SAME id than the id it was sent with, but it goes into a different private queue "fromnavision".

    How do I know that the id of the message sent to navision is the same as the id of the message sent from navision? Since messaging works on the basis of first in first out, it is important that the ASP application picks up the exact reply message for the one that was sent.
  • IHateLinuxIHateLinux Member Posts: 223
    Hi,

    this is exactly the way with using the correlation id. You can not set the message id itself, this is determined by the system (readonly property). The only way to identify a reply is:
    a.) Putting a GUID inside of the message and peeking on the reply queue (this is how Commerce Portal is working)
    CON: Very slow, because every message has to be peeked

    b.) Putting a GUID in the message label
    Set the message label to a guid and peek just the messages with the corresponding label
    CON: You can not use MSMQBusAdapter because it is expecting a specific label

    c.) Using the correlation id
    As mentioned in my primary post, MSMQBusAdapter is setting the property CorrelationID of the outgoing/reply message. So you just have to save the message id (of the message that is sent to Navision) and peek for the message in the private queue which that id as correlation id.

    If you need any further assistance, just post your question.

    HTH,
    Rainer
  • KABOUTERKABOUTER Member Posts: 30
    I have tried again but the message id sent from the ASP application and the correlationid returned by NAS and MQAdapter is not the same.

    Example

    ASP Application sends request to navision :

    while(mqResponse.PeekByCorrelationId(messageID,new TimeSpan(0,0,10)) != null)
    {
    message = mqResponse.ReceiveByCorrelationId(messageID);

    found = true;
    }

    Navision responds on this specific message sent by ASP and returns a message with some xml content. When I look at the queue, I notice that the last 5 digits (after the "\") is not the same than the message sent to Navision.

    I am 100% sure that Navision is responding to that exact same message. WHY is the ID not the same, or am I perhaps looking at the wrong ID?
    Example - ASP sends message with id "{366CCE75-1EEC-4530-89EC-29605869C9ED}\53254" and Navision returns message with ID
    "{366CCE75-1EEC-4530-89EC-29605869C9ED}\53268".
    Why are the the last 5 digits not the same? Is there any way I can SET this with using Navision MQAdaptor and NAS when responding to ASP application?

    Thanks for your help so far.
  • IHateLinuxIHateLinux Member Posts: 223
    Hi,

    as i said before, the message ID will always be different.

    When you open Computer Management -> Service and Application -> Message Queuing -> Private Queues -> YOURQUEUE
    you can add a column in the view to display the Correlation.

    What do you see there?

    Thanks.

    Rainer
  • KABOUTERKABOUTER Member Posts: 30
    When I do what you've described here, I have nothing in the "Available" columns List, and only "Name" in the "Displayed" columns list.

    Please help.
  • IHateLinuxIHateLinux Member Posts: 223
    Hi,

    what OS do you use on the web app server and where are the queues?

    Rainer
  • KABOUTERKABOUTER Member Posts: 30
    Currently I am running everything on one PC for testing : XP Pro SP2 (NAS, Navision Server, using Private QUeues (no active directory), ASP application, IIS. All on MBS Navision 4.0 latest release).
Sign In or Register to comment.