# Custom message identifier - sequenceNumber vs applicationMessageId

**URL:** <https://community.solace.com/t/custom-message-identifier-sequencenumber-vs-applicationmessageid/419>\
**Category:** Training, Tips and Tricks\
**Created:** [September 28, 2020, 1:29pm UTC](https://community.solace.com/t/custom-message-identifier-sequencenumber-vs-applicationmessageid/419 "2020-09-28T13:29:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/solace/original/1X/1248f38eea018157e66cc024e8284f3331a54f94.png) [@system](https://community.solace.com/u/system)\
**Post date:** [September 28, 2020, 1:29pm UTC](https://community.solace.com/t/custom-message-identifier-sequencenumber-vs-applicationmessageid/419/1 "2020-09-28T13:29:28Z")

</div>

Recently I had a requirement to specify a unique identifier for each message that I was publishing to the broker. When inspecting the API reference, I found that there are two fields that can be used for this purpose - the applicationMessageId and the sequenceNumber on the message. Both are similar but have some subtle differences:

- Both fields when set on a message will propagate through to the consumer and can be retrieved via their appropriate getter method
- The “sequenceNumber” takes an unsigned int as an argument hence is useful when your identifier is a number. The “applicationMessageId” takes a char \* and hence is useful when you want to specify a GUID
- The “applicationMessageId” is a string that also corresponds to JMSMessageID. You can use this if you have a JMS consumer and want the message identifier to be available in the JMSMessageID field.
- The message-sequence number can be automatically set by the Solace API for you - you can do this by enabling the session property SOLCLIENT\_SESSION\_PROP\_GENERATE\_SEQUENCE\_NUMBER. However, if the application specifies a custom sequence number with solClient\_msg\_setSequenceNumber, solClient\_msg\_setSequenceNumber will take precedence.
- Finally if you do not want to use any of these fields, you can always define a custom header for your message and set the message identifier in that!

In any case, these identifiers are independant of the internal message-id that the Solace broker adds to each message received, to ensure that messages are delivered to consumers in the same sequence that they are received by the broker.
