Camel setHeader newbie error - header

I would just know where I'm wrong with this route.
I'm trying to return a messsage via a web socket route, but I'm unable to set camel connection key:
from("jms:queue:subscriptionValidationError").log("Receiving error message: ${body} ${in.headers.websocket.connectionKey}")
.setHeader(WebsocketConstants.CONNECTION_KEY, simple("${in.headers.websocket.connectionKey}"))
.log("Sending error message: ${body} ${out.headers.websocket.connectionKey}")
.to("websocket://0.0.0.0:9292/subscribeErrors?staticResources=classpath:webapp");
This gives me a log without the connection key on the second log operation:
Receiving error message: doit suivre "[-a-zA-Z0-9]+\#[-a-zA-Z0-9]+\.[a-zA-Z]+" 60f7cc44-9d9b-4bde-905a-d7d51be7661a
Sending error message: doit suivre "[-a-zA-Z0-9]+\#[-a-zA-Z0-9]+\.[a-zA-Z]+"
Can you please tell me where I'm wrong?
Thanks in advance

your log() references the out.header...but setHeader() is setting the in.header
see http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html

Related

Mediation of Class Mediator not happening

I am hitting my api from another service with help of endpoint in Wso2. However, I am getting the error below:
"errorCode": "0",
"errorMessage": "Error occured in the mediation of the class mediator"
Note: The error comes only for one endpoint rest all is working absolutely fine for the same service. Unable to figure out the problem.
for further detail of error I am attaching it below:
"errorDetail": "org.apache.synapse.SynapseException: Error occured in the mediation of the class mediator\n\tat
org.apache.synapse.mediators.ext.ClassMediator.mediate(ClassMediator.java:102)\n\tat
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109)\n\tat
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)\n\tat
org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)\n\tat
org.apache.synapse.api.Resource.process(Resource.java:342)\n\tat
org.apache.synapse.api.API.process(API.java:463)\n\tat
org.apache.synapse.api.AbstractApiHandler.apiProcess(AbstractApiHandler.java:93)\n\tat
org.apache.synapse.api.AbstractApiHandler.dispatchToAPI(AbstractApiHandler.java:71)\n\tat
org.apache.synapse.api.rest.RestRequestHandler.dispatchToAPI(RestRequestHandler.java:84)\n\tat
org.apache.synapse.api.rest.RestRequestHandler.process(RestRequestHandler.java:70)\n\tat
org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:54)\n\tat
org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:344)\n\tat
org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:101)\n\tat
org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)\n\tat
org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:375)\n\tat
org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:434)\n\tat
org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:182)\n\tat
org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)\n\tat
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat
java.base/java.lang.Thread.run(Thread.java:834)\nCaused by: org.apache.synapse.SynapseException:
org.json.simple.parser.ParseException\n\tat
org.apache.synapse.mediators.AbstractMediator.handleException(AbstractMediator.java:376)\n\tat
com.safaricom.mediator.RESTInteractRequestMediator.mediate(RESTInteractRequestMediator.java:139)\n\tat
org.apache.synapse.mediators.ext.ClassMediator.updateInstancePropertiesAndMediate(ClassMediator.java:178)\n\tat
org.apache.synapse.mediators.ext.ClassMediator.mediate(ClassMediator.java:97)\n\t... 20
more\nCaused by: Unexpected character (<) at position 0.\n\tat
org.json.simple.parser.Yylex.yylex(Yylex.java:610)\n\tat
org.json.simple.parser.JSONParser.nextToken(JSONParser.java:269)\n\tat
org.json.simple.parser.JSONParser.parse(JSONParser.java:118)\n\tat
org.json.simple.parser.JSONParser.parse(JSONParser.java:81)\n\tat
org.json.simple.parser.JSONParser.parse(JSONParser.java:75)\n\tat
com.safaricom.mediator.RESTInteractRequestMediator.mediate(RESTInteractRequestMediator.java:44)\n\
t... 22 more\n"
It seems your client is sending an XML request body to an API that expects a JSON message, or sending the wrong Content-Type header.

WSO2 API Manager returning RunTime Error

