Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JMSSink should cause CC to reset if message is not sent #8

Open
chanskw opened this issue Nov 18, 2016 · 2 comments
Open

JMSSink should cause CC to reset if message is not sent #8

chanskw opened this issue Nov 18, 2016 · 2 comments
Assignees
Labels

Comments

@chanskw
Copy link

chanskw commented Nov 18, 2016

In the process method of JMSSink:

This is called if the message is not sent:

if (!msgSent) {
									
			logger.log(LogLevel.ERROR, "EXCEPTION_SINK");
			if (hasErrorPort) {
				sendOutputErrorMsg(tuple,
						"Dropping this tuple since an exception occurred while sending.");
			}
			
		}

If the JMSSink operator is in CC, we should trigger a reset in the CC.

@ghost
Copy link

ghost commented Oct 13, 2017

In consistent region, the message is sent with sendMessageNoRetry:

else {
    // consistent region
    // Construct the JMS message based on the message type taking the
    // attributes from the tuple.
    // propagate all exceptions to the runtime to restart the consistent region in case of failure
    Message message = mhandler.convertTupleToMessage(tuple,
           jmsConnectionHelper.getSession());
    msgSent = jmsConnectionHelper.sendMessageNoRetry(message);
}

sendMessageNoRetry throws a JMSException in case of connection failure, which triggers reset of CR. Caught MessageFormatExceptions are NOT re-thrown, however:

boolean sendMessageNoRetry(Message message) throws JMSException {
	boolean res = false;
	try {
		// try to send the message
		synchronized (getSession()) {
			getProducer().send(message);
			res = true;
		}
	}
	catch (JMSException e) {
		// error has occurred, log error and try sending message again
		logger.log(LogLevel.WARN, "ERROR_DURING_SEND", new Object[] { e.toString() }); //$NON-NLS-1$
		// If the exception is caused by message format, then we can return peacefully as connection is still good.
/* ==>>  */	if(!(e instanceof MessageFormatException)) {
			throw e;
		}
	}
	if(!res) {
		nFailedInserts.incrementValue(1);
	}
	return res;
}

Thus, only in case of MessageFormatException the CR is not reset. Should also be reset. I suggest to throw also MessageFormatException, which is a subclass of JMSException and change the return of sendMessageNoRetryto void. Either we sent the message or we did not. If we did not, we throw an appropriate exception.

@schubon schubon transferred this issue from IBMStreams/streamsx.messaging Apr 24, 2019
@schubon schubon self-assigned this Apr 24, 2019
@schubon
Copy link
Member

schubon commented Apr 24, 2019

Check Rolef's comments and code changes. Probably, this issue may be closed already.

@schubon schubon added the investigate Cause unclear? Reproducible? label May 18, 2020
@schubon schubon added prio: low and removed defect Something isn't working prio: middle labels Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants