Skip to content

bhits-dev/fhir-audit-consumer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

fhir-audit-consumer

This project consumes AuditEvents from a messaging service. After the logs are consumed, they are persisted in the Fhir server.

Implementation

Also add a dependency to spring-cloud-starter-stream-rabbit:

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>

In the class where you want to consume the messages, decorate the class with @EnableBinding and use the built-in Sink interface. Next create a method to process any mesages found in the broker. To achieve that, decorate the method with @StreamListener and all the content type handling is done for us. In this case, the received messaged is persisted in Fhir server.

@StreamListener(Sink.INPUT)
public void processVote(AuditEvent auditEvent) {
  auditEventService.publishAuditEvent(auditEvent);
}

The properties for RabbitMQ are specified in application.yml. It tells Spring Cloud Stream how to connect to the broker. We do not need to tell Spring Cloud explicitly to use RabbitMQ; it happens automatically by having that dependency in the classpath. A consumer group auditProcessingGroup has been added. This is used to scale up the subscribers. Also the consumer group subscriptions are durable. It means if the consumer goes offline and messages continue to go that target queue. When a consumer comes back online, it can read from the queue.

Prerequisites

  • Oracle Java JDK 8
  • Apache Maven
  • RabbitMQ. This service can be run in docker using docker run -d -p 15672:15672 -p 5672:5672 rabbitmq:latest.

Build

This project requires Apache Maven to build it. To build the project, navigate to the folder that contains pom.xml file using the terminal/command line.

  • To build a JAR:
    • Run mvn clean package

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages