1 // pubsubplus-go-client 2 // 3 // Copyright 2021-2025 Solace Corporation. All rights reserved. 4 // 5 // Licensed under the Apache License, Version 2.0 (the "License"); 6 // you may not use this file except in compliance with the License. 7 // You may obtain a copy of the License at 8 // 9 // http://www.apache.org/licenses/LICENSE-2.0 10 // 11 // Unless required by applicable law or agreed to in writing, software 12 // distributed under the License is distributed on an "AS IS" BASIS, 13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 // See the License for the specific language governing permissions and 15 // limitations under the License. 16 17 package message 18 19 import ( 20 "time" 21 22 "solace.dev/go/messaging/pkg/solace/message/rgmid" 23 ) 24 25 // CacheStatus indicates whether or not a message was received as a part of a cache response 26 // and if it was, what kind of cache response. 27 // Refer to the documentation of each variant for more details. 28 type CacheStatus int 29 30 const ( 31 // The message was received independent of any cache response. 32 Live CacheStatus = iota 33 34 // The message was received as a part of a cache response from a trusted cache. 35 Cached 36 37 // The message was received as a part of a cache response from a suspect cache. 38 Suspect 39 ) 40 41 // CacheRequestID - a type to be used for correlating received, 42 // previously cached messages with their associated cache response. 43 type CacheRequestID uint64 44 45 // InboundMessage represents a message received by a consumer. 46 type InboundMessage interface { 47 // Extend the Message interface. 48 Message 49 50 // GetDestinationName retrieves the destination name on which the message was received. 51 // The destination may be either a topic or a queue. 52 // An empty string is returned if the information is not available. 53 GetDestinationName() string 54 55 // GetTimeStamp retrieves the timestamp as time.Time. 56 // This timestamp represents the time that the message was received by the API. 57 // This may differ from the time that the message is received by the MessageReceiver. 58 GetTimeStamp() (timestamp time.Time, ok bool) 59 60 // GetSenderTimestamp retrieves the timestamp as time.Time. 61 // This timestamp is often set automatically when the message is published. 62 GetSenderTimestamp() (senderTimestamp time.Time, ok bool) 63 64 // GetSenderID retrieves the sender's ID. This field can be set automatically during 65 // message publishing, but existing values are not overwritten if not empty, for example 66 // if the message is sent multiple times. 67 // Returns the sender's ID and a boolean indicating if it was set. 68 GetSenderID() (senderID string, ok bool) 69 70 // GetReplicationGroupMessageID retrieves the Replication Group Message ID. 71 // Returns an empty string and false if no Replication Group Message ID is set on the 72 // message (for example, direct messages or unsupported broker versions) 73 GetReplicationGroupMessageID() (replicationGroupMessageID rgmid.ReplicationGroupMessageID, ok bool) 74 75 // GetMessageDiscardNotification retrieves the message discard notification about 76 // previously discarded messages. Returns a MessageDiscardNotification and is not expected 77 // to be nil. 78 GetMessageDiscardNotification() MessageDiscardNotification 79 80 // IsRedelivered retrieves the message's redelivery status. Returns true if the message 81 // redelivery occurred in the past, otherwise false. 82 IsRedelivered() bool 83 84 // GetCacheRequestID retrieves the [CacheRequestID] of the message 85 // and a [True] result if the message was received as a part of a 86 // cache response. Otherwise, returns 0 and False. 87 GetCacheRequestID() (CacheRequestID, bool) 88 89 // GetCacheStatus retrieves the [CacheStatus] of the message, indicating its provenance. 90 GetCacheStatus() CacheStatus 91 } 92 93 // MessageDiscardNotification is used to indicate that there are discarded messages. 94 type MessageDiscardNotification interface { 95 // HasBrokerDiscardIndication determines whether the broker has discarded one 96 // or more messages prior to the current message. 97 // Returns true if messages (one or more) were previously discarded by the broker, 98 // otherwise false. 99 HasBrokerDiscardIndication() bool 100 101 // HasInternalDiscardIndication determines if the API has discarded one or more messages 102 // prior to the current message (i.e., in a back-pressure situation). 103 // Returns true if messages (one or more) were previously discarded by the API, otherwise false. 104 HasInternalDiscardIndication() bool 105 } 106