Hello.

I'm testing Camel routes that work as expected with Camel 2.25 and
fail with Camel 3.18, both running on Karaf 4.4.2.

I have a very strange behavior with the component "master". I create a
File Lock instance of CamelClusterService and expose it as a service
in a bundle. Then another bundle with a blueprint containing the Camel
context gets a reference on the service to provide it for master
endpoints.

When the context is built, first logs say that the service is used and
even that two instances (the same twice) are resolved :
16:29:27.218 INFO [Blueprint Extender: 3] Using CamelClusterService
with id: null and implementation:
org.apache.camel.component.file.cluster.FileLockClusterService@2b6df8e6
16:29:27.220 INFO [Blueprint Extender: 3] Using CamelClusterService
with id: null and implementation:
org.apache.camel.component.file.cluster.FileLockClusterService@2b6df8e6
16:29:27.535 WARN [Blueprint Event Dispatcher: 1] Multiple
CamelClusterService instances available
(items=[org.apache.camel.component.file.cluster.FileLockClusterService@2b6df8e6,
org.apache.camel.component.file.cluster.FileLockClusterService@2b6df8e6])

But when the context is supposed to start, an error says that no
service is found :
16:29:27.552 ERROR [Blueprint Event Dispatcher: 1] Error occurred
during starting CamelContext: KT1
org.apache.camel.FailedToCreateRouteException: Failed to create route
KT1-File: Route(KT1-File)[From[master:K1-FILE:file://{{my.input-folder...
because of Failed to resolve endpoint:
master://K1-FILE:file:///SHARE/data/input?delete=true&moveFailed=.ERROR
due to: No cluster service found
        at 
org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:81)
~[?:?]
        at 
org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49)
~[?:?]
        at 
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:878)
~[?:?]
        at 
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:766)
~[?:?]
        at 
org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2947)
~[?:?]
        at 
org.apache.camel.support.service.BaseService.init(BaseService.java:83)
~[?:?]
        at 
org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2630)
~[?:?]
        at 
org.apache.camel.support.service.BaseService.start(BaseService.java:111)
~[?:?]
        at 
org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2649)
~[?:?]
        at 
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:262)
~[?:?]
        at 
org.apache.camel.blueprint.BlueprintCamelContext.start(BlueprintCamelContext.java:241)
~[?:?]
        at 
org.apache.camel.blueprint.BlueprintCamelContext.maybeStart(BlueprintCamelContext.java:283)
~[?:?]
        at 
org.apache.camel.blueprint.BlueprintCamelContext.blueprintEvent(BlueprintCamelContext.java:188)
~[?:?]
        at 
org.apache.aries.blueprint.container.BlueprintEventDispatcher$3.call(BlueprintEventDispatcher.java:197)
~[?:?]
        at 
org.apache.aries.blueprint.container.BlueprintEventDispatcher$3.call(BlueprintEventDispatcher.java:195)
~[?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
        at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
~[?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
        at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
~[?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
        at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
~[?:?]
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
~[?:?]
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
~[?:?]
        at java.lang.Thread.run(Thread.java:829) ~[?:?]

I attach the 2 blueprints with the service creation and the routes...

Some idea of what changes between Camel versions for "master" ?

Thanks for your help.

Regards.
<?xml version="1.0" encoding="UTF-8"?>

<blueprint
	xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
	xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0";
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
	xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
							http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
						http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0
							http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd";>

	<cm:property-placeholder
		persistent-id="my_test_26_karaf_s_master"
		update-strategy="reload" />

	<bean
		id="clusterBean"
		class="org.apache.camel.component.file.cluster.FileLockClusterService">
		<property
			name="root"
			value="${my.share-files-path}" />
	</bean>

	<service
		id="clusterService"
		interface="org.apache.camel.cluster.CamelClusterService"
		ref="clusterBean">
	</service>

</blueprint>
<?xml version="1.0" encoding="UTF-8"?>

<blueprint
	xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
	xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0";
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
	xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
							http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
						http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0
							http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd";>

	<cm:property-placeholder
		persistent-id="my_test_26_karaf_2_routes"
		update-strategy="reload">
		<cm:default-properties>
			<cm:property
				name="my.option"
				value="value" />
		</cm:default-properties>
	</cm:property-placeholder>

	<reference
		id="myHelper"
		interface="my.test.t26.helper.Helper"
		availability="mandatory" />

	<reference
		id="myUOWF"
		interface="my.test.t26.uow.CustomUnitOfWorkFactory"
		availability="mandatory" />

	<reference
		id="myJMS"
		interface="javax.jms.ConnectionFactory"
		availability="mandatory" />

	<reference
		id="myDB"
		interface="javax.sql.DataSource"
		filter="(osgi.jndi.service.name=jdbc/fifi)"
		availability="mandatory" />

	<reference
		id="myCluster"
		interface="org.apache.camel.cluster.CamelClusterService"
		availability="mandatory" />

	<camelContext
		id="KT1"
		streamCache="true"
		useMDCLogging="true"
		xmlns="http://camel.apache.org/schema/blueprint";
		xsi:schemaLocation="http://camel.apache.org/schema/blueprint
								https://camel.apache.org/schema/blueprint/camel-blueprint-3.18.4.xsd";>

		<onException>
			<exception>java.lang.Exception</exception>
			<handled>
				<constant>false</constant>
			</handled>
			<log
				loggingLevel="ERROR"
				message="EXCEPTION on route ${routeId} : '${exception}' \n${exception.stacktrace}" />
		</onException>

		<route id="KT1-File">
			<from uri="master:K1-FILE:file://{{my.input-folder}}?delete=true&amp;moveFailed=.ERROR" />
			<transacted />
			<log message="File : ${headers.CamelFilePath}" />
			<unmarshal>
				<csv />
			</unmarshal>
			<split shareUnitOfWork="true">
				<simple>${body}</simple>
				<log message="Line : ${body}" />
				<split shareUnitOfWork="true">
					<simple>${body}</simple>
					<transform>
						<groovy>"-- ${request.body} --"</groovy>
					</transform>
					<to uri="bean:myHelper" />
					<log message="Field : ${body}" />
					<to uri="jms:queue:k1-test-queue-1?connectionFactory=#myJMS&amp;transacted=true" />
					<transform>
						<groovy>
							[
								request.getHeader('MyCorrelationId'),
								request.getHeader('CamelFileName'),
								request.body
							]
						</groovy>
					</transform>
					<setProperty name="mySQL">
						<groovy>
							"""
							INSERT INTO fifi.karaf1 (
								correlation_id,
								file,
								message,
								moment,
								clock
							) VALUES (
								#,
								#,
								#,
								now(),
								clock_timestamp()
							)
							""".stripIndent().toString().replaceAll('(\t|\r|\n)', '')
						</groovy>
					</setProperty>
					<toD uri="sql:${exchangeProperty.mySQL}?dataSource=#myDB" />
				</split>
			</split>
			<log message="End of ID : ${header.MyCorrelationId}" />
		</route>

		<route id="KT1-AMQ">
			<from uri="master:K1-JMS:jms:queue:k1-test-queue-1?connectionFactory=#myJMS" />
			<log message="AMQ routing [${headers.MyCorrelationId}-${headers.CamelFileName}] : ${body}" />
		</route>

	</camelContext>

</blueprint>

Reply via email to