I have an API in WSO2. When I try to test it in the store with valid parameters via GET, it returns the following error message:
<am:fault xmlns:am="http://wso2.org/apimanager">
<am:code>101504</am:code>
<am:type>Status report</am:type>
<am:message>Runtime Error</am:message>
<am:description>Send timeout</am:description>
</am:fault>
I have already searched and tried a lot, but with no success, always returning the same error. Don't know if helps, but the api that I try to access is a PHP file.
Any ideas?
EDIT:
I have identical apis to this one, changing only the response, that are working properly. Even if I erase the php file that the API is pointing, the error keep coming.
EDIT:
I changed the code in Management Console, in Metadata>List>APIs:
{"production_endpoints":
{"url":"http://site/myapi.php","config":
{"format":"leave-as-is","optimize":"leave-as-
is","actionSelect":"fault","actionDuration":30000}},
"sandbox_endpoints":
{"url":"http://site/myapi.php","config":
{"format":"leave-as-is","optimize":"leave-as-
is","actionSelect":"fault","actionDuration":30000}},
"implementation_status":"managed","endpoint_type":"http"}
to this:
{"production_endpoints":
{"url":"http://10.20.40.189/ConsultaAutorizacaoCadPos.php","config":null},
"sandbox_endpoints":{"url":"http://10.20.40.189/ConsultaAutorizacaoCadPos.php","config":null},
"implementation_status":"managed","endpoint_type":"http"}
And this error message vanishes. But this new one appears:
<am:fault xmlns:am="http://wso2.org/apimanager">
<am:code>303001</am:code>
<am:type>Status report</am:type>
<am:message>Runtime Error</am:message>
<am:description>Currently , Address endpoint : [ Name : admin--myapi_APIproductionEndpoint_0 ] [ State : SUSPENDED ]</am:description>
EDIT: this error message is appearing just sometimes. Most of the time the request takes long time to run and then returns nothing( no content )
Any ideas how to solve it?

What does this error mean? [GatekeeperXPC]

I get this error:
[GatekeeperXPC] Connection to assetsd was interrupted or assetsd died
What does it mean? (I am currently working with AVAssets)
Thanks!

Get a 'clear' error message in Lua

I am using the error function in quite a few of my functions and would like to propagate the error messages to the user. However, I obviously don't want to include information about where the error occured exactly; this information should only go to the log files.
For example, I have a class that manages the connection to a server. If the connection times out, it calls
error("Connection timed out!")
The error message is then caught by the calling code via pcall. However, the message contains not only the message I passed, but also the name of the file that caused the error and the line number:
common/net/enetclient.lua:21: Connection timed out!
The question is: Is there any way to only retrieve the error message itself, or do I have to do this manually like following:
local status, msg = pcall(someFunctionThatThrowsErrors)
if not status then
local file, msg = msg:match("(.-:%d+): (.+)")
print("Error: " .. msg)
end
Cheers,
From the documentation of the error function:
error (message [, level])
Terminates the last protected function called and returns message as the error message. Function error never returns.
Usually, error adds some information about the error position at the beginning of the message, if the message is a string. The level argument specifies how to get the error position. With level 1 (the default), the error position is where the error function was called. Level 2 points the error to where the function that called error was called; and so on. Passing a level 0 avoids the addition of error position information to the message.
From what is stated in the second paragraph, adding a level of 0 to the error call will result in the desired output:
error("Connection timed out!", 0)

Application Cache Error

I've got this error:
Application Cache Error event: Manifest fetch failed (-1)
http://localhost:8080/offline.manifest
online: NO, event: error, status: idle
This JSON String show the content of the error:
({"returnValue":true,"eventPhase":2,"timeStamp":1355923608009,"target":{"onprogress":null,"onchecking":null,"onerror":null,"onupdateready":null,"oncached":null,"ondownloading":null,"status":1,"onobsolete":null,"onnoupdate":null},"type":"error","cancelBubble":false,"cancelable":false,"defaultPrevented":false,"srcElement":{"onprogress":null,"onchecking":null,"onerror":null,"onupdateready":null,"oncached":null,"ondownloading":null,"status":1,"onobsolete":null,"onnoupdate":null},"bubbles":false,"currentTarget":{"onprogress":null,"onchecking":null,"onerror":null,"onupdateready":null,"oncached":null,"ondownloading":null,"status":1,"onobsolete":null,"onnoupdate":null}}) debug.js:34
I got it with JSON.stringify(error).
OK I have this information. But what can one understand from here???
Where is the problem? How can I solve it?
Thank you in advance.