jms20subset

package
v1.13.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2025 License: EPL-2.0 Imports: 1 Imported by: 4

Documentation

Overview

Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.

Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.

Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.

Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.

Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.

Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.

Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.

Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.

Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.

Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.

Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.

Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.

Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.

Package jms20subset provides interfaces for messaging applications in the style of the Java Message Service (JMS) API.

Index

Constants

View Source
const DeliveryMode_NON_PERSISTENT int = 1

DeliveryMode_NON_PERSISTENT is Used to configure messages to be sent Non-Persistently.

View Source
const DeliveryMode_PERSISTENT int = 2

DeliveryMode_PERSISTENT is used to configure messages to be sent Persistently.

View Source
const Destination_PUT_ASYNC_ALLOWED_AS_DEST int = -1

Destination_PUT_ASYNC_ALLOWED_AS_DEST allows the async message behaviour to be controlled by the queue on the queue manager.

View Source
const Destination_PUT_ASYNC_ALLOWED_DISABLED int = 0

Destination_PUT_ASYNC_ALLOWED_DISABLED is used to disable messages being sent asynchronously.

View Source
const Destination_PUT_ASYNC_ALLOWED_ENABLED int = 1

Destination_PUT_ASYNC_ALLOWED_ENABLED is used to enable messages being sent asynchronously.

View Source
const JMSContextAUTOACKNOWLEDGE int = 1

JMSContextAUTOACKNOWLEDGE is used to specify a sessionMode that automatically acknowledge message transmission.

View Source
const JMSContextSESSIONTRANSACTED int = 0

JMSContextSESSIONTRANSACTED is used to specify a sessionMode that requires manual commit/rollback of transactions.

View Source
const Priority_DEFAULT int = 4

Priority_DEFAULT is the default priority for messages sent using a Producer.

Variables

This section is empty.

Functions

This section is empty.

Types

type BytesMessage added in v1.3.0

type BytesMessage interface {

	// Encapsulate the root Message type so that this interface "inherits" the
	// accessors for standard attributes that apply to all message types, such
	// as GetJMSMessageID.
	Message

	// ReadBytes returns the bytes contained in this message's data.
	ReadBytes() *[]byte

	// WriteBytes sets the bytes for this message's data.
	WriteBytes(bytes []byte)

	GetBodyLength() int
}

BytesMessage is used to send a message containing a slice of bytes

Instances of this object are created using the functions on the JMSContext such as CreateBytesMessage and CreateBytesMessageWithBytes.

type ConnectionFactory

type ConnectionFactory interface {

	// CreateContext creates a connection to the messaging provider using the
	// configuration parameters that are encapsulated by this ConnectionFactory.
	//
	// Optional MQOptions can be provided to configure the connection prior to initialisation
	// but are not typically required. Most calls to this function pass zero arguments.
	//
	// Defaults to sessionMode of JMSContextAUTOACKNOWLEDGE
	CreateContext(opts ...MQOptions) (JMSContext, JMSException)

	// CreateContextWithSessionMode creates a connection to the messaging provider using the
	// configuration parameters that are encapsulated by this ConnectionFactory,
	// and the specified session mode.
	//
	// Optional MQOptions can be provided to configure the connection prior to initialisation
	// but are not typically required. Most calls to this function pass zero arguments.
	CreateContextWithSessionMode(sessionMode int, opts ...MQOptions) (JMSContext, JMSException)
}

ConnectionFactory defines a Golang interface which provides similar functionality as the Java JMS ConnectionFactory - encapsulating a set of connection configuration parameters that allows an application to create connections to a messaging provider.

type Destination

type Destination interface {

	// GetDestinationName returns the name of the destination represented by this
	// object.
	//
	// In Java JMS this interface contains no methods and is only a parent for the
	// Queue and Topic interfaces, however in Golang an interface with no methods
	// is automatically implemented by every object, so we need to define at least
	// one method here in order to make it meet the JMS style semantics.
	GetDestinationName() string

	// SetPutAsyncAllowed controls whether asynchronous put is allowed for this
	// destination.
	//
	// See also ConnectionFactoryImpl.SendCheckCount to control the frequency with
	// which checks will be made for errors. Default of 0 (zero) means no error checks
	// will be made for errors during async put.
	//
	// Permitted values are:
	//  * Destination_PUT_ASYNC_ALLOWED_ENABLED - enables async put
	//  * Destination_PUT_ASYNC_ALLOWED_DISABLED - disables async put
	//  * Destination_PUT_ASYNC_ALLOWED_AS_DEST - delegate to queue configuration (default)
	SetPutAsyncAllowed(paa int) Queue

	// GetPutAsyncAllowed returns whether asynchronous put is configured for this
	// destination.
	//
	// Returned value is one of:
	//  * Destination_PUT_ASYNC_ALLOWED_ENABLED - async put is enabled
	//  * Destination_PUT_ASYNC_ALLOWED_DISABLED - async put is disabled
	//  * Destination_PUT_ASYNC_ALLOWED_AS_DEST - delegated to queue configuration (default)
	GetPutAsyncAllowed() int
}

Destination encapsulates a provider-specific address, which is typically specialized as either a Queue or a Topic.

type JMSConsumer

type JMSConsumer interface {

	// ReceiveNoWait receives the next message if one is available, or nil if
	// there is no message immediately available
	ReceiveNoWait() (Message, JMSException)

	// Receive(waitMillis) returns a message if one is available, or otherwise
	// waits for up to the specified number of milliseconds for one to become
	// available. A value of zero or less indicates to wait indefinitely.
	Receive(waitMillis int32) (Message, JMSException)

	// ReceiveStringBodyNoWait receives the next message for this JMSConsumer
	// and returns its body as a string. If a message is not immediately
	// available a nil is returned.
	ReceiveStringBodyNoWait() (*string, JMSException)

	// ReceiveStringBody returns the body of a message as a string if one is
	// available. If a message is not immediately available the method will
	// block for up to the specified number of milliseconds to wait for one
	// to become available. A value of zero or less indicates to wait
	// indefinitely.
	ReceiveStringBody(waitMillis int32) (*string, JMSException)

	// ReceiveBytesBodyNoWait receives the next message for this JMSConsumer
	// and returns its body as a slice of bytes. If a message is not immediately
	// available an uninitialized *[]byte is returned.
	ReceiveBytesBodyNoWait() (*[]byte, JMSException)

	// ReceiveBytesBody returns the body of a message as a slice of bytes if one is
	// available. If a message is not immediately available the method will
	// block for up to the specified number of milliseconds to wait for one
	// to become available. A value of zero or less indicates to wait
	// indefinitely.
	ReceiveBytesBody(waitMillis int32) (*[]byte, JMSException)

	// Closes the JMSConsumer in order to free up any resources that were
	// allocated by the provider on behalf of this consumer.
	Close()
}

JMSConsumer provides the ability for an application to receive messages from a queue or a topic.

Note that Golang doesn't provide Generics in the same way as Java so we have to create multiple separate functions to provide capability equivalent to the Java JMS receiveBody(Class<T>) method.

type JMSContext

type JMSContext interface {

	// CreateProducer creates a new producer object that can be used to configure
	// and send messages.
	//
	// Note that the Destination object is always supplied when making the
	// individual producer.Send calls, and not as part of creating the producer
	// itself.
	CreateProducer() JMSProducer

	// CreateConsumer creates a consumer for the specified Destination so that
	// an application can receive messages from that Destination.
	CreateConsumer(dest Destination) (JMSConsumer, JMSException)

	// CreateConsumer creates a consumer for the specified Destination using a
	// message selector, so that an application can receive messages from a
	// Destination that match the selector criteria.
	//
	// Note that since Golang does not allow multiple functions with the same
	// name and different parameters we must use a different function name.
	CreateConsumerWithSelector(dest Destination, selector string) (JMSConsumer, JMSException)

	// CreateBrowser creates a consumer for the specified Destination so that
	// an application can look at messages without removing them.
	CreateBrowser(dest Destination) (QueueBrowser, JMSException)

	// CreateQueue creates a queue object which encapsulates a provider specific
	// queue name.
	//
	// Note that this method does not create the physical queue in the JMS
	// provider. Creating a physical queue is typically an administrative task
	// performed by an administrator using provider-specific tooling.
	CreateQueue(queueName string) Queue

	// CreateTextMessage creates a message object that is used to send a string
	// from one application to another.
	CreateTextMessage() TextMessage

	// CreateTextMessageWithString creates an initialized text message object
	// containing the string that needs to be sent.
	//
	// Note that since Golang does not allow multiple functions with the same
	// name and different parameters we must use a different function name.
	CreateTextMessageWithString(txt string) TextMessage

	// CreateBytesMessage creates a message object that is used to send a slice
	// of bytes from one application to another.
	CreateBytesMessage() BytesMessage

	// CreateBytesMessageWithBytes creates a message object that is used to send a slice
	// of bytes from one application to another.
	CreateBytesMessageWithBytes(bytes []byte) BytesMessage

	// Commit confirms all messages sent/received during this transaction.
	Commit() JMSException

	// Rollback releases all messages sent/received during this transaction.
	Rollback() JMSException

	// Closes the connection to the messaging provider.
	//
	// Since the provider typically allocates significant resources on behalf of
	// a connection applications should close these resources when they are not
	// needed.
	Close()
}

