Getting Started with Red Hat build of Apache Camel for Spring Boot Red Hat build of Apache Camel 4.4

Commands:
<dependencyManagement> <dependencies> <!-- Camel BOM --> <dependency> <groupId>com.redhat.camel.springboot.platform</groupId> <artifactId>camel-spring-boot-bom</artifactId> <version>4.4.0.redhat-00039</version> <type>pom</type> <scope>import</scope> </dependency> <!-- ... other BOMs or dependencies ... --> </dependencies> </dependencyManagement>
<dependencies> <!-- Camel Starter --> <dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-spring-boot-starter</artifactId> </dependency> <!-- ... other dependencies ... --> </dependencies>
<dependencies> <!-- ... other dependencies ... --> <dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-paho-mqtt5</artifactId> </dependency> </dependencies>
camel.component.paho-mqtt5.broker-url=tcp://localhost:61616
import org.apache.camel.builder.RouteBuilder; import org.springframework.stereotype.Component; @Component public class MyRoute extends RouteBuilder { @Override public void configure() throws Exception { from("...") .to("..."); } }
<dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-spring-boot</artifactId> <version>4.4.0.redhat-00039</version> <!-- use the same version as your Camel core version --> </dependency>
<dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-spring-boot-bom</artifactId> <version>4.4.0.redhat-00039</version> <!-- use the same version as your Camel core version --> </dependency>
package com.example; import org.apache.camel.builder.RouteBuilder; import org.springframework.stereotype.Component; @Component public class MyRoute extends RouteBuilder { @Override public void configure() throws Exception { from("timer:foo").to("log:bar"); } }
<dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-spring-boot-starter</artifactId> <version>4.4.0.redhat-00039</version> <!-- use the same version as your Camel core version --> </dependency>
@Configuration public class MyAppConfig { @Autowired CamelContext camelContext; @Bean MyService myService() { return new DefaultMyService(camelContext); } }
@Component public class MyRouter extends RouteBuilder { @Override public void configure() throws Exception { from("jms:invoices").to("file:/invoices"); } }
@Configuration public class MyRouterConfiguration { @Bean RoutesBuilder myRouter() { return new RouteBuilder() { @Override public void configure() throws Exception { from("jms:invoices").to("file:/invoices"); } }; } }
route.from = jms:invoices
java -Droute.to=jms:processed.invoices -jar mySpringApp.jar
@Component public class MyRouter extends RouteBuilder { @Override public void configure() throws Exception { from("{{route.from}}").to("{{route.to}}"); } }
@Configuration public class MyAppConfig { @Bean CamelContextConfiguration contextConfiguration() { return new CamelContextConfiguration() { @Override void beforeApplicationStart(CamelContext context) { // your custom configuration goes here } }; } }
@Component public class InvoiceProcessor { @Autowired private ProducerTemplate producerTemplate; @Autowired private ConsumerTemplate consumerTemplate; public void processNextInvoice() { Invoice invoice = consumerTemplate.receiveBody("jms:invoices", Invoice.class); producerTemplate.sendBody("netty-http:http://invoicing.com/received/" + invoice.id()); } }
camel.springboot.consumer-template-cache-size = 100 camel.springboot.producer-template-cache-size = 200
@Component public class InvoiceProcessor { @Autowired private TypeConverter typeConverter; public long parseInvoiceValue(Invoice invoice) { String invoiceValue = invoice.grossValue(); return typeConverter.convertTo(Long.class, invoiceValue); } }
@Component public class InvoiceProcessor { @Autowired private TypeConverter typeConverter; public UUID parseInvoiceId(Invoice invoice) { // Using Spring's StringToUUIDConverter UUID id = invoice.typeConverter.convertTo(UUID.class, invoice.getId()); } }
camel.springboot.main-run-controller = true
turn off camel.springboot.routes-include-pattern = false
scan only in the com/foo/routes classpath camel.springboot.routes-include-pattern = classpath:com/foo/routes/*.xml
<routes xmlns="http://camel.apache.org/schema/spring"> <route id="test"> <from uri="timer://trigger"/> <transform> <simple>ref:myBean</simple> </transform> <to uri="log:out"/> </route> </routes>
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <version>3.2.11</version> <!-- Use the same version as your Spring Boot version --> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-test-spring-junit5</artifactId> <version>4.4.0.redhat-00046</version> <!-- use the same version as your Camel core version --> <scope>test</scope> </dependency>
@CamelSpringBootTest @SpringBootApplication @MockEndpoints("direct:end") public class MyApplicationTest { @Autowired private ProducerTemplate template; @EndpointInject("mock:direct:end") private MockEndpoint mock; @Test public void testReceive() throws Exception { mock.expectedBodiesReceived("Hello"); template.sendBody("direct:start", "Hello"); mock.assertIsSatisfied(); } }
camel.component.paho-mqtt5.broker-url=tcp://localhost:61616
camel.dataformat.csv.delimiter=;
camel.component.jms.transactionManager=#bean:myjtaTransactionManager
@Bean("myjtaTransactionManager") public JmsTransactionManager myjtaTransactionManager(PooledConnectionFactory pool) { JmsTransactionManager manager = new JmsTransactionManager(pool); manager.setDefaultTimeout(45); return manager; }
@Bean("kafka") public KafkaComponent kafka(KafkaConfiguration kafkaconfiguration){ return ComponentsBuilderFactory.kafka() .brokers("{{kafka.host}}:{{kafka.port}}") .build(); }
mvn archetype:generate -DarchetypeGroupId=org.apache.camel.archetypes -DarchetypeArtifactId=camel-archetype-spring-boot -DarchetypeVersion=4.4.0.redhat-00039 -DgroupId=com.redhat -DartifactId=csb-app -Dversion=1.0-SNAPSHOT -DinteractiveMode=false
mvn package -f csb-app/pom.xml
java -jar csb-app/target/csb-app-1.0-SNAPSHOT.jar
com.redhat.MySpringBootApplication : Started MySpringBootApplication in 3.514 seconds (JVM running for 4.006) Hello World Hello World
mvn clean -DskipTests oc:deploy -Popenshift
logs -f dc/csb-app
<build> <plugins> <<plugin> <groupId>com.redhat.camel.springboot.platform</groupId> <artifactId>patch-maven-plugin</artifactId> <version>USD{camel-spring-boot-version}</version> <extensions>true</extensions> </plugin> </plugins> </build>
mvn clean install [INFO] Scanning for projects [INFO] ========== Red Hat Maven patching ========== [INFO] [PATCH] No project in the reactor uses Camel on Spring Boot product BOM. Skipping patch processing. [INFO] [PATCH] Done in 7ms =================================================
mvn clean install [INFO] Scanning for projects [INFO] ========== Red Hat Maven patching ========== [INFO] [PATCH] Reading patch metadata and artifacts from 2 project repositories [INFO] [PATCH] - redhat-ga-repository: http://maven.repository.redhat.com/ga/ [INFO] [PATCH] - central: https://repo.maven.apache.org/maven2 Downloading from redhat-ga-repository: http://maven.repository.redhat.com/ga/com/redhat/camel/springboot/platform/redhat-camel-spring-boot-patch-metadata/maven-metadata.xml Downloading from central: https://repo.maven.apache.org/maven2/com/redhat/camel/springboot/platform/redhat-camel-spring-boot-patch-metadata/maven-metadata.xml [INFO] [PATCH] Resolved patch descriptor: /path/to/.m2/repository/com/redhat/camel/springboot/platform/redhat-camel-spring-boot-patch-metadata/3.20.1.redhat-00043/redhat-camel-spring-boot-patch-metadata-3.20.1.redhat-00043.xml [INFO] [PATCH] Patch metadata found for com.redhat.camel.springboot.platform/camel-spring-boot-bom/[3.20,3.21) [INFO] [PATCH] Done in 938ms =================================================
<?xml version="1.0" encoding="UTF-8"?> <metadata> <groupId>com.redhat.camel.springboot.platform</groupId> <artifactId>redhat-camel-spring-boot-patch-metadata</artifactId> <versioning> <release>3.20.1.redhat-00041</release> <versions> <version>3.20.1.redhat-00041</version> </versions> <lastUpdated>20230322103858</lastUpdated> </versioning> </metadata>
mvn clean install [INFO] Scanning for projects [INFO] ========== Red Hat Maven patching ========== [INFO] [PATCH] Reading patch metadata and artifacts from 2 project repositories [INFO] [PATCH] - MRRC-GA: https://maven.repository.redhat.com/ga [INFO] [PATCH] - central: https://repo.maven.apache.org/maven2
<?xml version="1.0" encoding="UTF-8" ?> <<metadata xmlns="urn:redhat:patch-metadata:1"> <product-bom groupId="com.redhat.camel.springboot.platform" artifactId="camel-spring-boot-bom" versions="[3.20,3.21)" /> <cves> </cves> <fixes> <fix id="HF0-1" description="logback-classic (Example) - Version Bump"> <affects groupId="ch.qos.logback" artifactId="logback-classic" versions="[1.0,1.3.0)" fix="1.3.0" /> </fix> </fixes> </metadata>
mvn dependency:tree [INFO] Scanning for projects [INFO] ========== Red Hat Maven patching ========== [INFO] [PATCH] Reading patch metadata and artifacts from 3 project repositories [INFO] [PATCH] - redhat-ga-repository: http://maven.repository.redhat.com/ga/ [INFO] [PATCH] - local: file:///path/to/.m2/repository [INFO] [PATCH] - central: https://repo.maven.apache.org/maven2 [INFO] [PATCH] Resolved patch descriptor:/path/to/.m2/repository/com/redhat/camel/springboot/platform/redhat-camel-spring-boot-patch-metadata/3.20.1.redhat-00043/redhat-camel-spring-boot-patch-metadata-3.20.1.redhat-00043.xml [INFO] [PATCH] Patch metadata found for com.redhat.camel.springboot.platform/camel-spring-boot-bom/[3.20,3.21) [INFO] [PATCH] - patch contains 1 patch fix [INFO] [PATCH] Processing managed dependencies to apply patch fixes [INFO] [PATCH] - HF0-1: logback-classic (Example) - Version Bump [INFO] [PATCH] Applying change ch.qos.logback/logback-classic/[1.0,1.3.0) -> 1.3.0 [INFO] [PATCH] Project com.test:yaml-routes [INFO] [PATCH] - managed dependency: ch.qos.logback/logback-classic/1.2.11 -> 1.3.0 [INFO] [PATCH] Done in 39ms =================================================
<build> <plugins> <plugin> <groupId>com.redhat.camel.springboot.platform</groupId> <artifactId>patch-maven-plugin</artifactId> <version>USD{camel-spring-boot-version}</version> <extensions>true</extensions> <configuration> <skip>true</skip> </configuration> </plugin> </plugins> </build>
mvn clean install -DskipPatch [INFO] Scanning for projects [INFO] [INFO] -------------------------< com.example:test-csb >------------------------- [INFO] Building A Camel Spring Boot Route 1.0-SNAPSHOT
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.camel</groupId> <artifactId>camel-restdsl-openapi-plugin</artifactId> <version>{CamelCommunityVersion}</version> </plugin> </plugins> </build>
USDmvn camel-restdsl-openapi:generate
<dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.10.1</version> </dependency> <dependency> <groupId>io.swagger.core.v3</groupId> <artifactId>swagger-core</artifactId> <version>2.2.8</version> </dependency> <dependency> <groupId>org.threeten</groupId> <artifactId>threetenbp</artifactId> <version>1.6.8</version> </dependency>
<dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.10.1</version> </dependency> <dependency> <groupId>io.swagger.core.v3</groupId> <artifactId>swagger-core</artifactId> <version>2.2.8</version> </dependency> <dependency> <groupId>org.threeten</groupId> <artifactId>threetenbp</artifactId> <version>1.6.8</version> </dependency>
<dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.10.1</version> </dependency> <dependency> <groupId>io.swagger.core.v3</groupId> <artifactId>swagger-core</artifactId> <version>2.2.8</version> </dependency> <dependency> <groupId>org.threeten</groupId> <artifactId>threetenbp</artifactId> <version>1.6.8</version> </dependency>
mvn --version
<?xml version="1.0"?> <settings> <profiles> <profile> <id>extra-repos</id> <activation> <activeByDefault>true</activeByDefault> </activation> <repositories> <repository> <id>redhat-ga-repository</id> <url>https://maven.repository.redhat.com/ga</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>redhat-ea-repository</id> <url>https://maven.repository.redhat.com/earlyaccess/all</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>atlassian</id> <url>https://packages.atlassian.com/artifactory/maven-public/</url> <name>atlassian external repo</name> <snapshots> <enabled>false</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>redhat-ga-repository</id> <url>https://maven.repository.redhat.com/ga</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> <pluginRepository> <id>redhat-ea-repository</id> <url>https://maven.repository.redhat.com/earlyaccess/all</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <activeProfile>extra-repos</activeProfile> </activeProfiles> </settings>
├── README ├── build-offline-repo.sh ├── errors.log ├── logback.xml ├── maven-repositories.txt ├── offliner-2.0-sources.jar ├── offliner-2.0-sources.jar.md5 ├── offliner-2.0.jar ├── offliner-2.0.jar.md5 ├── offliner.log ├── rhaf-camel-offliner-4.4.0.txt └── rhaf-camel-spring-boot-offliner-4.4.0.txt
mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.0:go-offline -Dmaven.repo.local=/tmp/my-project
<mirror> <id>all</id> <mirrorOf>*</mirrorOf> <url>http://host:port/path</url> </mirror>
groupId:artifactId:version groupId:artifactId:packaging:version groupId:artifactId:packaging:classifier:version
<project ... > <groupId>org.fusesource.example</groupId> <artifactId>bundle-demo</artifactId> <packaging>bundle</packaging> <version>1.0-SNAPSHOT</version> </project>
<project ... > <dependencies> <dependency> <groupId>org.fusesource.example</groupId> <artifactId>bundle-demo</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> </project>
login --user system:admin --token=my-token --server=https://my-cluster.example.com:6443
oc -n openshift-monitoring edit configmap cluster-monitoring-config
apiVersion: v1 kind: ConfigMap metadata: name: cluster-monitoring-config namespace: openshift-monitoring data: config.yaml: | enableUserWorkload: true
oc -n openshift-user-workload-monitoring get pod Example output NAME READY STATUS RESTARTS AGE prometheus-operator-6f7b748d5b-t7nbg 2/2 Running 0 3h prometheus-user-workload-0 4/4 Running 1 3h prometheus-user-workload-1 4/4 Running 1 3h thanos-ruler-user-workload-0 3/3 Running 0 3h thanos-ruler-user-workload-1 3/3 Running 0 3h
<profiles> <profile> <id>openshift</id> <build> <plugins> <plugin> <groupId>org.eclipse.jkube</groupId> <artifactId>openshift-maven-plugin</artifactId> <version>1.13.1</version> <executions> <execution> <goals> <goal>resource</goal> <goal>build</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles>
expose actuator endpoint via HTTP management.endpoints.web.exposure.include=mappings,metrics,health,shutdown,jolokia,prometheus
<dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-registry-prometheus</artifactId> </dependency> <dependency> <groupId>org.jolokia</groupId> <artifactId>jolokia-core</artifactId> <version>USD{jolokia-version}</version> </dependency> <dependency> <groupId>io.prometheus.jmx</groupId> <artifactId>collector</artifactId> <version>USD{prometheus-version}</version> </dependency>
import org.springframework.context.annonation.Bean; import org.apache.camel.component.micrometer.MicrometerConstants; import org.apache.camel.component.micrometer.eventnotifier.MicrometerExchangeEventNotifier; import org.apache.camel.component.micrometer.eventnotifier.MicrometerRouteEventNotifier; import org.apache.camel.component.micrometer.messagehistory.MicrometerMessageHistoryFactory; import org.apache.camel.component.micrometer.routepolicy.MicrometerRoutePolicyFactory;
@SpringBootApplication public class SampleCamelApplication { @Bean(name = {MicrometerConstants.METRICS_REGISTRY_NAME, "prometheusMeterRegistry"}) public PrometheusMeterRegistry prometheusMeterRegistry( PrometheusConfig prometheusConfig, CollectorRegistry collectorRegistry, Clock clock) throws MalformedObjectNameException, IOException { InputStream resource = new ClassPathResource("config/prometheus_exporter_config.yml").getInputStream(); new JmxCollector(resource).register(collectorRegistry); new BuildInfoCollector().register(collectorRegistry); return new PrometheusMeterRegistry(prometheusConfig, collectorRegistry, clock); } @Bean public CamelContextConfiguration camelContextConfiguration(@Autowired PrometheusMeterRegistry registry) { return new CamelContextConfiguration() { @Override public void beforeApplicationStart(CamelContext camelContext) { MicrometerRoutePolicyFactory micrometerRoutePolicyFactory = new MicrometerRoutePolicyFactory(); micrometerRoutePolicyFactory.setMeterRegistry(registry); camelContext.addRoutePolicyFactory(micrometerRoutePolicyFactory); MicrometerMessageHistoryFactory micrometerMessageHistoryFactory = new MicrometerMessageHistoryFactory(); micrometerMessageHistoryFactory.setMeterRegistry(registry); camelContext.setMessageHistoryFactory(micrometerMessageHistoryFactory); MicrometerExchangeEventNotifier micrometerExchangeEventNotifier = new MicrometerExchangeEventNotifier(); micrometerExchangeEventNotifier.setMeterRegistry(registry); camelContext.getManagementStrategy().addEventNotifier(micrometerExchangeEventNotifier); MicrometerRouteEventNotifier micrometerRouteEventNotifier = new MicrometerRouteEventNotifier(); micrometerRouteEventNotifier.setMeterRegistry(registry); camelContext.getManagementStrategy().addEventNotifier(micrometerRouteEventNotifier); } @Override public void afterApplicationStart(CamelContext camelContext) { } }; }
mvn -Popenshift oc:deploy
get pods -n myapp NAME READY STATUS RESTARTS AGE camel-example-spring-boot-xml-2-deploy 0/1 Completed 0 13m camel-example-spring-boot-xml-2-x78rk 1/1 Running 0 13m camel-example-spring-boot-xml-s2i-2-build 0/1 Completed 0 14m
apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: labels: k8s-app: csb-demo-monitor name: csb-demo-monitor spec: endpoints: - interval: 30s port: http scheme: http path: /actuator/prometheus selector: matchLabels: app: camel-example-spring-boot-xml
apply -f servicemonitor.yml servicemonitor.monitoring.coreos.com/csb-demo-monitor "myapp" created
get servicemonitor NAME AGE csb-demo-monitor 9m17s
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd "> <camelContext xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="direct:a"/> <choice> <when> <xpath>USDfoo = 'bar'</xpath> <to uri="direct:b"/> </when> <when> <xpath>USDfoo = 'cheese'</xpath> <to uri="direct:c"/> </when> <otherwise> <to uri="direct:d"/> </otherwise> </choice> </route> </camelContext> </beans>
<camelContext xmlns="http://camel.apache.org/schema/spring"> <routeBuilder ref="myBuilder"/> </camelContext> <bean id="myBuilder" class="org.apache.camel.spring.example.test1.MyRouteBuilder"/>
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; /** * A Configuration class that import the Spring XML resource */ @Configuration // load the spring xml file from classpath @ImportResource("classpath:camel-context.xml") public class CamelSpringXMLConfiguration { }
<camelContext id="camel-A" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="seda:start"/> <to uri="mock:result"/> </route> </camelContext>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> </camelContext> <bean id="jmsConnectionFactory" class="org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory"> <property name="brokerURL" value="tcp:someserver:61616"/> </bean> <bean id="jms" class="org.apache.camel.component.jms.JmsComponent"> <property name="connectionFactory"> <bean class="org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory"> <property name="brokerURL" value="tcp:someserver:61616"/> </bean> </property> </bean>
<camelContext> <packageScan> <package>com.foo</package> <excludes>**.*Excluded*</excludes> <includes>**.*</includes> </packageScan> </camelContext>
<camelContext> <packageScan> <package>com.foo</package> <excludes>**.*Special*</excludes> </packageScan> </camelContext>
<!-- enable Spring @Component scan --> <context:component-scan base-package="org.apache.camel.spring.issues.contextscan"/> <camelContext xmlns="http://camel.apache.org/schema/spring"> <!-- and then let Camel use those @Component scanned route builders --> <contextScan/> </camelContext>
@Component public class MyRoute extends RouteBuilder { @Override public void configure() throws Exception { from("direct:start") .to("mock:result"); } }
<routes xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="timer:tick"/> <setBody> <constant>Hello Camel K!</constant> </setBody> <to uri="log:info"/> </route> </routes>
kamel run my-route.xml
camel run my-route.xml
<camel> <bean name="beanFromProps" type="com.acme.MyBean"> <properties> <property key="field1" value="f1_p" /> <property key="field2" value="f2_p" /> <property key="nested.field1" value="nf1_p" /> <property key="nested.field2" value="nf2_p" /> </properties> </bean> </camel>
<camel> <beans xmlns="http://www.springframework.org/schema/beans"> <bean id="messageString" class="java.lang.String"> <constructor-arg index="0" value="Hello"/> </bean> <bean id="greeter" class="org.apache.camel.main.app.Greeter"> <description>Spring Bean</description> <property name="message"> <bean class="org.apache.camel.main.app.GreeterMessage"> <property name="msg" ref="messageString"/> </bean> </property> </bean> </beans> <route id="my-route"> <from uri="direct:start"/> <bean ref="greeter"/> <to uri="mock:finish"/> </route> </camel>
<camel> <bean name="beanFromProps" type="com.acme.MyBean"> <constructors> <constructor index="0" value="true"/> <constructor index="1" value="Hello World"/> </constructors> <!-- and you can still have properties --> <properties> <property key="field1" value="f1_p" /> <property key="field2" value="f2_p" /> <property key="nested.field1" value="nf1_p" /> <property key="nested.field2" value="nf2_p" /> </properties> </bean> </camel>
<bean name="beanFromProps" type="com.acme.MyBean(true, 'Hello World')"> <properties> <property key="field1" value="f1_p" /> <property key="field2" value="f2_p" /> <property key="nested.field1" value="nf1_p" /> <property key="nested.field2" value="nf2_p" /> </properties> </bean>
<bean name="myBean" type="com.acme.MyBean" factoryMethod="createMyBean"> <constructors> <constructor index="0" value="true"/> <constructor index="1" value="Hello World"/> </constructors> </bean>
public class MyBean { public static MyBean createMyBean(boolean important, String message) { MyBean answer = // create and configure the bean return answer; } }
<bean name="myBean" type="com.acme.MyBean" builderClass="com.acme.MyBeanBuilder" builderMethod="createMyBean"> <properties> <property key="id" value="123"/> <property key="name" value="Acme"/> </constructors> </bean>
<bean name="myBean" type="com.acme.MyBean" factoryBean="com.acme.MyHelper" factoryMethod="createMyBean"> <constructors> <constructor index="0" value="true"/> <constructor index="1" value="Hello World"/> </constructors> </bean>
public class MyHelper { public static MyBean createMyBean(boolean important, String message) { MyBean answer = // create and configure the bean return answer; } }
<bean name="myBean" type="com.acme.MyBean" scriptLanguage="groovy"> <script> // some groovy script here to create the bean bean = return bean </script> </bean>
public class MyBean { public void initMe() { // do init work here } public void destroyMe() { // do cleanup work here } }
<bean name="myBean" type="com.acme.MyBean" initMethod="initMe" destroyMethod="destroyMe"> <constructors> <constructor index="0" value="true"/> <constructor index="1" value="Hello World"/> </constructors> </bean>
<camel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://camel.apache.org/schema/spring" xsi:schemaLocation=" http://camel.apache.org/schema/spring https://camel.apache.org/schema/spring/camel-spring.xsd"> <rest id="rest"> <post id="post" path="start"> <to uri="direct:start"/> </post> </rest> <route> <from uri="direct:start"/> <to uri="amqp:queue:Test.Broker.StreamMessage?jmsMessageType=Stream&amp;disableReplyTo=true"/> </route> </camel>