This section gives a brief overview of the steps required to implement a FUSE Mediation Router custom component.
When implementing a component, it is almost always necessary to implement the following Java interfaces:
org.apache.camel.Component
org.apache.camel.Endpoint
org.apache.camel.Consumer
org.apache.camel.Producer
In addition, it is sometimes also necessary to implement the following Java interfaces:
org.apache.camel.Exchange
org.apache.camel.Message
In outline, you would typically implement a custom component as follows:
Implement the Component interface—a component object acts
as an endpoint factory. Derive from the DefaultComponent class and
implement the createEndpoint() method.
See Chapter 5.
Implement the Endpoint interface—an endpoint represents a resource identified by a specific URI. The approach you take to implementing an endpoint depends on whether your consumers follow an event-driven pattern, a scheduled poll pattern, or a polling pattern.
For an event-driven pattern, implement the endpoint by inheriting from DefaultEndpoint and implementing the following methods:
createProducer().
createConsumer().
For a scheduled poll pattern, implement the endpoint by inheriting from ScheduledPollEndpoint and implementing the following methods:
createProducer().
createConsumer().
For a polling pattern, implement the endpoint by inheriting from DefaultPollingEndpoint and implementing the following methods:
createProducer().
createPollConsumer().
See Chapter 6.
Implement the Consumer interface—there are several different approaches you can take to implementing a consumer, depending on whether you need to implement an event-driven pattern, a scheduled poll pattern, or a polling pattern. The consumer implementation is also crucially important for determining the threading model used for processing a message exchange.
Implement the Producer interface—to implement a producer,
derive from the DefaultProducer class and implement the process() method.
See Chapter 8.
(Optionally) Implement Exchange or Message
interfaces—frequently, the default implementations of Exchange and Message can be used directly. Occasionally,
you might find it necessary to customize these types.
See Chapter 9 and Chapter 10.
You can install a custom component in one of the following ways:
Add the component directly to the CamelContext—use the
CamelContext.addComponent() method to add a component
programatically. For more details, see Adding Components to the Camel Context in the Deployment Guide.
Add the component using Spring configuration—use the
standard Spring bean element to create a component instance. The bean's
id attribute implicitly defines the component prefix. For details, see
Configuring a Component.
Configure Mediation Router to auto-discover the component—using auto-discovery, you can ensure that Mediation Router automatically loads the component on demand. For details, see Setting Up Auto-Discovery.