Skip to content

Commit

Permalink
Merge pull request #474 from Health-Education-England/chore/removeRed…
Browse files Browse the repository at this point in the history
…undantConfig_NO-CARD

Chore/remove redundant config no card
  • Loading branch information
JosephKelly authored Nov 20, 2023
2 parents 8d50c6c + 56c79c8 commit d4bc79d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,85 +23,27 @@

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();
return new Jackson2JsonMessageConverter(mapper);
}

@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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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");
}

Expand Down

0 comments on commit d4bc79d

Please sign in to comment.