Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

cDynamicRouter and different endpoints

Hi all, 
I have the route (attached bellow). 
I have to dynamically redirect the messages depending on the Http verb (I tried to do it using another approch but it was an epic fail 0683p000009MAB6.png
used the link
The problem is that only the "DELETE" method is working, and yet I have the error:  

 :1:1: Fin prématurée du fichier.
: org.apache.camel.processor.DefaultErrorHandler - Failed delivery for (MessageId: ID-LFR204094-55535-1439324535115-0-3 on ExchangeId: ID-LFR204094-55535-1439324535115-0-1). Exhausted after delivery attempt: 1 caught: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange]


while with the GET or POST methods all I have is this error:


 :1:1: Contenu non autorisé dans le prologue.
: org.apache.camel.processor.DefaultErrorHandler - Failed delivery for (MessageId: ID-LFR204094-56301-1439325581670-0-3 on ExchangeId: ID-LFR204094-56301-1439325581670-0-1). Exhausted after delivery attempt: 1 caught: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange]


I bridged the URLs:

"http://localhost:8081/webMavenChouette?bridgeEndpoint=true&throwExceptionOnFailure=false"


please find attached the snapshots of the route and the bean:
0683p000009MAHp.png 0683p000009MAcR.png
Thank you for your time 
-Regards

Labels (2)
40 Replies
Anonymous
Not applicable
Author

It is now complaining about an XML element called "Meta". You need to focus on one verb at a time. I'd suggest POST. Do not change any of the other routes or use service calls with a verb other than POST. 
Remember where I asked you to add a cProcessor and convert to JSON? Can you replace it with the following code. But only for the POST route....
String jsonString = exchange.getIn().getBody(String.class);
System.out.println(jsonString);
exchange.getIn().setBody(jsonString);

I need to know what is being sent and what the system.out prints to the output. 
Anonymous
Not applicable
Author

after adding the cProcessor with the code you've given me;
the debug throws: 
: org.eclipse.jetty.server.AbstractConnector - Started SelectChannelConnector@localhost:8087
: org.apache.camel.spring.SpringCamelContext - Route: base_cHttp_1 started and consuming from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Route: cMessagingEndpoint_2 started and consuming from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Total 2 routes, of which 2 is started.
: org.apache.camel.spring.SpringCamelContext - Apache Camel 2.15.2 (CamelContext: test2cDynamicRouter-ctx) started in 1.119 seconds
:1:1: Contenu non autorisé dans le prologue.
: org.apache.camel.processor.DefaultErrorHandler - Failed delivery for (MessageId: ID-LFR204094-57607-1439562308204-0-2 on ExchangeId: ID-LFR204094-57607-1439562308204-0-1). Exhausted after delivery attempt: 1 caught: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange]
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor Elapsed (ms)

]
Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange
]

and the executions' logs: 
from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Route: cMessagingEndpoint_2 started and consuming from: Endpoint
: org.apache.camel.spring.SpringCamelContext - Total 2 routes, of which 2 is started.
: org.apache.camel.spring.SpringCamelContext - Apache Camel 2.15.2 (CamelContext: test2cDynamicRouter-ctx) started in 1.271 seconds
:1:1: Contenu non autorisé dans le prologue.
: org.apache.camel.processor.DefaultErrorHandler - Failed delivery for (MessageId: ID-LFR204094-52305-1439564677351-0-2 on ExchangeId: ID-LFR204094-52305-1439564677351-0-1). Exhausted after delivery attempt: 1 caught: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange]
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor Elapsed (ms)

]
Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange
]
Anonymous
Not applicable
Author

Well, to know   what is being sent and what the system.out prints to the output, I used a cIntercept component and  tried the scenario below; hope it helps: 
0683p000009MAd0.png
Anonymous
Not applicable
Author

Finally, it works, instead of using the cMessagingEndpoint, I should have chosen the cIntercept component; 
thank you very much for your time and your patient 0683p000009MACn.png 
0683p000009MAd5.png
Anonymous
Not applicable
Author

I need to see the JSON. Change the cProcessor code to be as below...
String jsonString = exchange.getIn().getBody(String.class);
System.out.println("THE JSON STRING = "+jsonString);
exchange.getIn().setBody(jsonString);

When you run it, look for "THE JSON STRING =" in the output.
Can you also let me know what you supply as JSON when you call it?
Also, can you take a screenshot of route so I can see how far the call got along the route?
This is pretty tricky not being able to play with the route myself.
Anonymous
Not applicable
Author

I supply the json object: 
{"id":14,"objectid":"14","objectVersion":14,"creationTime":null,"creatorId":"14","name":"company14","shortName":"","organizationalUnit":"","operatingDepartmentName":"","code":"","phone":"","fax":"","email":"","registrationNumber":"1","ligneses":[],"vehicleJourneyses":[]}

When I run the route, the "THE JSON STRING ="   isn't even printed in the output. I get the same log errors as above. 
here's the screenshot of route:
0683p000009MANt.png
Anonymous
Not applicable
Author

If you look at the screenshot you can see that the message does not make it to cMessagingEndpoint as no rows are shown. Was this a POST call? In your bean that builds the dynamic endpoint, can you put a System.out call to display what it is actually producing?
You are working with a lot of unknowns here. It is always good practise in situations like this to print as much of what is happening to the output as possible.
Anonymous
Not applicable
Author

yes, this was a POST call, 
the System.out I added in the bean didn't display anything

public class setDynaURI {
public String setURI(Document document,@Header(Exchange.SLIP_ENDPOINT) String previous, 
@Header(Exchange.HTTP_METHOD) String httpVerb) {
if (previous != null) {
return null;
}
System.out.println("direct:" + httpVerb);
return "direct:" + httpVerb;
}
}
Anonymous
Not applicable
Author

That is interesting. It suggests that "previous" is not null and therefore that method is returning null. Can you put ....
System.out.println("Previous = " + previous + " and httpverb = " +  httpVerb);
.... before the if condition to the see whether "previous" is null. This could very well be one of your problems.
Anonymous
Not applicable
Author

it's not printed neither. 
as I told you, I replaced the cMessagingEndpoint with a cIntercepter, the route works but the
 System.out.println("Previous = " + previous + " and httpverb = " + httpVerb);

 isn't printed either. I think that what's in the bean can't be printed in the Log