Abacn commented on code in PR #25945:
URL: https://github.com/apache/beam/pull/25945#discussion_r1157517762
##########
sdks/java/io/jms/src/main/java/org/apache/beam/sdk/io/jms/JmsIO.java:
##########
@@ -1026,7 +1027,7 @@ public void start() throws JMSException {
}
Review Comment:
may replace the direct assignment of producer with startProducer() thus make
it clear that producer is opened in single code path.
Also, I see " isProducerNeedsToBeCreated" is removed in several places and
connect() is only called in DoFn's setup. Can we get rid of this flag now?
##########
sdks/java/io/jms/src/main/java/org/apache/beam/sdk/io/jms/JmsIO.java:
##########
@@ -1043,25 +1044,35 @@ public void publishMessage(T input) throws
JMSException, JmsIOException {
}
}
- public void close() throws JMSException {
- isProducerNeedsToBeCreated = true;
+ void startProducer() throws JMSException {
+ this.producer = this.session.createProducer(null);
+ }
+
+ void closeProducer() throws JMSException {
if (producer != null) {
producer.close();
producer = null;
}
- if (session != null) {
- session.close();
- session = null;
- }
- if (connection != null) {
- try {
- // If the connection failed, stopping the connection will throw a
JMSException
- connection.stop();
- } catch (JMSException exception) {
- LOG.warn("The connection couldn't be closed", exception);
+ }
+
+ void close() {
+ try {
+ if (producer != null) {
Review Comment:
may call closeProducer() here. Making producer is opened / closed by single
code path
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]