LibraryLink ToToggle FramesPrintFeedback

Configuring a Component

You can add a component by configuring it in the FUSE Mediation Router Spring configuration file, META-INF/spring/camel-context.xml. To find the component, the component's URI prefix is matched against the ID attribute of a bean element in the Spring configuration. If the component prefix matches a bean element ID, FUSE Mediation Router instantiates the referenced class and injects the properties specified in the Spring configuration.

[Note]Note

This mechanism has priority over auto-discovery. If the CamelContext finds a Spring bean with the requisite ID, it will not attempt to find the component using auto-discovery.

If there are any properties that you want to inject into your component class, define them as bean properties. For example:

public class CustomComponent extends 
  DefaultComponent<CustomExchange> { 
    ...
    PropType getProperty() { ... }
    void setProperty(PropType v) { ...  }
}

The getProperty() method and the setProperty() method access the value of property.

To configure a component in Spring, edit the configuration file, META-INF/spring/camel-context.xml, as shown in Example 4.1.


The bean element with ID component-prefix configures the component-class-name component. You can inject properties into the component instance using property elements. For example, the property element in the preceding example would inject the value, propertyValue, into the property property by calling setProperty() on the component.

Example 4.2 shows an example of how to configure the FUSE Mediation Router's JMS component by defining a bean element with ID equal to jms. These settings are added to the Spring configuration file, camel-context.xml.


1

The CamelContext automatically instantiates any RouteBuilder classes that it finds in the specified Java package, org.apache.camel.example.spring.

2

The bean element with ID, jms, configures the JMS component. The bean ID corresponds to the component's URI prefix. For example, if a route specifies an endpoint with the URI, jms://MyQName, FUSE Mediation Router automatically loads the JMS component using the settings from the jms bean element.

3

JMS is just a wrapper for a messaging service. You must specify the concrete implementation of the messaging system by setting the connectionFactory property on the JmsComponent class.

4

In this example, the concrete implementation of the JMS messaging service is Apache ActiveMQ. The brokerURL property initializes a connection to an ActiveMQ broker instance, where the message broker is embedded in the local Java virtual machine (JVM). If a broker is not already present in the JVM, ActiveMQ will instantiate it with the options broker.persistent=false (the broker does not persist messages) and broker.useJmx=false (the broker does not open a JMX port).