diff --git a/application/src/main/java/uk/nhs/hee/tis/revalidation/RevalidationApplication.java b/application/src/main/java/uk/nhs/hee/tis/revalidation/RevalidationApplication.java index 417bc968..0257d076 100644 --- a/application/src/main/java/uk/nhs/hee/tis/revalidation/RevalidationApplication.java +++ b/application/src/main/java/uk/nhs/hee/tis/revalidation/RevalidationApplication.java @@ -31,6 +31,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.data.elasticsearch.core.query.NativeSearchQuery; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; +import org.springframework.oxm.Unmarshaller; import org.springframework.oxm.jaxb.Jaxb2Marshaller; import org.springframework.web.client.RestTemplate; import org.springframework.ws.client.core.WebServiceTemplate; @@ -65,10 +66,10 @@ public Jaxb2Marshaller marshaller() { } @Bean - public WebServiceTemplate webServiceTemplate() { + public WebServiceTemplate webServiceTemplate(Unmarshaller unmarshaller) { final var webServiceTemplate = new WebServiceTemplate(); webServiceTemplate.setMarshaller(marshaller()); - webServiceTemplate.setUnmarshaller(marshaller()); + webServiceTemplate.setUnmarshaller(unmarshaller); return webServiceTemplate; } diff --git a/application/src/main/java/uk/nhs/hee/tis/revalidation/config/RabbitConfig.java b/application/src/main/java/uk/nhs/hee/tis/revalidation/config/RabbitConfig.java index afadd220..3812abb1 100644 --- a/application/src/main/java/uk/nhs/hee/tis/revalidation/config/RabbitConfig.java +++ b/application/src/main/java/uk/nhs/hee/tis/revalidation/config/RabbitConfig.java @@ -23,75 +23,16 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.amqp.core.AcknowledgeMode; -import org.springframework.amqp.core.Binding; -import org.springframework.amqp.core.BindingBuilder; -import org.springframework.amqp.core.DirectExchange; -import org.springframework.amqp.core.Queue; import org.springframework.amqp.rabbit.connection.ConnectionFactory; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; import org.springframework.amqp.support.converter.MessageConverter; -import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class RabbitConfig { - @Value("${app.rabbit.queue}") - private String queueName; - - @Value("${app.rabbit.exchange}") - private String exchange; - - @Value("${app.rabbit.routingkey}") - private String routingKey; - - @Value("${app.rabbit.connection.routingkey}") - private String removeDbcRoutingKey; - - @Value("${app.rabbit.reval.exchange}") - private String revalExchange; - - @Value("${app.rabbit.reval.queue.recommendation.syncstart}") - private String recommendationGmcSyncStartQueue; - - @Value("${app.rabbit.reval.routingKey.recommendation.syncstart}") - private String recommendationGmcSyncStartKey; - - @Bean - public Queue queue() { - return new Queue(queueName, false); - } - - @Bean - public DirectExchange exchange() { - return new DirectExchange(exchange); - } - - - @Bean - public Queue recommendationRevalQueue() { - return new Queue(recommendationGmcSyncStartQueue, false); - } - - @Bean - public DirectExchange revalExchange() { - return new DirectExchange(revalExchange); - } - - @Bean - public Binding revalidationBinding(final Queue recommendationRevalQueue, - final DirectExchange revalExchange) { - return BindingBuilder.bind(recommendationRevalQueue).to(revalExchange) - .with(recommendationGmcSyncStartKey); - } - - @Bean - public Binding binding(final Queue queue, final DirectExchange exchange) { - return BindingBuilder.bind(queue).to(exchange).with(routingKey); - } - @Bean public MessageConverter jsonMessageConverter() { final ObjectMapper mapper = new ObjectMapper().findAndRegisterModules(); @@ -99,9 +40,10 @@ public MessageConverter jsonMessageConverter() { } @Bean - public RabbitTemplate rabbitTemplate(final ConnectionFactory connectionFactory) { + public RabbitTemplate rabbitTemplate(final ConnectionFactory connectionFactory, + MessageConverter jsonMessageConverter) { final var rabbitTemplate = new RabbitTemplate(connectionFactory); - rabbitTemplate.setMessageConverter(jsonMessageConverter()); + rabbitTemplate.setMessageConverter(jsonMessageConverter); rabbitTemplate.containerAckMode(AcknowledgeMode.AUTO); return rabbitTemplate; } diff --git a/application/src/main/java/uk/nhs/hee/tis/revalidation/service/GmcDoctorNightlySyncService.java b/application/src/main/java/uk/nhs/hee/tis/revalidation/service/GmcDoctorNightlySyncService.java index 61b2dd03..79d812d0 100644 --- a/application/src/main/java/uk/nhs/hee/tis/revalidation/service/GmcDoctorNightlySyncService.java +++ b/application/src/main/java/uk/nhs/hee/tis/revalidation/service/GmcDoctorNightlySyncService.java @@ -10,9 +10,9 @@ @Service public class GmcDoctorNightlySyncService { - private GmcDoctorsForDbSyncStartPublisher gmcDoctorsForDbSyncStartPublisher; + private final GmcDoctorsForDbSyncStartPublisher gmcDoctorsForDbSyncStartPublisher; - private DoctorsForDBService doctorsForDBService; + private final DoctorsForDBService doctorsForDBService; public GmcDoctorNightlySyncService( DoctorsForDBService doctorsForDBService, @@ -22,12 +22,12 @@ public GmcDoctorNightlySyncService( this.doctorsForDBService = doctorsForDBService; } - @Scheduled(cron="${app.gmc.nightlySyncStart.cronExpression}") + @Scheduled(cron = "${app.gmc.nightlySyncStart.cronExpression}") @SchedulerLock(name = "GmcNightlySyncJob") public void startNightlyGmcDoctorSync() { - this.doctorsForDBService.hideAllDoctors(); + doctorsForDBService.hideAllDoctors(); log.info("All doctors are hidden now"); - this.gmcDoctorsForDbSyncStartPublisher.publishNightlySyncStartMessage(); + gmcDoctorsForDbSyncStartPublisher.publishNightlySyncStartMessage(); log.info("Start message has been sent to start gmc sync"); }