generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* PI-2605 Send domain events for address changes * Formatting changes --------- Co-authored-by: probation-integration-bot[bot] <177347787+probation-integration-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
6b9090f
commit 5da437f
Showing
18 changed files
with
324 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...ed-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/messaging/Notifier.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package uk.gov.justice.digital.hmpps.messaging | ||
|
||
import org.openfolder.kotlinasyncapi.annotation.Schema | ||
import org.openfolder.kotlinasyncapi.annotation.channel.Channel | ||
import org.openfolder.kotlinasyncapi.annotation.channel.Message | ||
import org.openfolder.kotlinasyncapi.annotation.channel.Subscribe | ||
import org.springframework.beans.factory.annotation.Qualifier | ||
import org.springframework.stereotype.Service | ||
import uk.gov.justice.digital.hmpps.message.* | ||
import uk.gov.justice.digital.hmpps.publisher.NotificationPublisher | ||
|
||
@Service | ||
@Channel("hmpps-domain-events-topic") | ||
class Notifier(@Qualifier("topicPublisher") private val topicPublisher: NotificationPublisher) { | ||
@Subscribe( | ||
messages = [ | ||
Message(title = "probation-case.address.created", payload = Schema(HmppsDomainEvent::class)), | ||
Message(title = "probation-case.address.updated", payload = Schema(HmppsDomainEvent::class)) | ||
] | ||
) | ||
fun addressCreated(crn: String, addressId: Long, addressStatus: String) { | ||
topicPublisher.publish( | ||
Notification( | ||
message = HmppsDomainEvent( | ||
version = 1, | ||
eventType = "probation-case.address.created", | ||
description = "A new address has been created on the probation case", | ||
personReference = PersonReference( | ||
identifiers = listOf( | ||
PersonIdentifier("CRN", crn), | ||
), | ||
), | ||
additionalInformation = mapOf( | ||
"addressStatus" to addressStatus, | ||
"addressId" to addressId | ||
) | ||
), | ||
attributes = MessageAttributes("probation-case.address.created") | ||
) | ||
) | ||
} | ||
|
||
fun addressUpdated(crn: String, addressId: Long, addressStatus: String) { | ||
topicPublisher.publish( | ||
Notification( | ||
message = HmppsDomainEvent( | ||
version = 1, | ||
eventType = "probation-case.address.updated", | ||
description = "An address has been updated on the probation case", | ||
personReference = PersonReference( | ||
identifiers = listOf( | ||
PersonIdentifier("CRN", crn), | ||
), | ||
), | ||
additionalInformation = mapOf( | ||
"addressStatus" to addressStatus, | ||
"addressId" to addressId | ||
) | ||
), | ||
attributes = MessageAttributes("probation-case.address.updated") | ||
) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.