jms20subset

package
v0.0.0-...-d5575fb Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2019 License: EPL-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Interfaces for messaging applications in the style of the Java Message Service (JMS) API.

Index

Constants

View Source
const DeliveryMode_NON_PERSISTENT int = 1

Used to configure messages to be sent Non-Persistently.

View Source
const DeliveryMode_PERSISTENT int = 2

Used to configure messages to be sent Persistently.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionFactory

type ConnectionFactory interface {

	// CreateContext creates a connection to the messaging provider using the
	// configuration parameters that are encapsulated by this ConnectionFactory.
	CreateContext() (JMSContext, JMSException)
	CreateTLSContext(key string) (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
}

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)

	// 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)
	// 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)

	// 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

	// 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
}

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

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) 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

	// 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
	SetStringProperty(name string, value string)
}

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 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

	// 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
	GetStringProperty(p string) (string, error)
}

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 Queue

type Queue interface {

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

	// GetDestinationName returns the provider-specific name of the queue that is
	// represented by this object.
	//
	// This method is implemented to allow us to consider the Queue interface
	// as a specialization of the Destination interface.
	GetDestinationName() 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 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