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

"SSCSSI-352 | Fix prefetching issue with service bus topic message listeners" #3929

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import javax.net.ssl.SSLContext;
import lombok.extern.slf4j.Slf4j;
import org.apache.qpid.jms.JmsConnectionFactory;
import org.apache.qpid.jms.policy.JmsDefaultPrefetchPolicy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
Expand All @@ -14,7 +15,6 @@
import org.springframework.jms.connection.CachingConnectionFactory;
import org.springframework.jms.core.JmsTemplate;


@Configuration
@Slf4j
@EnableJms
Expand All @@ -32,7 +32,9 @@ public ConnectionFactory jmsConnectionFactory(@Value("${spring.application.name}
@Value("${amqp.username}") final String username,
@Value("${amqp.password}") final String password,
@Autowired final String jmsUrlString,
@Autowired(required = false) final SSLContext jmsSslContext) {
@Autowired(required = false) final SSLContext jmsSslContext,
@Value("${amqp.prefetch.override}") final boolean prefetchOverride,
@Value("${amqp.prefetch.topicPrefetch}") final int topicPrefetch) {
JmsConnectionFactory jmsConnectionFactory = new JmsConnectionFactory(jmsUrlString);
jmsConnectionFactory.setUsername(username);
jmsConnectionFactory.setPassword(password);
Expand All @@ -41,7 +43,12 @@ public ConnectionFactory jmsConnectionFactory(@Value("${spring.application.name}
if (jmsSslContext != null) {
jmsConnectionFactory.setSslContext(jmsSslContext);
}

if (prefetchOverride) {
JmsDefaultPrefetchPolicy prefetchPolicy = new JmsDefaultPrefetchPolicy();
prefetchPolicy.setTopicPrefetch(topicPrefetch);
prefetchPolicy.setDurableTopicPrefetch(topicPrefetch);
jmsConnectionFactory.setPrefetchPolicy(prefetchPolicy);
}
return new CachingConnectionFactory(jmsConnectionFactory);
}

Expand All @@ -62,5 +69,4 @@ public JmsListenerContainerFactory topicJmsListenerContainerFactory(ConnectionFa
returnValue.setExceptionListener(t -> log.error("Exception while processing JMS message", t));
return returnValue;
}

}
2 changes: 2 additions & 0 deletions src/main/resources/config/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ amqp.password=${AMQP_PASSWORD:}
amqp.topic=${TOPIC_NAME:sscs-topic}
amqp.subscription=${SUBSCRIPTION_NAME:test.queue}
amqp.trustAllCerts=${TRUST_ALL_CERTS:true}
amqp.prefetch.override=${AMQP_PREFETCH_OVERRIDE:false}
amqp.prefetch.topicPrefetch=${AMQP_TOPIC_PREFETCH:1}

docmosis.template.english.dl6.name=TB-SCS-GNO-ENG-00010.doc
docmosis.template.english.dl16.name=TB-SCS-GNO-ENG-00011.doc
Expand Down