Skip to content

Commit

Permalink
Revert "Revert "SSCSSI-352 | Fix prefetching issue with service bus t…
Browse files Browse the repository at this point in the history
…opic mes…" (#3929)

This reverts commit 83c3291.
  • Loading branch information
srochani authored Aug 9, 2024
1 parent 51f50b9 commit 8bd0bc6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/java/uk/gov/hmcts/reform/sscs/config/MessagingConfig.java
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

0 comments on commit 8bd0bc6

Please sign in to comment.