mqjms

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2019 License: EPL-2.0 Imports: 12 Imported by: 8

Documentation

Overview

Implementation of the JMS style Golang interfaces to communicate with IBM MQ.

Implementation of the JMS style Golang interfaces to communicate with IBM MQ.

Index

Constants

View Source
const TLSClientAuth_NONE string = "NONE"

Used to configure the TLSClientAuth property to indicate that a client certificate should not be sent.

View Source
const TLSClientAuth_REQUIRED string = "REQUIRED"

Used to configure the TLSClientAuth property to indicate that a client certificate must be sent to the queue manager, as part of mutual TLS.

View Source
const TransportType_BINDINGS int = 1

Used to configure the TransportType property of the ConnectionFactory, to use a local bindings connection to the queue manager

View Source
const TransportType_CLIENT int = 0

Used to configure the TransportType property of the ConnectionFactory, to use a TCP client connection to the queue manager. This is the default.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionFactoryImpl

type ConnectionFactoryImpl struct {
	QMName      string
	Hostname    string
	PortNumber  int
	ChannelName string
	UserName    string
	Password    string

	TransportType int // Default to TransportType_CLIENT (0)

	// Equivalent to SSLCipherSpec and SSLClientAuth in the MQI client, however
	// the names have been updated here to reflect that SSL protocols have all
	// been discredited.
	TLSCipherSpec string
	TLSClientAuth string // Default to TLSClientAuth_NONE

	KeyRepository    string
	CertificateLabel string
}

ConnectionFactoryImpl defines a struct that contains attributes for each of the key properties required to establish a connection to an IBM MQ queue manager.

The fields are defined as Public so that the struct can be initialised programmatically using whatever approach the application prefers.

func CreateConnectionFactoryFromDefaultJSONFiles

func CreateConnectionFactoryFromDefaultJSONFiles() (cf ConnectionFactoryImpl, err error)

CreateConnectionFactoryFromDefaultJSONFiles is a utility method that creates a JMS ConnectionFactory object that is populated with properties from values stored in two external files on the file system.

This method reads the following files;

  • $HOME/Downloads/connection_info.json for host/port/channel information
  • $HOME/Downloads/apiKey.json for username/password information

If your queue manager is hosted on the IBM MQ on Cloud service then you can download these two files directly from the IBM Cloud service console. Alternative you can use the example files provided in the /config-samples directory of this repository and populate them with the details of your own queue manager.

func CreateConnectionFactoryFromJSON

func CreateConnectionFactoryFromJSON(connectionInfoLocn string, apiKeyLocn string) (cf ConnectionFactoryImpl, err error)

CreateConnectionFactoryFromJSON is a utility method that creates a JMS ConnectionFactory object that is populated with properties from values stored in two external files on the file system.

The calling application provides the fully qualified path to the location of the file as the two parameters. If empty string is provided then the default location and name is assumed as follows;

  • $HOME/Downloads/connection_info.json for host/port/channel information
  • $HOME/Downloads/apiKey.json for username/password information

If your queue manager is hosted on the IBM MQ on Cloud service then you can download these two files directly from the IBM Cloud service console. Alternative you can use the example files provided in the /config-samples directory of this repository and populate them with the details of your own queue manager.

func (ConnectionFactoryImpl) CreateContext

CreateContext implements the JMS method to create a connection to an IBM MQ queue manager.

type ConsumerImpl

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

ConsumerImpl defines a struct that contains the necessary objects for receiving messages from a queue on an IBM MQ queue manager.

func (ConsumerImpl) Close

func (consumer ConsumerImpl) Close()

Closes the JMSConsumer, releasing any resources that were allocated on behalf of that consumer.

func (ConsumerImpl) Receive

