Reusable Route Pattern

Intent

This pattern allows agnostic business logic to be repeatedly used in different service contexts. Reusability is one of the main tenets of object-oriented and functional programming paradigms. It is also one of the main promises of component-based and service-oriented architectures. In this lesson, we will look at this principle from a Camel application point of view, where it expresses itself as the Reusable Route pattern.

Context and problem

Reuse is a common and overrated goal in many software projects to avoid redundancy. It can be implemented at many levels, starting from methods and class level reuse to complex processing flow reuse and complete service reuse (as advertised by SOA). When implementing a complex system composed of multiple services, there might be bits of logic repeated in multiple places, in the same service, or different services. That repetition can vary from small endpoint configuration to complex sets of processing steps. Rather than duplicating the implementation (through copy and paste) and making it harder to maintain in the long term, it is better to reuse a single implementation in multiple places.

Get hands-on with 1200+ tech skills courses.