How do I configure endpoints?There are a few different approaches to configuring components and endpoints. Using Java CodeYou can explicitly configure a Component using Java code as shown in this example Or you can explicitly get hold of an Endpoint and configure it using Java code as shown in the Mock endpoint examples. SomeEndpoint endpoint = (SomeEndpoint) camelContext.getEndpoint("someURI"); endpoint.setSomething("aValue"); Using Spring XMLYou can configure your Component or Endpoint instances in your Spring XML as follows. <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> </camelContext> <bean id="activemq" class="org.apache.camel.component.jms.JmsComponent"> <property name="connectionFactory"> <bean class="org.apache.activemq.ActiveMQConnectionFactory"> <property name="brokerURL" value="vm://localhost?broker.persistent=false"/> </bean> </property> </bean> Which allows you to configure a component using some name (activemq in the above example), then you can refer to the component using activemq:[queue:|topic:]destinationName. This works by the SpringCamelContext lazily fetching components from the spring context for the scheme name you use for Endpoint URIs Using Endpoint URIsAnother approach is to use the URI syntax. The URI syntax supports the query notation. So for example with the Mail component you can configure the password property via the URI pop3://host:port?password=foo
See AlsoHow do I add a componentYou might first want to read Writing Components for a background in how to implement a new component. You can then register your component explicitly via CamelContext context = new DefaultCamelContext(); context.addComponent("foo", new FooComponent(context)); However you can use the auto-discovery feature of Camel where by Camel will automatically add a Component when an endpoint URI is used. To do this you would create a file called /META-INF/services/org/apache/camel/component/foo with contents class=org.acme.FooComponent (you can add other property configurations in there too if you like) Then if you refer to an endpoint as foo://somethingOrOther Camel will auto-discover your component and register it. The FooComponent can then be auto-injected with resources using the Injector Working with Spring XMLYou can configure a component via Spring using the following mechanism... <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> </camelContext> <bean id="activemq" class="org.apache.camel.component.jms.JmsComponent"> <property name="connectionFactory"> <bean class="org.apache.activemq.ActiveMQConnectionFactory"> <property name="brokerURL" value="vm://localhost?broker.persistent=false"/> </bean> </property> </bean> Which allows you to configure a component using some name (activemq in the above example), then you can refer to the component using activemq:[queue:|topic:]destinationName. If you want to add explicit Spring 2.x XML objects to your XML then you could use the xbean-spring which tries to automate most of the XML binding work for you; or you could look in camel-spring at CamelNamespaceHandler you'll see how we handle the Spring XML stuff (warning its kinda hairy code to look at See Also |