How does .Net(C#) Consumer obtain MessageID value? Tks.

hkszlq
hkszlq Member Posts: 8

No "MessageID" properties in SolaceSystems.Solclient.Messaging.IMessage.

According to the documentation: This field is generated by the Solace platform and cannot be changed by the sending application

I can saw messageID on the Solace message management site , messageID value is "18943221297"
But I don’t know how to get this value
:s

Comments

  • hkszlq
    hkszlq Member Posts: 8

    messageID value is "18943221297"
    But I don’t know how to get this value,The site picture is as follows:

  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 636 admin

    hi @hkszlq . The value that you see inside the broker in your screenshot there is a sequence number the Persistent pipeline automatically assigns. I believe it corresponds to IMessage.ADMessageId. https://docs.solace.com/API-Developer-Online-Ref-Documentation/net/html/caa03c8f-8dee-bd5b-3a72-ae65fb35de72.htm

    You can't/shouldn't rely on this number or use it for anything other than acknowledging messages. It's just for "internal" broker-to-API use. It is shared across all queues/consumers/Message VPNs on the broker, so don't try to infer anything from it.

    If you (the application) needs a message ID of some sort, for sequencing or uniqueness or whatever, your publisher should insert either a SequenceNumber (Long) or a ApplicationMessageId (String). Those are the usual candidates for adding some identifiers to your published messages.

  • hkszlq
    hkszlq Member Posts: 8

    Tks for your reply.
    We have obtained all the message attribute values. ADmessageID is not the messageid displayed on the management site. I don't know the reason.
    Because according to the test case, we need to obtain this messageID.

    07:13:36.436 [DBG AspNetCoreSolaceDemo.WebSocketMiddleware] PublishMessage result: SUCCESS
    07:13:36.437 [DBG SolaceSystemsService.QueueConsumer] Received message.
    07:13:36.437 [DBG SolaceSystemsService.QueueConsumer] Message Details: {{{{{
    07:13:36.437 [DBG SolaceSystemsService.QueueConsumer] CorrelationKey =
    07:13:36.438 [DBG SolaceSystemsService.QueueConsumer] UserPropertyMap =
    07:13:36.438 [DBG SolaceSystemsService.QueueConsumer] BinaryAttachment = System.Byte[]
    07:13:36.439 [DBG SolaceSystemsService.QueueConsumer] UserData =
    07:13:36.439 [DBG SolaceSystemsService.QueueConsumer] XmlContent =
    07:13:36.440 [DBG SolaceSystemsService.QueueConsumer] Destination = Topic=[ name: v1/********nn/-/pub , IsReceiveAllDeliverToOne: False , Temporary: False ]
    07:13:36.440 [DBG SolaceSystemsService.QueueConsumer] ReplyTo =
    07:13:36.441 [DBG SolaceSystemsService.QueueConsumer] DeliveryMode = NonPersistent
    07:13:36.441 [DBG SolaceSystemsService.QueueConsumer] UserCos = Cos1
    07:13:36.441 [DBG SolaceSystemsService.QueueConsumer] DiscardIndication = False
    07:13:36.442 [DBG SolaceSystemsService.QueueConsumer] Redelivered = False
    07:13:36.442 [INF SolaceSystemsService.SolaceMsgService] [7/27/2021 7:13:36 AM][Info][Sdk] solClient.c:12864 (7f634a9c9700) solClient_bufInfo_getConsumerIdCount called
    07:13:36.442 [DBG SolaceSystemsService.QueueConsumer] ConsumerIdList =
    07:13:36.443 [DBG SolaceSystemsService.QueueConsumer] DeliverToOne = False
    07:13:36.443 [DBG SolaceSystemsService.QueueConsumer] ADMessageId = 1
    07:13:36.444 [DBG SolaceSystemsService.QueueConsumer] CorrelationId =
    07:13:36.444 [DBG SolaceSystemsService.QueueConsumer] SenderId =
    07:13:36.444 [DBG SolaceSystemsService.QueueConsumer] ReceiverTimestamp = -1
    07:13:36.445 [DBG SolaceSystemsService.QueueConsumer] SenderTimestamp = 1627370016434
    07:13:36.445 [DBG SolaceSystemsService.QueueConsumer] SequenceNumber =
    07:13:36.445 [DBG SolaceSystemsService.QueueConsumer] TopicSequenceNumber =
    07:13:36.446 [DBG SolaceSystemsService.QueueConsumer] ApplicationMessageId =
    07:13:36.446 [DBG SolaceSystemsService.QueueConsumer] ApplicationMessageType =
    07:13:36.447 [DBG SolaceSystemsService.QueueConsumer] CacheRequestId = -1
    07:13:36.447 [DBG SolaceSystemsService.QueueConsumer] CacheStatus = Live
    07:13:36.447 [DBG SolaceSystemsService.QueueConsumer] IsReplyMessage = False
    07:13:36.447 [DBG SolaceSystemsService.QueueConsumer] Expiration = 0
    07:13:36.448 [DBG SolaceSystemsService.QueueConsumer] TimeToLive = 0
    07:13:36.448 [DBG SolaceSystemsService.QueueConsumer] DMQEligible = False
    07:13:36.448 [DBG SolaceSystemsService.QueueConsumer] ElidingEligible = False
    07:13:36.449 [DBG SolaceSystemsService.QueueConsumer] AckImmediately = False
    07:13:36.449 [DBG SolaceSystemsService.QueueConsumer] Priority = 4
    07:13:36.450 [DBG SolaceSystemsService.QueueConsumer] ReplicationGroupMessageId =
    07:13:36.451 [DBG SolaceSystemsService.QueueConsumer] HttpContentType =
    07:13:36.451 [DBG SolaceSystemsService.QueueConsumer] HttpContentEncoding =
    07:13:36.451 [DBG SolaceSystemsService.QueueConsumer] Message Details: }}}}}

    TestCase:


  • Ragnar
    Ragnar Member, Employee Posts: 65 Solace Employee
    edited August 2021 #5

    The JMS MessageID is a field in the JMS header generated by JMS Producers. As such it is considered 'meta' data and part of the payload of Solace messages. It is not visible in the broker management interfaces. It is not the ADMessageId.

    In general the ADMessageID should not be extracted and in future releases of the API it may be deprecated. This number is not useful on it's own and may or may not match the message ID displayed in the broker, depending on the transport characteristics.

    In .NET the JMS MessageID is known as the 'ApplicationMessageId'.

    string ApplicationMessageId { get; set; }

  • hkszlq
    hkszlq Member Posts: 8

    @Ragnar said:
    The JMS MessageID is a field in the JMS header generated by JMS Producers. As such it is concerted 'meta' data and part of the payload of Solace messages. It is not visible in the broker management interfaces. It is not the ADMessageId.

    In general the ADMessageID should not be extracted and in future releases of the API it may be deprecated. This number is not useful on it's own and may or may not match the message ID displayed in the broker, depending on the transport characteristics.

    In .NET the JMS MessageID is known as the 'ApplicationMessageId'.

    string ApplicationMessageId { get; set; }

    Thank you Ragnar.

    Can’t I get the value of MessageID in the picture?

  • hkszlq
    hkszlq Member Posts: 8

    @hkszlq said:

    @Ragnar said:
    The JMS MessageID is a field in the JMS header generated by JMS Producers. As such it is concerted 'meta' data and part of the payload of Solace messages. It is not visible in the broker management interfaces. It is not the ADMessageId.

    In general the ADMessageID should not be extracted and in future releases of the API it may be deprecated. This number is not useful on it's own and may or may not match the message ID displayed in the broker, depending on the transport characteristics.

    In .NET the JMS MessageID is known as the 'ApplicationMessageId'.

    string ApplicationMessageId { get; set; }

    Thank you Ragnar.

    Can’t I get the value of MessageID in the picture?

    The following is the reference document description

  • Ragnar
    Ragnar Member, Employee Posts: 65 Solace Employee

    I'm sorry to say that table is misleading. There is no relationship between ApplicationMessageId (aka JMS MessageId) and the 'ADMessageId'. The ApplicationMessageId is whatever string that is set by the publishing applications. The JMS API has the ability to auto-generate this field.

    While the broker does generate a unique ID for each message stored on the broker, that messageId, which you see in the broker admin interface, is not available through the APIs.

    The ADMessageId in CSCSMP is simply a transport acknowledgment number and internal to the API/broker protocol and not useful. This is why in a future release it will be deprecated, as the application simply calls 'IMessage.ack()' to remove a message from the broker and does not need to know the transport acknowledgement number.

  • hkszlq
    hkszlq Member Posts: 8

    @Ragnar said:
    I'm sorry to say that table is misleading. There is no relationship between ApplicationMessageId (aka JMS MessageId) and the 'ADMessageId'. The ApplicationMessageId is whatever string that is set by the publishing applications. The JMS API has the ability to auto-generate this field.

    While the broker does generate a unique ID for each message stored on the broker, that messageId, which you see in the broker admin interface, is not available through the APIs.

    The ADMessageId in CSCSMP is simply a transport acknowledgment number and internal to the API/broker protocol and not useful. This is why in a future release it will be deprecated, as the application simply calls 'IMessage.ack()' to remove a message from the broker and does not need to know the transport acknowledgement number.

    Thanks for your reply

  • hkszlq
    hkszlq Member Posts: 8

    excuse me. I have one more question for you, why can’t be assigned to the correlationId attribute in the request response mode, the code has already given the value, but the value is always: #SOL1

    Testcase:

    run result:

  • Ragnar
    Ragnar Member, Employee Posts: 65 Solace Employee

    Hello. I've been away and you may have solved this already.

    The CorrelationID in request/response is used to map the response to the original request. solClient_session_sendRequest automatically sets this to a easy to parse but unique string (#SOLnnn) for each request. Then the sending session can easily and quickly, which is the important part, scan all incoming messages for the response to the request.

    __solClient_session_sendReply_ automatically retrieves the correlationId from the request message, and the reply-to topic, and populates the reply message with these values so the reply get to the right place.

    The application cannot override correlationId, and if it were able to do so, request-reply would not work.

  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 636 admin
    edited August 2021 #12

    If you send multiple messages, you should see that value increase, the autogenerated Correlation ID. It's not always #SOL1.

    You can actually override/set the correlation ID if you want, but I think it gets overwritten if you use the convenience feature ISession.SentRequest().