Как применить пользовательский org.apache.camel.Processor в Camel-маршруте, развернутом в автономном ServiceMix

Одна из моих попыток решить другую проблему - внедрить пользовательский процессор Camel и использовать его на некоторых маршрутах, объявленных в Spring DSL, развернутых в автономном ServiceMix.

Новая проблема заключается в том, что я не знаю, как рассказать ServiceMix о моем классе.

В ServiceMix docs написано, что из коробки он может развернуть jar-файл в допустимый комплект OSGi, а также развернуть маршруты в конфигурационных файлах Spring xml. Но даже после того, как я упаковал свой класс в jar и развернул его в ServiceMix, при загрузке маршрутов все равно возникает ошибка:

        Unable to start bundle 236: Unable to resolve stub-services.xml [236](R 236.66): missing requirement [stub-services.xml [236](R 236.66)] osgi.wiring.package; (osgi.wiring.package=ru.home.project) Unresolved requirements: [[stub-services.xml [236](R 236.66)] osgi.wiring.package; (osgi.wiring.package=ru.home.project)]

В маршруте я пытаюсь использовать свой собственный процессор таким образом

<camelContext xmlns="http://camel.apache.org/schema/spring">
...
<route ...>
    <bean ref="myProcessor" method="process"/>
    <!-- or <process ref="myProcessor"/> -->
...
</route>
...
</camelContext>

Пожалуйста, направь меня на правильный путь. ТИА.

UPD: я завернул свой пользовательский процессор в пакет osgi с помощью maven-bundle-plugin. В конфигурации манифеста я написал Export-Package с пакетом, который содержит мой класс. После того, как я развернул jar, я вижу свой пакет в списке импорта пакета xml (команда headers <bundleId>).

Но, тем не менее, когда xml bundle пытается запуститься, он терпит неудачу за исключением

karaf@root>Exception in thread "SpringOsgiExtenderThread-46" org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route get-client-offers-rest at: >>> process[ref:queryParamProcessor] <<< in route: Route(get-client-offers-rest)[[From[restlet:http://localhost... because of No bean could be found in the registry for: queryParamProcessor of type: org.apache.camel.Processor
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1652)
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:138)
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:340)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:96)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:954)
at org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route get-client-offers-rest at: >>> process[ref:queryParamProcessor] <<< in route: Route(get-client-offers-rest)[[From[restlet:http://localhost... because of No bean could be found in the registry for: queryParamProcessor of type: org.apache.camel.Processor
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1072)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196)
at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:944)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3260)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:2983)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:175)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2814)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2810)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2833)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2810)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2779)
at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:270)
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:136)
... 10 more
Caused by: org.apache.camel.NoSuchBeanException: No bean could be found in the registry for: queryParamProcessor of type: org.apache.camel.Processor
at org.apache.camel.util.CamelContextHelper.mandatoryLookup(CamelContextHelper.java:159)
at org.apache.camel.impl.DefaultRouteContext.mandatoryLookup(DefaultRouteContext.java:151)
at org.apache.camel.model.ProcessDefinition.createProcessor(ProcessDefinition.java:95)
at org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:535)
at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:496)
at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:220)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1069)
... 23 more

Когда я пытался использовать процессор как бин с <to uri="bean:queryParamProcessor" method="process"/> на маршруте происходит сбой с NPE внутри метода процессора, потому что аргумент метода как-то не связан, даже в документации верблюда сказано: вы также можете использовать Exchange в качестве самого параметра, но тогда возвращаемый тип должен быть void.

0 ответов

Другие вопросы по тегам