message

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2022 License: Apache-2.0 Imports: 3 Imported by: 5

Documentation

Overview

Package message contains the type definitions of InboundMessage and OutboundMessage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Disposable

type Disposable interface {
	// Dispose frees all the underlying resources of the Disposable instance.
	// Dispose is idempotent, and removes any redundant finalizers on the
	// instance and substantially improves garbage-collection performance.
	// This function is thread-safe, and subsequent calls to Dispose
	// block and wait for the first call to complete. Additional calls
	// return immediately. The instance is considered unusable after Dispose
	// has been called.
	Dispose()

	// IsDisposed checks if the Disposable instance has been disposed by
	// a call to Dispose. IsDisposeed returns true if Dispose has been called,
	// otherwise false if it is still usable. Dispose may or may not have returned.
	// The instance is considered unusable if IsDisposed returns true.
	IsDisposed() bool
}

Disposable implies that the implementing data structure needs to free the underlying resources. This is done with the Dispose function. It is optional to use this function to free the underlying resources because any implementing data structure must attempt to free the underlying resources using a finalizer. For performance purposes, we recommend to explicitly free the underlying resources before garbage collection runs.

type InboundMessage

type InboundMessage interface {
	// Extend the Message interface.
	Message

	// GetDestinationName retrieves the destination name on which the message was received.
	// The destination may be either a topic or a queue.
	// An empty string is returned if the information is not available.
	GetDestinationName() string

	// GetTimeStamp retrieves the timestamp as time.Time.
	// This timestamp represents the time that the message was received by the API.
	// This may differ from the time that the message is received by the MessageReceiver.
	GetTimeStamp() (timestamp time.Time, ok bool)

	// GetSenderTimestamp retrieves the timestamp as time.Time.
	// This timestamp is often set automatically when the message is published.
	GetSenderTimestamp() (senderTimestamp time.Time, ok bool)

	// GetSenderID retrieves the sender's ID. This field can be set automatically during
	// message publishing, but existing values are not overwritten if not empty, for example
	// if the message is sent multiple times.
	// Returns the sender's ID and a boolean indicating if it was set.
	GetSenderID() (senderID string, ok bool)

	// GetReplicationGroupMessageID retrieves the Replication Group Message ID.
	// Returns an empty string and false if no Replication Group Message ID is set on the
	// message (for example, direct messages or unsupported broker versions)
	GetReplicationGroupMessageID() (replicationGroupMessageID rgmid.ReplicationGroupMessageID, ok bool)

	// GetMessageDiscardNotification retrieves the message discard notification about
	// previously discarded messages. Returns a MessageDiscardNotification and is  not expected
	// to be nil.
	GetMessageDiscardNotification() MessageDiscardNotification

	// IsRedelivered retrieves the message's redelivery status. Returns true if the message
	// redelivery occurred in the past, otherwise false.
	IsRedelivered() bool
}

InboundMessage represents a message received by a consumer.

type Message

