diff --git a/jms20subset/ConnectionFactory.go b/jms20subset/ConnectionFactory.go index c564bee..5e49000 100644 --- a/jms20subset/ConnectionFactory.go +++ b/jms20subset/ConnectionFactory.go @@ -18,14 +18,18 @@ type ConnectionFactory interface { // CreateContext creates a connection to the messaging provider using the // configuration parameters that are encapsulated by this ConnectionFactory. - // Optional options can be provided to configure the connection prior to initialisation. + // + // 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 options can be provided to configure the - // connection prior to initialisation. + // 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) } diff --git a/mq_connection_options_test.go b/mq_connection_options_test.go index c861f49..4920b53 100644 --- a/mq_connection_options_test.go +++ b/mq_connection_options_test.go @@ -10,9 +10,10 @@ package main import ( + "testing" + "github.com/ibm-messaging/mq-golang-jms20/jms20subset" "github.com/ibm-messaging/mq-golang/v5/ibmmq" - "testing" "github.com/ibm-messaging/mq-golang-jms20/mqjms" "github.com/stretchr/testify/assert" @@ -73,8 +74,8 @@ func TestMQConnectionOptions(t *testing.T) { // Create a Queue object that points at an IBM MQ queue rQueue := rContext.CreateQueue("DEV.QUEUE.1") // Send a message to the queue that contains a large string - consumer, errSend := rContext.CreateConsumer(rQueue) - assert.NoError(t, errSend) + consumer, errCons := rContext.CreateConsumer(rQueue) + assert.NoError(t, errCons) // expect that receiving the message will cause an JMS Data Length error _, err := consumer.ReceiveStringBodyNoWait() @@ -82,5 +83,12 @@ func TestMQConnectionOptions(t *testing.T) { jmsErr, ok := err.(jms20subset.JMSExceptionImpl) assert.True(t, ok) assert.Equal(t, "MQRC_DATA_LENGTH_ERROR", jmsErr.GetReason()) + + // Now consume the message sucessfully to tidy up before the next test. + tidyConsumer, errCons := sContext.CreateConsumer(sQueue) + assert.NoError(t, errCons) + gotMsg, err := tidyConsumer.ReceiveNoWait() + assert.NoError(t, err) + assert.NotNil(t, gotMsg) }) }