Microservice Endpoints¶
The preferred mechanism for extending the point of sale is by implementing our microservice endpoints. Endpoints are first-class citizens in JMC, offering well-defined contracts the point of sale adheres to, making them an excellent point for extending functionality.
Examples of overriding endpoints include:
- Payment: Provide a different implementation of payment providers
- Customer: Integrate with CRM and loyalty backend solutions
- Orders: Integrate with OMS and E-commerce
Configure¶
See the developer microservice documentation for more details on how to configure new implementations of endpoints.
Approaches¶
There are a couple of different approaches to providing a different implementation of an endpoint.
-
Java-Based Implementation: The most common mechanism is to provide an alternate Java-based implementation of an endpoint.
-
REST API over HTTP: Another approach is to interface directly with the REST API over HTTP. This approach eliminates any dependencies on the JMC framework. Simply configure the endpoint to be remote and specify the URL to call. The implementor can create the implementation in whatever technology is appropriate for that particular customer.
Java-Based Implementation¶
Endpoint implementation can be defined in the YAML configuration. JMC will prefer a version of the endpoint that matches the specified implementation over the default implementation in the YAML configuration. If an endpoint implementation cannot be found, then the default implementation will be loaded.
If multiple implementations are found then the endpoint that is used will be decided in the following order of precedence.
- An
@Endpointimplementation that also has@EndpointOverridewill be given the highest priority. - Then whichever of these returns a non-null value that will be sorted in ascending order.
- Implementing
org.springframework.core.PriorityOrdered - Implementing
org.springframework.core.Ordered - Having
@org.springframework.core.annotation.Orderdirectly on the endpoint class
- Implementing
- Everything else will not be guaranteed to have a specific order.
Best Practices¶
- The best choice for extending JMC is by using Endpoints.
Anti-patterns¶
- Developers should avoid subclassing an endpoint and relying on protected methods to change functionality.