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 config 18 19 // ReceiverPropertiesConfigurationProvider describes the behavior of a configuration provider 20 // that provides properties for receivers. 21 type ReceiverPropertiesConfigurationProvider interface { 22 GetConfiguration() ReceiverPropertyMap 23 } 24 25 // ReceiverProperty is a property that can be set on a receiver. 26 type ReceiverProperty string 27 28 // ReceiverPropertyMap is a map of ReceiverProperty keys to values. 29 type ReceiverPropertyMap map[ReceiverProperty]interface{} 30 31 // GetConfiguration returns a copy of the ReceiverPropertyMap. 32 func (receiverPropertyMap ReceiverPropertyMap) GetConfiguration() ReceiverPropertyMap { 33 ret := make(ReceiverPropertyMap) 34 for key, value := range receiverPropertyMap { 35 ret[key] = value 36 } 37 return ret 38 } 39 40 // MarshalJSON implements the json.Marshaler interface. 41 func (receiverPropertyMap ReceiverPropertyMap) MarshalJSON() ([]byte, error) { 42 m := make(map[string]interface{}) 43 for k, v := range receiverPropertyMap { 44 m[string(k)] = v 45 } 46 return nestJSON(m) 47 } 48 49 // UnmarshalJSON implements the json.Unmarshaler interface. 50 func (receiverPropertyMap ReceiverPropertyMap) UnmarshalJSON(b []byte) error { 51 m, err := flattenJSON(b) 52 if err != nil { 53 return err 54 } 55 for key, val := range m { 56 receiverPropertyMap[ReceiverProperty(key)] = val 57 } 58 return nil 59 } 60 61 const ( 62 // ReceiverPropertyDirectBackPressureStrategy defines a direct receiver back pressure strategy. 63 // Valid values are BUFFER_DROP_LATEST_WHEN_FULL where the latest incoming message is dropped 64 // or BUFFER_DROP_OLDEST_WHEN_FULL where the oldest undelivered message is dropped. 65 ReceiverPropertyDirectBackPressureStrategy ReceiverProperty = "solace.messaging.receiver.direct.back-pressure.strategy" 66 67 // ReceiverPropertyDirectBackPressureBufferCapacity defines the direct receiver back pressure buffer capacity 68 // measured in messages. This property only has effect in conjunction with the back pressure strategy. 69 ReceiverPropertyDirectBackPressureBufferCapacity ReceiverProperty = "solace.messaging.receiver.direct.back-pressure.buffer-capacity" 70 71 // ReceiverPropertyPersistentMissingResourceCreationStrategy specifies if and how missing remote resource (such as queues) are to be created 72 // on a broker prior to receiving persistent messages. Valid values are of type MissingResourceCreationStrategy, either 73 // MissingResourceDoNotCreate or MissingResourceCreateOnStart. 74 ReceiverPropertyPersistentMissingResourceCreationStrategy ReceiverProperty = "solace.messaging.receiver.persistent.missing-resource-creation-strategy" 75 76 // ReceiverPropertyPersistentMessageSelectorQuery specifies the message-selection query based on the message header parameter 77 // and message properties values. When a selector is applied then the receiver receives only 78 // messages whose headers and properties match the selector. A message selector cannot select 79 // messages on the basis of the content of the message body. 80 ReceiverPropertyPersistentMessageSelectorQuery ReceiverProperty = "solace.messaging.receiver.persistent.selector-query" 81 82 // ReceiverPropertyPersistentStateChangeListener specifies to use the callback ReceiverStateChangeListener and enable 83 // activation and passivation support. 84 ReceiverPropertyPersistentStateChangeListener ReceiverProperty = "solace.messaging.receiver.persistent.state-change-listener" 85 86 // ReceiverPropertyPersistentMessageAckStrategy specifies the acknowledgement strategy for the message receiver. 87 ReceiverPropertyPersistentMessageAckStrategy ReceiverProperty = "solace.messaging.receiver.persistent.ack.strategy" 88 89 // ReceiverPropertyPersistentMessageReplayStrategy enables message replay and to specify a replay strategy. 90 ReceiverPropertyPersistentMessageReplayStrategy ReceiverProperty = "solace.messaging.receiver.persistent.replay.strategy" 91 92 // ReceiverPropertyPersistentMessageReplayStrategyTimeBasedStartTime configures time-based replay strategy with a start time. 93 ReceiverPropertyPersistentMessageReplayStrategyTimeBasedStartTime ReceiverProperty = "solace.messaging.receiver.persistent.replay.timebased-start-time" 94 95 // ReceiverPropertyPersistentMessageReplayStrategyIDBasedReplicationGroupMessageID configures the ID based replay strategy with a specified replication group message ID. 96 ReceiverPropertyPersistentMessageReplayStrategyIDBasedReplicationGroupMessageID ReceiverProperty = "solace.messaging.receiver.persistent.replay.replication-group-message-id" 97 ) 98