JMSContext represents a connection to the messaging provider, and provides the capability for applications to create Producer and Consumer objects so that it can send and receive messages.

type JMSException

type JMSException interface {
	GetReason() string
	GetErrorCode() string
	GetLinkedError() error
	Error() string
}

JMSException represents an interface for returning details of a condition that has caused a function call to fail.

It includes provider-specific Reason and ErrorCode attributes, and an optional reference to an Error describing the low-level problem.

func CreateJMSException

func CreateJMSException(reason string, errorCode string, linkedErr error) JMSException

CreateJMSException is a helper function for creating a JMSException

func CreateJMSExceptionWithExtraParams added in v1.13.1

func CreateJMSExceptionWithExtraParams(reason string, errorCode string, linkedErr error, messageLength int) JMSException

CreateJMSException is a helper function for creating a JMSException

type JMSExceptionImpl

type JMSExceptionImpl struct {
	// contains filtered or unexported fields
}

JMSExceptionImpl is a struct that implements the JMSException interface

func (JMSExceptionImpl) Error

func (ex JMSExceptionImpl) Error() string

Error allows the JMSExceptionImpl struct to be treated as a Golang error, while also returning a human readable string representation of the error.

func (JMSExceptionImpl) GetErrorCode

func (ex JMSExceptionImpl) GetErrorCode() string

GetErrorCode returns the provider-specific error code describing the error.

func (JMSExceptionImpl) GetLinkedError

func (ex JMSExceptionImpl) GetLinkedError() error

GetLinkedError returns the linked Error object representing the low-level problem, if one has been provided.

func (JMSExceptionImpl) GetMessageLength added in v1.13.1

func (ex JMSExceptionImpl) GetMessageLength() int

GetMessageLength gives the data length that was returned by a Receive (GET) call, for example if the message was truncated, or could not be read because the receive buffer was too small.

func (JMSExceptionImpl) GetReason

func (ex JMSExceptionImpl) GetReason() string

GetReason returns the provider-specific reason string describing the error.

type JMSProducer

type JMSProducer interface {

	// Send a message to the specified Destination, using any message options
	// that are defined on this JMSProducer.
	Send(dest Destination, msg Message) JMSException

	// Send a TextMessage with the specified body to the specified Destination
	// using any message options that are defined on this JMSProducer.
	//
	// Note that since Golang does not allow multiple functions with the same
	// name and different parameters we must use a different function name.
	SendString(dest Destination, body string) JMSException

	// Send a BytesMessage with the specified body to the specified Destination
	// using any message options that are defined on this JMSProducer.
	//
	// Note that since Golang does not allow multiple functions with the same
	// name and different parameters we must use a different function name.
	SendBytes(dest Destination, body []byte) JMSException

	// SetDeliveryMode sets the delivery mode of messages sent using this
	// JMSProducer - for example whether a message is persistent or non-persistent.
	//
	// Permitted arguments to this method are jms20subset.DeliveryMode_PERSISTENT
	// and jms20subset.DeliveryMode_NON_PERSISTENT.
	SetDeliveryMode(mode int) JMSProducer

	// GetDeliveryMode returns the delivery mode of messages that are send using
	// this JMSProducer.
	//
	// Typical values returned by this method include
	// jms20subset.DeliveryMode_PERSISTENT and jms20subset.DeliveryMode_NON_PERSISTENT
	GetDeliveryMode() int

	// SetTimeToLive sets the time to live (in milliseconds) for messages that
	// are sent using this JMSProducer.
	//
	// The expiration time of a message is the sum of this time to live and the
	// time at which the message is sent. A value of zero means that the message
	// never expires.
	SetTimeToLive(timeToLive int) JMSProducer

	// GetTimeToLive returns the time to live (in milliseconds) that will be
	// applied to messages that are sent using this JMSProducer.
	GetTimeToLive() int

	// SetPriority sets the message priority for all messages sent by this producer.
	SetPriority(priority int) JMSProducer

	// GetPriority returns the priority for all messages sent by this producer.
	// Default priority is 4.
	GetPriority() int
}

JMSProducer is a simple object used to send messages on behalf of a JMSContext. It provides various methods to send a message to a specified Destination. It also provides methods to allow message options to be specified prior to sending a message.

type MQOptions added in v1.9.0

type MQOptions func(cno *ibmmq.MQCNO)

func WithMaxMsgLength added in v1.9.0

func WithMaxMsgLength(maxMsgLength int32) MQOptions

type Message

