You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2022/12/14 14:55:00 UTC
[jira] [Created] (CAMEL-18814) camel-javascript - Make it easier to interop Camel Message with JS functions
Claus Ibsen created CAMEL-18814:
-----------------------------------
Summary: camel-javascript - Make it easier to interop Camel Message with JS functions
Key: CAMEL-18814
URL: https://issues.apache.org/jira/browse/CAMEL-18814
Project: Camel
Issue Type: Improvement
Reporter: Claus Ibsen
Fix For: 3.x
{code}
// camel-k: language=js
import { faker } from "./js/node_modules/@faker-js/faker/dist/esm/index.mjs";
const greet = (exchange, message, headers, body) => {
return { hello: faker.name.fullName() };
};
const greetByName = (exchange, message, headers, body) => {
return { hello: headers.name };
};
const call = (e, callback) => {
const result = callback(
e,
e.getMessage(),
e.getMessage().getHeaders(),
e.getMessage().getBody()
);
e.getOut().setBody(result);
};
from("direct:greet").process((e)=>call(e, greet)).marshal().json();
from("direct:greetByName").process((e)=>call(e,greetByName)).marshal().json();
{code}
I would like `process` to fire the call to a js function with all the params (Exchange, Message, Headers, Body) and accept the result as is
instead of having manually to do it, like in the call function
Is there a way to include this call function as part of the process DSL or even better add a new js process version?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)