The Mercury Framework contains a set of libraries and tools to facilitate the integration between different Service Domains.
Business applications can leverage the Mercury Framework for:
- Application to application communication
- State notification broadcasting (Eventing)
There is a Service Domain specific set of dependencies that can be used depending on the business needs. All libraries use the SmallRye Mutiny reactive framework and are implemented using Quarkus.
The integration between two different service domains is expected to happen using CloudEvents over gRPC. The client service sends a CloudEvent to the target service and the target service understands the command or query received from the CloudEvent Type. The context is extracted from the extension attributes (Service Domain Reference, Control Record, Behaviour Qualifiers, ...) and the service implements the business logic for this Query/Command.
After a record is created/updated in a Service Domain the internal state might change and that change should be broadcasted to other service domains interested in such changes. This will be done through a message channel and the clients will subscribe to it.
This is a common library used by client, events and service libraries. Includes the .proto
files
and the generated Java model for this specific service domain
It also includes the Service and Notification APIs.
Client library to be used for gRPC communication with the Service Domain. Use this library to your project if you need to communicate with a specific service domain through gRPC. e.g.
<dependency>
<groupId>com.redhat.mercury</groupId>
<artifactId>customer-offer-client</artifactId>
</dependency>
After adding this dependency, you can inject the CustomerOfferClient
service that includes a
grpcClient
and talk to the CustomerOffer
service domain.
public class MyService {
@Inject
CustomerOfferClient client;
public void myBusinessLogic() {
client.retrieveCustomerOffer(sdRef, crRef);
}
}
Client library to be used only when need for subscription to the service-domain events. It contains tools to automatically subscribe to a messaging channel.
<dependency>
<groupId>com.redhat.mercury</groupId>
<artifactId>customer-offer-events</artifactId>
</dependency>
Extend the abstract class CustomerOfferNotificationService
for handling each specific event
public MyCustomerOfferNotificationServiceImpl extends CustomerOfferNotificationService {
@Override
public void onCustomerOfferInitiated(CustomerOfferNotification notification) {
// do something
}
}
Used for this specific service domain implementation. Contains the gRPC service endpoints, the state change notification service and the service interfaces to be implemented following the business needs.
<dependency>
<groupId>com.redhat.mercury</groupId>
<artifactId>customer-offer-service</artifactId>
</dependency>
After adding this dependency a Quarkus grpcService
will be added and in your project you will
only have to implement the methods your business logic requires. If a given method is not implemented
a no-op default implementation will be provided for you.
public MyCustomerOffer implements CustomerOfferService {
@Inject
CustomerOfferNotificationService notificationService;
@Override
public Uni<Message> retrieveCustomerOffer(String sdRefId, String crRefId) {
// my business logic here
}
}
You can find a set of demo integrations in the examples folder:
- Customer Credit Rating
- Party Routing Profile
- Customer Offer
- Customer Offer - Kogito