-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
[BUG] Non recoverable JMS connection caused by: java.lang.NullPointerException: null #29881
Comments
@adelinor Thanks for reporting this. I tested your case with only |
Dear @yiliuTo , Many thanks for coming back on this issue. The project I use is the following: |
Hi @adelinor , thanks for sharing your project. Could you also share your Service Bus service configuration? like below or something more if you have other custom configurations. And I noticed that you are using Weblogic as well as the Thus besides for the Service Bus service configuration, could you help to test if you can get this error without Weblogic or transaction usage? This can help us to narrow down the scope. |
Hi @yiliuTo , The service bus was setup as follows:
The sample code attached earlier was updated to use the default transaction manager (data source based one):
@Configuration
@EnableJms
@Slf4j
public class JmsConfig {
/**
* @param connectionFactory Auto configured by spring boot
* @param transactionManager Required parameter
* @return Camel JMS configuration
*/
@Bean
JmsConfiguration jmsConfiguration(
ConnectionFactory connectionFactory,
PlatformTransactionManager transactionManager) {
JmsConfiguration result = new JmsConfiguration();
result.setConnectionFactory(connectionFactory);
if (transactionManager != null) {
LOGGER.info("Setting transacted=true for the JMS configuration");
result.setTransactionManager(transactionManager);
result.setTransacted(true);
// Default is CACHE_AUTO which should resolve to
// CACHE_NONE in a transaction enabled environment but
// defaulting it to avoid any doubt
result.setCacheLevelName("CACHE_NONE");
}
return result;
}
/**
* @param jmsConfiguration Required parameter
* @return Camel JMS endpoint
*/
@Bean
JmsComponent jmsComponent(JmsConfiguration jmsConfiguration) {
return JmsComponent.jmsComponent(jmsConfiguration);
}
}
5000 messages were pushed to the
Please find logs for the entire execution: |
Hi @adelinor sorry for the late response, given the log of
Service Bus has some specific rules for cross-entity transactions, like it will create a session with specified name crossentity-coordinator for cross-entity transaction operations. Thus for other common transaction managers, it cannot meet this requirement of Service Bus. However, I have tested with the native JMS transacted session with your sample code, and find that can work. I am connecting to MS Service Bus team internally to confirm this and will update to you if any. Would you like to try using the transacted session for camel JMS instead of other transaction managers? |
Hi @yiliuTo , as it seems difficult to reproduce the issue, it would be beneficial to add more logging in the SDK so that the cause of the problem can be better located. This sample app consumes a message to perform operations in the database so the transaction manager needs to encompass database operations. Kind regards |
Hi @adelinor ,
While considering that what the library And as for the cause of the cross-entity transaction error, as mentioned in jmstoolbox/jmstoolbox#137 (comment), the support from Service Bus service side on cross-entity transaction of JMS specs is only for transacted session (locally transacted JMS session). And according to the underlying Spring JMS code, see JmsAccessor and DefaultJmsListenerContainerFactoryConfigurer, to set the transacted JMS session or transaction managers are mutually exclusive, thus I think that's the reason. |
Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you! |
Hi @yiliuTo , The JMSConfiguration is set as transacted. If the transaction configuration was wrong, no message would get processed. The observed behaviour is that the processing works as expected for a small number of messages (less than 100) and fails with the error reported in this issue with larger volumes. The error reported, Kind regards |
Hi @yiliuTo, I would like to share with you some further tests I have done on this issue. I did two runs where both start with 1000 messages in the inbox queue and with empty tables. The second run is done by setting the environment variable In both scenarios above I come to the conclusion that we do not have reliability with this setup: i.e. use of Azure Service Bus via JMS. |
Hi @adelinor , thanks for the detailed information. The test I used is a pure spring-jms application without camel jms since both camel-jms and Azure Service Bus JMS starter relys on the connection /listener container/transaction-management implementation from spring-jms, and here is the application I use. And for spring-jms, it by default configure the transacted session when no transaction manager is found, thus in my test I didn't specifically configure the transaction. However, I found that when using different ways for cross-entity transaction of spring-jms, it behaves differently of using JmsTemplate or @sendto annotation, when using @sendto, it will encounter the same error of |
The article https://www.infoworld.com/article/2077963/distributed-transactions-in-spring--with-and-without-xa.html describes very well the options that for managing transactions with various transactional resources. That is the case of the The option of not using JTA, i.e. using the default JPA transaction manager, is referred as the Wing-and-a-Prayer pattern:
Using JTA would guarantee the reliability but the Azure Service Bus may not support XA and this might explain why the applications hangs. The XA and the Last Resource Gambit would be a fit for this scenario:
|
@adelinor could you please try to reproduce the issue with Java 11? https://camel.apache.org/manual/camel-3-migration-guide.html Also your POM does not include camel-azure-servicebus , could you please try to reproduce with Camel latest version below ?: <dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-azure-servicebus</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency> Camel will set the autoCommit on the JDBC connection to be false, commit the change after executed the statement and reset the autoCommit flag of the connection at the end, if the resetAutoCommit is true. If the JDBC connection doesn’t support to reset the autoCommit flag, you can set the resetAutoCommit flag to be false, and Camel will not try to reset the autoCommit flag. When used with XA transactions you most likely need to set it to false so that the transaction manager is in charge of committing this tx. |
@adelinor also: |
The Weblogic Application server runs on Java 8. Nevertheless in order to try this option, I updated slightly the pom file to make the app runnable from Spring boot. Changes were to:
With JDK 11 (version "11.0.16" 2022-07-19 LTS), the same error as reported in this issue occurs but the application is not blocked and all messages end up in the out queue. The database though misses records: 18 out of 5000.
I changed further the pom to use the camel version
With that setup, a batch of 5000 messages get consumed, No error appear in the logs. The database misses 15 records out of the 5000 processed. |
hi @adelinor , We have a meeting internally to discuss this issue, and aware that finally the POC successfully. Is there any other problems we need to help you? |
Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you! |
Dear @fangjian0423 , Indeed by creating separate transaction managers:
I was able to process successfully 100,00 messages without a loss or errors using a standard (i.e. not premium) Azure ServiceBus resource. Note that:
To conclude, this issue can be closed. As a take-away it would be beneficial to the community to have guidance on how to approach the use case of processing messages while performing a transaction with a database. Kind regards |
Thank you for your feedback and suggestion. We will mention the transaction in our docs in the future. |
Describe the bug
Consumer implemented with spring-cloud-azure-starter-servicebus-jms loses the JMS connection and is not able to recover it.
Exception or Stack Trace
The stack trace below shows that the connection is lost after or while processing the 31st message. Attempts to recover the connection can be seen with the message:
Encountered a JMSException - resetting the underlying JMS Connection
.run_10011log.txt
On the 10th attempt the connection is not recovered and the consumer becomes stale. The only way to resume the consumption of messages is to stop the app and start it again.
To Reproduce
Code Snippet
This is not identifiable as logs only report a cause of
null
.Expected behavior
The expected behaviour is that the process for resetting the underlying JMS connection eventually succeeds.
Screenshots
If applicable, add screenshots to help explain your problem.
Setup (please complete the following information):
I do not suspect a dependency version mismatch. I nevertheless provide the effective pom which includes all transitive dependencies:
effective-pom.xml.txt
Additional context
The capacity was increased at the Azure Service Bus level to 8 MU but it did not affect the behaviour of not recovering the JMS connection. It still failed after a few hundred messages were received.
Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
The text was updated successfully, but these errors were encountered: