My logs format is JSON format and whenever I receive message immediately I set few parameters to header(additionalInfo), for all the logs default include the additionalInfo.
I tried the below in Java and success, but I need it in camel spring dsl
logger.info(Markers.append("additionalInfo", Map), "Message Received");
Can someone please help me the possibility of the same in spring DSL. Mainly to set any Object in marker rather than just String.
Related
Im am trying to call a rest post service from my Camel route.
The rest service is deployed at https://csp-verteileauftrag-camunda-v1-csp-ims-dev-az.apcn.osp4-preprod.hel.kko.ch/api/v1/verteileauftrag/.
Calling the Service from a Rest Client like VS Code works if there is a trailing slash (after verteileauftrag).
In my camel route I have configured the following:
restConfiguration().host("https://csp-verteileauftrag-camunda-v1-csp-ims-dev-az.apcn.osp4-preprod.hel.kko.ch/api/v1").component("http").bindingMode(RestBindingMode.json);
and in then later using the config:
.to("rest:post:verteileauftrag?outType=ch.helsana.csp.verteileauftrag.rest.model.apiadapter.ResponseType")
If I execute the code, I get a 404 HTTP Error from the Backend as the URL used is
https://csp-verteileauftrag-camunda-v1-csp-ims-dev-az.apcn.osp4-preprod.hel.kko.ch/api/v1/verteileauftrag. So without a trailing slash.
I have tried to add it like .to("rest:post:verteileauftrag/?outType=ch.helsana.csp.verteileauftrag.rest.model.apiadapter.ResponseType")
but no success.
Do you have any idea how to tell the http component in the rest configuration how to add the trailing slash?
Thank you very much.
Using redhat fuse 7_10_2.
Regards Michel
Based on a collegues example I reimplemented the Rest Service call with a normal .to("URL") configuration in the routebuilder with setting the appropriate Headers for HTTP Post and content type json. Would still be interessted in any answer, but not waiting on one.
I'm trying to run a simple test with Apache Camel:
from("http://localhost:61554/api/v1/MyController/my-endpoint")
.to("direct:a")
.log("$({body}");
I'm getting the following error: "No endpoint could be found for: http://localhost:61554/api/v1/MyController/my-endpoint, please check your classpath contains the needed Camel component jar"
I'm very new to Camel and Java. Can someone please tell me why this error is coming up? Should I be using from("direct:x")... ? If, so where do I map my "direct" endpoints to concrete ones?
Thanks
You cannot use the http component as consumer (eg in from) - its a http client for calling HTTP servers (so its a producer, eg to).
Instead to have HTTP as consumer you can use camel-servlet, camel-jetty, camel-undertow, etc.
I want to be able to use Logic Apps to put/post messages in an Azure Storage Queue, because I want to make use of the Managed Identity option that HTTP Logic App acion provides.
I have a Logic App that uses HTTP action to post XML messages to the queue and I have a "Put a message on a queue" action that puts JSON message to the queue for debugging purposes.
My ultimate goal is to be able to use the HTTP action with Managed Identity as Authentication but be able to post JSON messages to the queue like the "Put a message on a queue" action is able to.
You can certainly send JSON as message body. In fact you can send any text. You just have to ensure that the text you're sending as message body must be XML safe e.g. replace < with < etc. Generally Base64 encoded string messages are sent to ensure this.
From the REST API documentation:
A message must be in a format that can be included in an XML request
with UTF-8 encoding. To include markup in the message, the contents of
the message must either be XML-escaped or Base64-encode. Any XML
markup in the message that is not escaped or encoded will be removed
before the message is added to the queue.
Here is what worked for me:
Enabled "Managed Identity" on the Logic App.
Added Storage-Queue-Contributor permissions on the storage queue.
Used utcnow('R') to get this date format ("Tue, 08 Sep 2020 12:03:08 GMT")
for x-ms-date HTTP header (no doc from MS about this).
Inserted JSON data inside
<QueueMessage>
<MessageText>
{
"car": "Audi",
"year": 1983
}
</MessageText>
</QueueMessage>
Final result in Logic App designer:
First of all, I haven't found any generic open source implementation for ebxml/ebms, for me it's somehow strange or maybe I have looked up the wrong stuff, but I haven't found here something rly usefull.
When I was looking for ebxml/ebms I have also found JAXM/SAAJ(JSR 67). It looks like this implementations never got to an end, all links regarding this are refering to the sun homepage which doesn't exist anymore. From the sun homepage you get redirected to the oracle homepage, and there I can't find something about JAXM or JSR 67.
This leads me to my question, how to implement an ebxml service in apache camel?
Should I create the ebxml SOAP message "manually" or are there some libs I've missed that are generating such an ebxml message for me?`
How to send such an ebXml SOAP message via apache camel? Cxf needs an wsdl, for the service we want to call there exists no wsdl.
How to recieve such ebXml messages? Cxf see above, maybe with an http consumer like netty-http or jetty?
A few years too late, but maybe valuable for others :)
There is an open source implementation available which supports the ebMS 2.0 spec.
This ebMS adapter can be deployed as a Mule ESB plugin or as a regular WAR application.
https://sourceforge.net/projects/muleebmsadapter/
Despite being on sourceforge, it is still being actively developed.
You can use velocity template to create the ebxml SOAP message manually, for example.
Template example:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:ser="http://test/Service">
<soap:Header/>
<soap:Body>
<ser:insertRequest>
<ser:routingHeader>
<ser:operationType>${headers.OPERATION_TYPE}</ser:operationType>
<ser:messageId>${exchange.properties.messageId}</ser:messageId>
<ser:sourceId>${exchange.properties.sourceId}</ser:sourceId>
<ser:destinationId>${exchange.properties.destinationId}</ser:destinationId>
</ser:routingHeader>
<ser:datagram>
${body}
</ser:datagram>
</ser:insertRequest>
</soap:Body>
</soap:Envelope>
You can use http, http4 or jetty components to send such an ebXml SOAP message via apache camel.
to("jetty:http://{{server.host}}:{{server.http.port}}/service/").
log(LoggingLevel.INFO, "HTTP response code: ${in.header.CamelHttpResponseCode}")
After you only need to parse SOAP response manually (XPath, maybe), or you can transform response by XSLT.
Maybe you can use beanio, xstream or jaxb and so on to transform XML to POJO.
....
to("velocity:file:///{{karaf.home}}/etc/vm/ws-message-oc.vm?contentCache=true").
setProperty(Exchange.CONTENT_TYPE).constant("application/soap+xml").
setProperty(Exchange.CONTENT_ENCODING).constant("gzip").
setProperty(Exchange.CHARSET_NAME).constant("utf-8").
//log(LoggingLevel.INFO, "WS request: ${body}").
to("jetty:http://{{app-server.host}}:{{app-server.http.port}}/service/").
log(LoggingLevel.INFO, "HTTP response code: ${in.header.CamelHttpResponseCode}")
//log(LoggingLevel.INFO, "WS response: ${body}")
.setHeader("callRC").xpath("//ser:callRC/text()", String.class, XmlNamespaces.NAMESPACES.getNamespace())
....
I'm pretty new to camel so perhaps I'm going about this the wrong way but I'm routing messages from one endpoint to another and transforming them on the way. However the next stage is to add authentication to the pipeline. I have a service that tracks authenticated users. My plan is to, in the first stage of the route, to add a filter that checks to see if the current user is authenticated. If the user is not I want to transform the message into an authentication request and send that to my endpoint. All good so far, however, after authentication (if successful) I want to send the original message down the pipeline. Is this something that can be done?
A simplified version of my route would be:
from("seda:in").
filter(method(Authentication.class, "isNotAuthenticated")).
bean(AuthenticationTransformer.class)
to("cxfbean:out")
.end()
.bean(RequestTransformer.class)
.to("cxfbean:out")
The same message would be sent to both transformer beans.
You should preserve the message in the Exchange property setProperty("originalMessage", body()) before transforming it. Afterwards you can access that property using getProperty("originalMessage")