type Message interface {
	// Message is of type Disposable. If the message has any underlying resources from the backing
	// messaging implementation, these can be freed using Disposable.Dispose(). If Disposable.Dispose()
	// is not called on the Message, finalizers attempt to clean up any underlying resources.
	// Calling Dispose() is optional, but is recommended because it improves garbage collection performance.
	// After Disposable.Dispose() is called, Message is considered unusable and all any subsequent function calls
	// return nil or empty data.
	Disposable

	// GetProperties returns a map of user properties.
	GetProperties() sdt.Map

	// GetProperty returns the user property at the given key, and a boolean indicating if its present.
	// Will return nil if not found. Property may be present and set to nil.
	GetProperty(key string) (value sdt.Data, ok bool)

	// HasProperty return whether a user property is present in Message.
	HasProperty(key string) bool

	// GetPayloadAsBytes attempts to get the payload of the message as a byte array.
	// This function return bytes containing the byte array and an ok flag indicating if it was
	// successful. If the content is not accessible in byte array form, an empty slice is
	// returned and the ok flag is false.
	GetPayloadAsBytes() (bytes []byte, ok bool)

	// GetPayloadAsString attempts to get the payload of the message as a string.
	// This function returns a string containing the data stored in the message and an ok flag
	// indicating if it was successful. If the content is not accessible in string form,
	// an empty string is returned and the ok flag is false.
	GetPayloadAsString() (str string, ok bool)

	// GetPayloadAsMap attempts to get the payload of the message as an SDTMap.
	// This function returns a SDTMap instance containing the data stored in the message and
	// an ok indicating if it was success. If the content is not accessible in SDTMap
	// form, sdtMap is nil and ok is false.
	GetPayloadAsMap() (sdtMap sdt.Map, ok bool)

	// GetPayloadAsStream attempts to get the payload of the message as an SDTStream.
	// This function returns a SDTStream instance containing the data stored in the message and
	// an ok indicating if it was success. If the content is not accessible in SDTStream
	// form, sdtStream is nil and ok is false.
	GetPayloadAsStream() (sdtStream sdt.Stream, ok bool)

	// GetCorrelationID returns the correlation ID of the message.
	// If not present, the id argument is an empty string and ok is false.
	GetCorrelationID() (id string, ok bool)

	// GetExpiration returns the expiration time of the message.
	// The expiration time is UTC time of when the message was discarded or
	// moved to the Dead Message Queue by the broker.
	// A value of zero (as determined by time.isZero()) indicates that the
	// message never expires. The default value is zero.
	GetExpiration() time.Time

	// GetSequenceNumber returns the sequence number of the message.
	// Sequence numbers may be set by the publisher applications or
	// automatically generated by the publisher APIs. The sequence number
	// is carried in the Message metadata in addition to the payload, and
	// can be retrieved by consumer applications. Returns a positive
	// sequenceNumber if set, otherwise ok is false if priority is not set.
	GetSequenceNumber() (sequenceNumber int64, ok bool)

	// GetPriority returns the priority value. Valid priorities range from
	// 0 (lowest) to 255 (highest). Returns the priority, otherwise ok is false if priority is not set.
	GetPriority() (priority int, ok bool)

	// GetHTTPContentType returns the HTTP content-type set on the message.
	// If not set, returns an empty string and ok is false.
	GetHTTPContentType() (contentType string, ok bool)

	// GetHTTPContentEncoding returns the HTTP content encoding set on the message.
	// If not set, returns an empty string and ok is false.
	GetHTTPContentEncoding() (contentEncoding string, ok bool)

	// GetApplicationMessageID returns the Application Message ID of the message.
	// This value is used by applications only and is passed through the API unmodified.
	// If not set, returns an empty string and ok is false.
	GetApplicationMessageID() (applicationMessageID string, ok bool)

	// GetApplicationMessageType returns the Application Message Type of the message.
	// This value is used by applications only and is passed through the API unmodified.
	// If not set, returns an empty string and ok is false.
	GetApplicationMessageType() (applicationMessageType string, ok bool)

	// GetClassOfService returns the class of service of the message. Class of Service is
	// represented by an integer with:
	//  0 | COS_1
	//  1 | COS_2
	//  2 | COS_3
	GetClassOfService() (cos int)

	// String implements fmt.Stringer. Prints the message as a string. A truncated response
	// may be returned when large payloads or properties are attached.
	String() string
}

Message represents the common functionality between an Inbound and Outbound message.

type MessageDiscardNotification

type MessageDiscardNotification interface {
	// HasBrokerDiscardIndication determines whether the broker has discarded one
	// or more messages prior to the current message.
	// Returns true if messages (one or more) were previously discarded by the broker,
	// otherwise false.
	HasBrokerDiscardIndication() bool

	// HasInternalDiscardIndication determines if the API has discarded one or more messages
	// prior to the current message (i.e., in a back-pressure situation).
	// Returns true if messages (one or more) were previously discarded by the API, otherwise false.
	HasInternalDiscardIndication() bool
}

MessageDiscardNotification is used to indicate that there are discarded messages.

type OutboundMessage

type OutboundMessage interface {
	// Extend the Message interface.
	Message
}

OutboundMessage is a type of Message that is build by an OutboundMessageBuilder.

Directories

Path Synopsis
Package rgmid contains the ReplicationGroupMessageID interface.
Package rgmid contains the ReplicationGroupMessageID interface.
Package sdt contains the types needed to work with Structured Data on a message.
Package sdt contains the types needed to work with Structured Data on a message.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL