1 // pubsubplus-go-client 2 // 3 // Copyright 2021-2024 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 // InboundMessage represents a message received by a consumer. 26 type InboundMessage interface { 27 // Extend the Message interface. 28 Message 29 30 // GetDestinationName retrieves the destination name on which the message was received. 31 // The destination may be either a topic or a queue. 32 // An empty string is returned if the information is not available. 33 GetDestinationName() string 34 35 // GetTimeStamp retrieves the timestamp as time.Time. 36 // This timestamp represents the time that the message was received by the API. 37 // This may differ from the time that the message is received by the MessageReceiver. 38 GetTimeStamp() (timestamp time.Time, ok bool) 39 40 // GetSenderTimestamp retrieves the timestamp as time.Time. 41 // This timestamp is often set automatically when the message is published. 42 GetSenderTimestamp() (senderTimestamp time.Time, ok bool) 43 44 // GetSenderID retrieves the sender's ID. This field can be set automatically during 45 // message publishing, but existing values are not overwritten if not empty, for example 46 // if the message is sent multiple times. 47 // Returns the sender's ID and a boolean indicating if it was set. 48 GetSenderID() (senderID string, ok bool) 49 50 // GetReplicationGroupMessageID retrieves the Replication Group Message ID. 51 // Returns an empty string and false if no Replication Group Message ID is set on the 52 // message (for example, direct messages or unsupported broker versions) 53 GetReplicationGroupMessageID() (replicationGroupMessageID rgmid.ReplicationGroupMessageID, ok bool) 54 55 // GetMessageDiscardNotification retrieves the message discard notification about 56 // previously discarded messages. Returns a MessageDiscardNotification and is not expected 57 // to be nil. 58 GetMessageDiscardNotification() MessageDiscardNotification 59 60 // IsRedelivered retrieves the message's redelivery status. Returns true if the message 61 // redelivery occurred in the past, otherwise false. 62 IsRedelivered() bool 63 } 64 65 // MessageDiscardNotification is used to indicate that there are discarded messages. 66 type MessageDiscardNotification interface { 67 // HasBrokerDiscardIndication determines whether the broker has discarded one 68 // or more messages prior to the current message. 69 // Returns true if messages (one or more) were previously discarded by the broker, 70 // otherwise false. 71 HasBrokerDiscardIndication() bool 72 73 // HasInternalDiscardIndication determines if the API has discarded one or more messages 74 // prior to the current message (i.e., in a back-pressure situation). 75 // Returns true if messages (one or more) were previously discarded by the API, otherwise false. 76 HasInternalDiscardIndication() bool 77 } 78