Skip to content

Commit dbca707

Browse files
authored
Merge pull request #353 from IBMStreams/develop
Merge latest develop changes into master
2 parents de8a3b5 + f465922 commit dbca707

File tree

5 files changed

+118
-91
lines changed

5 files changed

+118
-91
lines changed

com.ibm.streamsx.messaging/impl/java/src/com/ibm/streamsx/messaging/jms/ConnectionDocumentParser.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,14 @@ private void convertProviderURLPath(File applicationDir) throws ParseConnectionD
233233

234234
// subroutine to parse and validate the connection document
235235
// called by both the JMSSink and JMSSource
236-
public void parseAndValidateConnectionDocument(String connectionDocument, String connection, String access,
237-
StreamSchema streamSchema, boolean isProducer, File applicationDir) throws ParseConnectionDocumentException, SAXException,
238-
IOException, ParserConfigurationException {
236+
public void parseAndValidateConnectionDocument( String connectionDocument,
237+
String connection,
238+
String access,
239+
StreamSchema streamSchema,
240+
boolean isProducer,
241+
File applicationDir)
242+
throws ParseConnectionDocumentException, SAXException, IOException, ParserConfigurationException
243+
{
239244
// validate the connections document against the xsd
240245
validateConnectionsXML(connectionDocument);
241246
// create document builder

com.ibm.streamsx.messaging/impl/java/src/com/ibm/streamsx/messaging/jms/JMSConnectionHelper.java

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class JMSConnectionHelper implements ExceptionListener {
4141
// jndi context
4242
private Context jndiContext = null;
4343
// connection
44-
private Connection connect = null;
44+
private Connection connection = null;
4545
// JMS message producer
4646
private MessageProducer producer = null;
4747
// JMS message consumer
@@ -133,8 +133,8 @@ private void setSessionCreationTime(long sessionCreationTime) {
133133
}
134134

135135
// procedure to detrmine if there exists a valid connection or not
136-
private boolean isConnectValid() {
137-
if (connect != null)
136+
private boolean isConnectionValid() {
137+
if (connection != null)
138138
return true;
139139
return false;
140140
}
@@ -173,13 +173,13 @@ private synchronized void setSession(Session session) {
173173

174174
// setter for connect
175175
// connect is thread safe.Hence not synchronizing.
176-
private void setConnect(Connection connect) {
177-
this.connect = connect;
176+
private void setConnection(Connection connection) {
177+
this.connection = connection;
178178
}
179179

180180
// getter for connect
181-
private Connection getConnect() {
182-
return connect;
181+
private Connection getConnection() {
182+
return connection;
183183
}
184184

185185
// logger to get error messages
@@ -301,7 +301,7 @@ private synchronized void createConnection() throws ConnectionException, Interru
301301
int nConnectionAttempts = 0;
302302

303303
// Check if connection exists or not.
304-
if (!isConnectValid()) {
304+
if (!isConnectionValid()) {
305305

306306
// Delay in miliseconds as specified in period parameter
307307
final long delay = TimeUnit.MILLISECONDS.convert((long) period,
@@ -367,7 +367,7 @@ private synchronized void createConnectionNoRetry() throws ConnectionException {
367367

368368
tracer.log(TraceLevel.TRACE, "Begin createConnectionNoRetry()"); //$NON-NLS-1$
369369

370-
if (!isConnectValid()) {
370+
if (!isConnectionValid()) {
371371
try {
372372
connect(isProducer);
373373
} catch (JMSException e) {
@@ -389,22 +389,22 @@ private boolean connect(boolean isProducer) throws JMSException {
389389
if (userPrincipal != null && !userPrincipal.isEmpty() &&
390390
userCredential != null && !userCredential.isEmpty() ) {
391391
tracer.log(TraceLevel.TRACE, "Create connection for user: " + userPrincipal); //$NON-NLS-1$
392-
setConnect(connFactory.createConnection(userPrincipal, userCredential));
392+
setConnection(connFactory.createConnection(userPrincipal, userCredential));
393393
}
394394
else {
395395
tracer.log(TraceLevel.TRACE, "Create connection with empty credentials"); //$NON-NLS-1$
396-
setConnect(connFactory.createConnection());
396+
setConnection(connFactory.createConnection());
397397
}
398-
getConnect().setExceptionListener (this);
398+
getConnection().setExceptionListener (this);
399399

400400
// Create session from connection; false means
401401
// session is not transacted.
402402

403403
if(isProducer) {
404-
setSession(getConnect().createSession(this.useClientAckMode, Session.AUTO_ACKNOWLEDGE));
404+
setSession(getConnection().createSession(this.useClientAckMode, Session.AUTO_ACKNOWLEDGE));
405405
}
406406
else {
407-
setSession(getConnect().createSession(false, (this.useClientAckMode) ? Session.CLIENT_ACKNOWLEDGE : Session.AUTO_ACKNOWLEDGE));
407+
setSession(getConnection().createSession(false, (this.useClientAckMode) ? Session.CLIENT_ACKNOWLEDGE : Session.AUTO_ACKNOWLEDGE));
408408
}
409409

410410

@@ -422,14 +422,15 @@ private boolean connect(boolean isProducer) throws JMSException {
422422
getProducerCR().setDeliveryMode(DeliveryMode.PERSISTENT);
423423
// start the connection
424424
tracer.log (LogLevel.INFO, "going to start the connection for producer in client acknowledge mode ..."); //$NON-NLS-1$
425-
getConnect().start();
425+
getConnection().start();
426426
}
427427

428428
// set the delivery mode if it is specified
429429
// default is non-persistent
430430
if (deliveryMode == null) {
431431
getProducer().setDeliveryMode(DeliveryMode.NON_PERSISTENT);
432-
} else {
432+
}
433+
else {
433434
if (deliveryMode.trim().toLowerCase().equals("non_persistent")) { //$NON-NLS-1$
434435
getProducer().setDeliveryMode(DeliveryMode.NON_PERSISTENT);
435436
}
@@ -439,12 +440,13 @@ private boolean connect(boolean isProducer) throws JMSException {
439440
}
440441
}
441442

442-
} else {
443+
}
444+
else {
443445
// Its JMSSource, So we will create a consumer
444446
setConsumer(getSession().createConsumer(dest, messageSelector));
445447
// start the connection
446448
tracer.log (LogLevel.INFO, "going to start consumer connection ..."); //$NON-NLS-1$
447-
getConnect().start();
449+
getConnection().start();
448450
}
449451
tracer.log (LogLevel.INFO, "connection successfully created"); //$NON-NLS-1$
450452
tracer.log(TraceLevel.TRACE, "End connect()"); //$NON-NLS-1$
@@ -523,7 +525,7 @@ boolean sendMessage(Message message) throws ConnectionException, InterruptedExce
523525

524526
// Recreate the connection objects if we don't have any (this
525527
// could happen after a connection failure)
526-
setConnect(null);
528+
setConnection(null);
527529
createConnection();
528530
}
529531

@@ -559,7 +561,7 @@ Message receiveMessage(long timeout) throws ConnectionException, InterruptedExce
559561
}
560562
// Recreate the connection objects if we don't have any (this
561563
// could happen after a connection failure)
562-
setConnect(null);
564+
setConnection(null);
563565
logger.log(LogLevel.WARN, "ERROR_DURING_RECEIVE", //$NON-NLS-1$
564566
new Object[] { e.toString() });
565567
logger.log(LogLevel.INFO, "ATTEMPT_TO_RECONNECT"); //$NON-NLS-1$
@@ -627,7 +629,7 @@ public void recoverSession() throws JMSException, ConnectionException, Interrupt
627629

628630
tracer.log(LogLevel.INFO, "attempting to reconnect"); //$NON-NLS-1$
629631
logger.log(LogLevel.INFO, "ATTEMPT_TO_RECONNECT"); //$NON-NLS-1$
630-
setConnect(null);
632+
setConnection(null);
631633
createConnection();
632634

633635
synchronized (getSession()) {
@@ -670,14 +672,14 @@ public void closeConnection() {
670672
// ignore
671673
}
672674
}
673-
if (getConnect() != null) {
675+
if (getConnection() != null) {
674676
try {
675-
getConnect().close();
677+
getConnection().close();
676678
} catch (JMSException e) {
677679
// ignore
678680
}
679681
finally {
680-
setConnect(null);
682+
setConnection(null);
681683
}
682684
}
683685
tracer.log(TraceLevel.TRACE, "End closeConnection()"); //$NON-NLS-1$

0 commit comments

Comments
 (0)