Skip to content

Commit

Permalink
APID-647: add logging of incoming request, stop scheduled jobs loggin…
Browse files Browse the repository at this point in the history
…g noise at info, tidy (#63)
  • Loading branch information
worthydolt authored Dec 9, 2022
1 parent 4943406 commit d495e43
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,22 @@ import uk.gov.hmrc.apiplatformoutboundsoap.services.OutboundService
import uk.gov.hmrc.http.NotFoundException
import uk.gov.hmrc.play.bootstrap.backend.controller.BackendController
import uk.gov.hmrc.play.bootstrap.backend.http.ErrorResponse

import javax.inject.{Inject, Singleton}
import javax.wsdl.WSDLException
import play.api.Logging

import scala.concurrent.ExecutionContext

@Singleton
class OutboundController @Inject()(cc: ControllerComponents,
appConfig: AppConfig,
outboundService: OutboundService)
(implicit ec: ExecutionContext)
extends BackendController(cc) {
extends BackendController(cc) with Logging {

def message(): Action[JsValue] = Action.async(parse.json) { implicit request =>
withJsonBody[MessageRequest] { messageRequest =>
logger.info(s"Received request to send message to CCN2. Message body is $messageRequest")
val codValue = messageRequest.confirmationOfDelivery match {
case Some(cod) => cod
case None => appConfig.confirmationOfDelivery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package uk.gov.hmrc.apiplatformoutboundsoap.models

import uk.gov.hmrc.apiplatformoutboundsoap.utils.Require.validate

case class MessageRequest(wsdlUrl: String,
case class MessageRequest(wsdlUrl: String,
wsdlOperation: String,
messageBody: String,
addressing: Addressing,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ trait RunningOfScheduledJobs extends Logging {
scheduler.scheduleWithFixedDelay(job.initialDelay, job.interval)(() => {
val stopWatch = new StopWatch
stopWatch.start()
logger.info(s"Executing job ${job.name}")
logger.debug(s"Executing job ${job.name}")

job.execute.onComplete {
case Success(job.Result(message)) =>
stopWatch.stop()
logger.info(s"Completed job ${job.name} in $stopWatch: $message")
logger.debug(s"Completed job ${job.name} in $stopWatch: $message")
case Failure(throwable) =>
stopWatch.stop()
logger.error(s"Exception running job ${job.name} after $stopWatch", throwable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ import play.api.test.Helpers.{await, defaultAwaitTimeout}
import uk.gov.hmrc.apiplatformoutboundsoap.models._
import uk.gov.hmrc.mongo.play.json.PlayMongoRepository
import uk.gov.hmrc.mongo.test.PlayMongoRepositorySupport

import java.time.{Duration, Instant}
import java.util.UUID.randomUUID

import org.scalatest.concurrent.IntegrationPatience

class OutboundMessageRepositoryISpec extends AnyWordSpec with PlayMongoRepositorySupport[OutboundSoapMessage] with
Matchers with BeforeAndAfterEach with GuiceOneAppPerSuite {
Matchers with BeforeAndAfterEach with GuiceOneAppPerSuite with IntegrationPatience {
val serviceRepo = repository.asInstanceOf[OutboundMessageRepository]

override implicit lazy val app: Application = appBuilder.build()
Expand Down

0 comments on commit d495e43

Please sign in to comment.