A new message producer is created for each message, but they share the same session. Should the message producer be closed after sending each message?

A new message producer is created for each message, but they share the same session. Should the message producer be closed after sending each message?

book

Article ID: KB0093270

calendar_today

Updated On:

Products Versions
TIBCO Enterprise Message Service -
Not Applicable -

Description

Resolution:

Yes, you should close the producer. Otherwise, you will run into a producer leak issue. Since we allocate some resources on behalf of a MessageProducer outside the Java virtual machine, clients should close them when they are no longer needed. A CompletionListener callback method must not call close on its own MessageProducer. Doing so will cause an IllegalStateException to be thrown. If the session/connection is closed, all producers associated with it will be closed.

Issue/Introduction

A new message producer is created for each message, but they share the same session. Should the message producer be closed after sending each message?