Allow to use any query for POLL operation

master
Vitaliy Filippov 2015-12-21 00:07:03 +03:00
parent 4a592c717b
commit 133fc66358
1 changed files with 60 additions and 78 deletions

View File

@ -145,8 +145,6 @@ public class InboundMessageProcessor implements Runnable, MessageExchangeReplyLi
private String mXAEnabled = null;
private DatabaseModel dbDataAccessObject = null;
private String mTableName = null;
private String mDbName = null;
@ -358,7 +356,7 @@ public class InboundMessageProcessor implements Runnable, MessageExchangeReplyLi
getTransactionManager().begin();
}
dbDataAccessObject = getDataAccessObject(meta);
DatabaseModel dbDataAccessObject = getDataAccessObject(meta);
mSelectSQL = dbDataAccessObject.generateSelectQuery(mSelectSQL, mTableName);
epb.setTableName(mTableName);
@ -366,7 +364,6 @@ public class InboundMessageProcessor implements Runnable, MessageExchangeReplyLi
if (mDbName == null){
mDbName = connection.getMetaData().getDatabaseProductName().toLowerCase();
}
if (isSelectStatement(mSelectSQL)) {
if (epb.isClustered()) {
connection.setAutoCommit(false);
// In cluster environment, adding a simple "FOR UPDATE" to the poll query is enough
@ -427,7 +424,6 @@ public class InboundMessageProcessor implements Runnable, MessageExchangeReplyLi
doPostProcessing(connection, tempList);
}
}
}
} catch (final Exception ex) {
mLogger.log(Level.SEVERE, mMessages.getString("DBBC_E00663.IMP_ERROR_WHILE_PROCESSING_MEP"), ex);
} finally {
@ -502,8 +498,6 @@ public class InboundMessageProcessor implements Runnable, MessageExchangeReplyLi
String lSelectSQL) throws MessagingException {
ResultSet rs = null;
try {
String jndiName = epb.getValue(EndpointBean.JDBC_DATABASE_JNDI_NAME);
mLogger.log(Level.INFO, InboundMessageProcessor.mMessages.getString("DBBC_R00629.OMP_UsedJNDI") + jndiName);
String where = "";
List<String> bind = new ArrayList<String>();
if (lSelectSQL.indexOf("$WHERE") >= 0) {
@ -535,6 +529,13 @@ public class InboundMessageProcessor implements Runnable, MessageExchangeReplyLi
"Reason: " + ex.getLocalizedMessage() + " SQLState: " + ex.getSQLState() + " ErrorCode: " + ex.getErrorCode();
throw new MessagingException(msg, ex);
} catch (final Exception ex) {
if (mLogger.isLoggable(Level.FINEST)) {
mLogger.log(Level.FINEST, mMessages.getString("DBBC_E00639.IMP_Failed_Executing_SQL") + lSelectSQL, ex);
} else if (mLogger.isLoggable(Level.FINE)) {
mLogger.log(Level.FINE, mMessages.getString("DBBC_E00639.IMP_Failed_Executing_SQL") + lSelectSQL);
} else if (mLogger.isLoggable(Level.INFO)) {
mLogger.info(mMessages.getString("DBBC_E00639.IMP_Failed_Executing_SQL"));
}
final String msg = InboundMessageProcessor.mMessages.getString("DBBC_E00639.IMP_Failed_Executing_SQL") + lSelectSQL
+ ex.getLocalizedMessage();
throw new MessagingException(msg, ex);
@ -780,25 +781,6 @@ public class InboundMessageProcessor implements Runnable, MessageExchangeReplyLi
mLogger.log(Level.INFO, InboundMessageProcessor.mMessages.getString("DBBC_R00629.OMP_UsedJNDI") + jndiName);
return ((DataSource) getDataSourceFromContext(jndiName)).getConnection();
}
/**
* @param prepStmtSQLText
* @return
*/
private boolean isSelectStatement(final String prepStmtSQLText) {
prepStmtSQLText.trim();
final StringTokenizer tok = new StringTokenizer(prepStmtSQLText);
if (tok.hasMoreTokens()) {
final String firstTok = (String) tok.nextToken();
if (firstTok.equalsIgnoreCase("select")) {
return true;
}
}
return false;
}
protected void stopReceiving() {
mLogger.log(Level.INFO, "DBBC_R00644.IMP_Inbound_stopped");