type Message interface {

	// GetJMSMessageID returns the ID of the message that uniquely identifies
	// each message sent by the provider.
	GetJMSMessageID() string

	// GetJMSTimestamp returns the message timestamp at which the message was
	// handed off to the provider to be sent.
	GetJMSTimestamp() int64

	// GetJMSExpiration returns the timestamp at which the message is due to
	// expire.
	GetJMSExpiration() int64

	// SetJMSCorrelationID sets the correlation ID for the message which can be
	// used to link on message to another. A typical use is to link a response
	// message with its request message.
	SetJMSCorrelationID(correlID string) JMSException

	// GetJMSCorrelationID returns the correlation ID of this message.
	GetJMSCorrelationID() string

	// SetJMSReplyTo sets the Destination to which a reply to this message should
	// be sent. If it is nil then no reply is expected.
	SetJMSReplyTo(dest Destination) JMSException

	// GetJMSReplyTo returns the Destination object to which a reply to this
	// message should be sent.
	GetJMSReplyTo() Destination

	// GetJMSDeliveryMode returns the delivery mode that is specified for this
	// message.
	//
	// Typical values returned by this method include
	// jms20subset.DeliveryMode_PERSISTENT and jms20subset.DeliveryMode_NON_PERSISTENT
	GetJMSDeliveryMode() int

	// GetJMSPriority returns the priority that is specified for this message.
	GetJMSPriority() int

	// SetStringProperty enables an application to set a string-type message property.
	//
	// value is *string which allows a nil value to be specified, to unset an individual
	// property.
	SetStringProperty(name string, value *string) JMSException

	// GetStringProperty returns the string value of a named message property.
	// Returns nil if the named property is not set.
	GetStringProperty(name string) (*string, JMSException)

	// SetIntProperty enables an application to set a int-type message property.
	SetIntProperty(name string, value int) JMSException

	// GetIntProperty returns the int value of a named message property.
	// Returns 0 if the named property is not set.
	GetIntProperty(name string) (int, JMSException)

	// SetDoubleProperty enables an application to set a double-type (float64) message property.
	SetDoubleProperty(name string, value float64) JMSException

	// GetDoubleProperty returns the double (float64) value of a named message property.
	// Returns 0 if the named property is not set.
	GetDoubleProperty(name string) (float64, JMSException)

	// SetBooleanProperty enables an application to set a bool-type message property.
	SetBooleanProperty(name string, value bool) JMSException

	// GetBooleanProperty returns the bool value of a named message property.
	// Returns false if the named property is not set.
	GetBooleanProperty(name string) (bool, JMSException)

	// PropertyExists returns true if the named message property exists on this message.
	PropertyExists(name string) (bool, JMSException)

	// GetPropertyNames returns a slice of strings containing the name of every message
	// property on this message.
	// Returns a zero length slice if no message properties are set.
	GetPropertyNames() ([]string, JMSException)

	// ClearProperties removes all message properties from this message.
	ClearProperties() JMSException
}

Message is the root interface of all JMS Messages. It defines the common message header attributes used for all messages.

Instances of message objects are created using the functions on the JMSContext such as CreateTextMessage.

type MessageIterator added in v1.7.0

type MessageIterator interface {

	// GetNext returns the next Message that is available
	// or else nil if no messages are available.
	GetNext() (Message, JMSException)
}

MessageIterator provides the ability for the application to consume a sequence of Messages.

type Queue

type Queue interface {

	// Encapsulate the root Destination type so that this interface "inherits" the
	// accessors for standard attributes that apply to all destination types
	Destination

	// GetQueueName returns the provider-specific name of the queue that is
	// represented by this object.
	GetQueueName() string
}

Queue encapsulates a provider-specific queue name through which an application can carry out point to point messaging. It is the way a client specifies the identity of a queue to the JMS API functions.

type QueueBrowser added in v1.7.0

type QueueBrowser interface {

	// GetEnumeration returns an iterator for browsing the current
	// queue messages in the order they would be received.
	GetEnumeration() (MessageIterator, JMSException)

	// Closes the QueueBrowser in order to free up any resources that were
	// allocated by the provider.
	Close()
}

QueueBrowser provides the ability for an application to look at messages on a queue without removing them.

type TextMessage

type TextMessage interface {

	// Encapsulate the root Message type so that this interface "inherits" the
	// accessors for standard attributes that apply to all message types, such
	// as GetJMSMessageID.
	Message

	// GetText returns the string containing this message's data.
	GetText() *string

	// SetText sets the string containing this message's data.
	SetText(newBody string)
}

TextMessage is used to send a message containing a string.

Instances of this object are created using the functions on the JMSContext such as CreateTextMessage and CreateTextMessageWithString.

Jump to

Keyboard shortcuts

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