func (consumer ConsumerImpl) Receive(waitMillis int32) (jms20subset.Message, jms20subset.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.

func (ConsumerImpl) ReceiveNoWait

func (consumer ConsumerImpl) ReceiveNoWait() (jms20subset.Message, jms20subset.JMSException)

ReceiveNoWait implements the IBM MQ logic necessary to receive a message from a Destination, or immediately return a nil Message if there is no available message to be received.

func (ConsumerImpl) ReceiveStringBody

func (consumer ConsumerImpl) ReceiveStringBody(waitMillis int32) (*string, jms20subset.JMSException)

ReceiveStringBody implements the IBM MQ logic necessary to receive a message from a Destination and return its body as a string.

If no message is available the method blocks up to the specified number of milliseconds for one to become available.

func (ConsumerImpl) ReceiveStringBodyNoWait

func (consumer ConsumerImpl) ReceiveStringBodyNoWait() (*string, jms20subset.JMSException)

ReceiveStringBodyNoWait implements the IBM MQ logic necessary to receive a message from a Destination and return its body as a string.

If no message is immediately available to be returned then a nil is returned.

type ContextImpl

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

ContextImpl encapsulates the objects necessary to maintain an active connection to an IBM MQ queue manager.

func (ContextImpl) Close

func (ctx ContextImpl) Close()

Close this connection to the MQ queue manager, and release any resources that were allocated to support this connection.

func (ContextImpl) CreateConsumer

CreateConsumer creates a consumer object that allows an application to receive messages from the specified Destination.

func (ContextImpl) CreateConsumerWithSelector

func (ctx ContextImpl) CreateConsumerWithSelector(dest jms20subset.Destination, selector string) (jms20subset.JMSConsumer, jms20subset.JMSException)

CreateConsumer creates a consumer object that allows an application to receive messages that match the specified selector from the given Destination.

func (ContextImpl) CreateProducer

func (ctx ContextImpl) CreateProducer() jms20subset.JMSProducer

CreateProducer implements the logic necessary to create a JMSProducer object that allows messages to be sent to destinations in IBM MQ.

func (ContextImpl) CreateQueue

func (ctx ContextImpl) CreateQueue(queueName string) jms20subset.Queue

CreateQueue implements the logic necessary to create a provider-specific object representing an IBM MQ queue.

func (ContextImpl) CreateTextMessage

func (ctx ContextImpl) CreateTextMessage() jms20subset.TextMessage

CreateTextMessage is a JMS standard mechanism for creating a TextMessage.

func (ContextImpl) CreateTextMessageWithString

func (ctx ContextImpl) CreateTextMessageWithString(txt string) jms20subset.TextMessage

CreateTextMessage is a JMS standard mechanism for creating a TextMessage and initialise it with the chosen text string.

type ProducerImpl

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

ProducerImpl defines a struct that contains the necessary objects for sending messages to a queue on an IBM MQ queue manager.

func (*ProducerImpl) GetDeliveryMode

func (producer *ProducerImpl) GetDeliveryMode() int

GetDeliveryMode returns the current delivery mode that is set on this Producer.

func (*ProducerImpl) GetTimeToLive

func (producer *ProducerImpl) GetTimeToLive() int

GetTimeToLive returns the current time to live that is set on this Producer.

func (ProducerImpl) Send

Send a message to the specified IBM MQ queue, using the message options that are defined on this JMSProducer.

func (ProducerImpl) SendString

func (producer ProducerImpl) SendString(dest jms20subset.Destination, bodyStr string) jms20subset.JMSException

Send a TextMessage with the specified body to the specified Destination using any message options that are defined on this JMSProducer.

func (*ProducerImpl) SetDeliveryMode

func (producer *ProducerImpl) SetDeliveryMode(mode int) jms20subset.JMSProducer

SetDeliveryMode contains the MQ logic necessary to store the specified delivery mode parameter inside the Producer object so that it can be applied when sending messages using this Producer.

func (*ProducerImpl) SetTimeToLive

func (producer *ProducerImpl) SetTimeToLive(timeToLive int) jms20subset.JMSProducer

SetTimeToLive contains the MQ logic necessary to store the specified time to live parameter inside the Producer object so that it can be applied when sending messages using this Producer.

type QueueImpl

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

QueueImpl encapsulates the provider-specific attributes necessary to communicate with an IBM MQ queue.

func (QueueImpl) GetDestinationName

func (queue QueueImpl) GetDestinationName() string

GetDestinationName returns the name of the destination represented by this object.

func (QueueImpl) GetQueueName

func (queue QueueImpl) GetQueueName() string

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

type TextMessageImpl

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

TextMessageImpl contains the IBM MQ specific attributes necessary to present a message that carries a string.

func (*TextMessageImpl) GetJMSCorrelationID

func (msg *TextMessageImpl) GetJMSCorrelationID() string

GetJMSCorrelationID retrieves the correl ID from the native MQ message descriptor field.

func (*TextMessageImpl) GetJMSDeliveryMode

func (msg *TextMessageImpl) GetJMSDeliveryMode() int

GetJMSDeliveryMode extracts the persistence setting from this message and returns it in the JMS delivery mode format.

func (*TextMessageImpl) GetJMSMessageID

func (msg *TextMessageImpl) GetJMSMessageID() string

GetJMSMessageID extracts the message ID from the native MQ message descriptor.

func (*TextMessageImpl) GetJMSReplyTo

func (msg *TextMessageImpl) GetJMSReplyTo() jms20subset.Destination

GetJMSReplyTo extracts the native reply information from the MQ message and populates it into a Destination object.

func (*TextMessageImpl) GetJMSTimestamp

func (msg *TextMessageImpl) GetJMSTimestamp() int64

GetJMSTimestamp retrieves the timestamp at which the message was sent from the native MQ message descriptor fields.

func (*TextMessageImpl) GetText

func (msg *TextMessageImpl) GetText() *string

GetText returns the string that is contained in this TextMessage.

func (*TextMessageImpl) SetJMSCorrelationID

func (msg *TextMessageImpl) SetJMSCorrelationID(correlID string) jms20subset.JMSException

SetJMSCorrelationID applies the specified correlation ID string to the native MQ message field used for correlation purposes.

func (*TextMessageImpl) SetJMSReplyTo

SetJMSReplyTo uses the specified Destination object to configure the reply attributes of the native MQ message fields.

func (*TextMessageImpl) SetText

func (msg *TextMessageImpl) SetText(newBody string)

SetText stores the supplied string so that it can be transmitted as part of this TextMessage.

Jump to

Keyboard shortcuts

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