You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Raymond (Jira)" <ji...@apache.org> on 2023/04/04 09:03:00 UTC
[jira] [Commented] (CAMEL-19243) KameletConsumerNotAvailableException
[ https://issues.apache.org/jira/browse/CAMEL-19243?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17708319#comment-17708319 ]
Raymond commented on CAMEL-19243:
---------------------------------
As a workaround, I now load the kamelets of the catalog like this:
{code:java}
List<String> resourceNames;
try (ScanResult scanResult = new ClassGraph().acceptPaths("kamelets").scan()) {
resourceNames = scanResult.getAllResources().getPaths();
}
String properties = " properties:\n" +
" in:\n" +
" title: Source endpoint\n" +
" description: The Camel uri of the source endpoint.\n" +
" type: string\n" +
" default: kamelet:source\n" +
" out:\n" +
" title: Sink endpoint\n" +
" description: The Camel uri of the sink endpoint.\n" +
" type: string\n" +
" default: kamelet:sink\t";
ExtendedCamelContext extendedCamelContext = context.adapt(ExtendedCamelContext.class);
RoutesLoader loader = extendedCamelContext.getRoutesLoader();
for(String resourceName: resourceNames){
URL url = Resources.getResource(resourceName);
String resourceAsString = Resources.toString(url, StandardCharsets.UTF_8);
//replace values
resourceAsString = StringUtils.replace(resourceAsString,"\"kamelet:source\"", "\"{{in}}\"");
resourceAsString = StringUtils.replace(resourceAsString,"\"kamelet:sink\"", "\"{{out}}\"");
resourceAsString = StringUtils.replace(resourceAsString,"kamelet:source", "\"{{in}}\"");
resourceAsString = StringUtils.replace(resourceAsString,"kamelet:sink", "\"{{out}}\"");
resourceAsString = StringUtils.replace(resourceAsString," properties:", properties,1);
resourceName= StringUtils.substringAfter(resourceName,"kamelets/");
Resource resource = ResourceHelper.fromString(resourceName, resourceAsString);
try{
loader.loadRoutes(resource);
}catch (Exception e){
log.warn("could not load: " + resourceName + ". Reason: " + e.getMessage());
}
}
{code}
After that I can create a route from these kamelets and chain them by the in/out uri's. For example by loading the following route templates:
{code:java}
<?xml version="1.0" encoding="UTF-8"?>
<templatedRoutes xmlns="http://camel.apache.org/schema/spring">
<templatedRoute routeId="65-65" routeTemplateRef="timer-source">
<parameter name="period" value="15000"/>
<parameter name="message" value="Some message"/>
<parameter name="out" value="direct:65-65"/>
<parameter name="in" value="direct:65-65"/>
</templatedRoute>
</templatedRoutes>{code}
{code:java}
<?xml version="1.0" encoding="UTF-8"?>
<templatedRoutes xmlns="http://camel.apache.org/schema/spring">
<templatedRoute routeId="65-66" routeTemplateRef="log-action">
<parameter name="out" value="direct:65-66"/>
<parameter name="in" value="direct:65-65"/>
</templatedRoute>
</templatedRoutes> {code}
> KameletConsumerNotAvailableException
> ------------------------------------
>
> Key: CAMEL-19243
> URL: https://issues.apache.org/jira/browse/CAMEL-19243
> Project: Camel
> Issue Type: Bug
> Components: camel-kamelet
> Affects Versions: 3.20.3
> Reporter: Raymond
> Priority: Minor
>
> I would like to use the Kamelets from the Kamelet catalog:
> [https://camel.apache.org/camel-kamelets/3.20.x/index.html]
> I have added the Kamelets maven dependency to my project
> [https://mvnrepository.com/artifact/org.apache.camel.kamelets/camel-kamelets]
> And then use it within a route using the Kamelet component:
> {code:java}
> <route id="example">
> <from uri="kamelet:timer-source?message=hello&period=10000"/>
> <to uri="log:foo"/>
> </route> {code}
>
> This gives the following error:
> {code:java}
> 2023-04-03 15:50:03.073 ERROR 40304 --- [ - timer://tick] o.a.c.p.e.DefaultErrorHandler : Failed delivery for (MessageId: 7E14905736F56C0-000000000000001C on ExchangeId: 7E14905736F56C0-000000000000001C). Exhausted after delivery attempt: 1 caught: org.apache.camel.component.kamelet.KameletConsumerNotAvailableException: No consumers available on endpoint: kamelet://sink?routeId=timer-source-1. Exchange[7E14905736F56C0-000000000000001C]Message History
> ---------------------------------------------------------------------------------------------------------------------------------------
> Source ID Processor Elapsed (ms)
> timer-source.kamelet.yaml:64 timer-source-1/timer-source-1 from[timer://tick?period=10000] 481757935
> timer-source.kamelet.yaml:70 timer-source-1/setBody6 setBody[constant{{{message}}}] 1
> timer-source.kamelet.yaml:72 timer-source-1/setHeader6 setHeader[Content-Type] 0
> timer-source.kamelet.yaml:75 timer-source-1/to15 kamelet://sink?routeId=timer-source-8 0Stacktrace
> ---------------------------------------------------------------------------------------------------------------------------------------org.apache.camel.component.kamelet.KameletConsumerNotAvailableException: No consumers available on endpoint: kamelet://sink?routeId=timer-source-1. Exchange[7E14905736F56C0-000000000000001C]
> at org.apache.camel.component.kamelet.KameletProducer.process(KameletProducer.java:78)
> at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:172)
> at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:477)
> at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:181)
> at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:59)
> at org.apache.camel.processor.Pipeline.process(Pipeline.java:165)
> at org.apache.camel.impl.engine.CamelInternalProcessor.process(CamelInternalProcessor.java:392)
> at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:210)
> at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:76)
> at java.base/java.util.TimerThread.mainLoop(Timer.java:556)
> at java.base/java.util.TimerThread.run(Timer.java:506)2023-04-03 15:50:03.074 WARN 40304 --- [ - timer://tick] o.a.camel.component.timer.TimerConsumer : Error processing exchange. Exchange[7E14905736F56C0-000000000000001C]. Caused by: [org.apache.camel.component.kamelet.KameletConsumerNotAvailableException - No consumers available on endpoint: kamelet://sink?routeId=timer-source-1. Exchange[7E14905736F56C0-000000000000001C]]
> {code}
> Looking at the source of the timer-source Kamelet this is logical:
> [https://github.com/apache/camel-kamelets/blob/main/kamelets/timer-source.kamelet.yaml]
> It has a line:
> to: kamelet:sink
> I'm not sure what this "kamelet:sink" does (all kamels from the catalog have it)? When I remove it or change it with another uri (like direct:x) and load the yaml from a custom location then the kamelet works.
> Is this a bug? Is this as intended?
> In other words, how can I use the kamelets from the catalog within my routes? And is there a way to remove or overwrite the kamelet:sink?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)