Let me explain my configuration:
ActiveMQ 5.12.0
AnyPoint Studio 5.2.1
Mule 3.6.1
Flow of application:
I am using FunctionalTestCase to post and retrieve a message from queue.
MuleClient client = muleContext.getClient();
String productAsJson = "{\"name\":\"Widget\", \"price\":9.99, \"weight\":1.0, \"sku\":\"abcd-12345\"}";
client.dispatch("http://localhost:8081/products", productAsJson, null);
MuleMessage result = client.request("jms://products", RECEIVE_TIMEOUT);
What is happening is the message is getting posted but when I try to retrieve it, I get the string "{NullPayLoad}".
After stepping back through the flow, I have discovered the message payload, when using the Mule Client, is not making the queue. While looking through the admin console for ActiveMQ, I discovered the message details is "{NullPayload}". When I check using the Advance Risk Client, the JSON message is getting posted correctly.
Any suggestions would be greatly appreciated.
Russ
It's NullPayload when using the MuleClient because by default the http operation will be GET and wont be expecting a body to parse.
The MuleClient is more suited to working with Mule transport infrastructure such as the JMS transport or the old http transport. I don't think it plays nice with the new http listener module.
Normally with the transports you can set the method via a property but that doesnt seem to work with the http:listener:
MuleMessage message = getTestMuleMessage();
message.setPayload(productAsJson);
message.setProperty("http.method", "POST", PropertyScope.INBOUND);
client.send("http://localhost:8089/products", message);
I would suggest using a standard HTTP client such as Apache HTTP client etc. and set the method to POST/PUT or whatever method you need to use that expects a body.
Related
I am using RabbitMq with masstransit for messaging between different services, let us say that we have the following scenario:
First service asks about specific info from second service by sending a request.
Second service looks for the info in database and respond with an object containing the found info.
In case there is no info available in database, the second service responds with a null object.
The issue is that RabbitMQ is considering that the request has failed thus it keeps sending the request again.
Can I configure the bus to consider the null reponse as a normal response?
You cannot reply with null object. You have two options:
Add a boolean property to your response indicating it is not a success
Throwing an exception in the request consumer, then the fault message will be sent to the request client.
I have a requirement where I would need to call a servlet end point.
The servlet does the huge task. It might take about hours to do task.
Keeping all these, I need to build a http client which keeps connection and call this end point. I am not interested in the response. It should just call the endpoint and forget. Which client should i use ?
I tried with apache http client
CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
httpclient.start();
HttpGet request = new HttpGet(URL);`
Future<HttpResponse> future = httpclient.execute(request,null);
Does this call the end point of the servlet, because I don't see any logs of the servlet endpoint.
HttpResponse response = future.get();
Is this line required ? As I don't need to capture response.
No, it is not needed. The line:
HttpResponse response = future.get();
blocks your thread until the there is a HTTP response or connection breaks. Check out Future.get() javadoc
This question is on Mule CXF error handling. I have a soap based web service basically this is a validation service that validates an incoming file and reports on any errors in the file. Once validation is unsuccessful i have a catch-exception-strategy which logs the error and sends a email to Prod support team. After validation is unsuccessful i need not call the subsequent steps in the flow. And only the logging and sending an email alert should happen. Shouldn't using a catch-exception-strategy solve the problem ( similar to a try/catch block in Java). But what i notice is the caller is sent a response back and subsequent flow steps are executed
In your catch exception strategy put an asynchronous flow and in that put your logger and smtp to send the mail ... I guess it will solve your problem ...
Since you will be using asynchronous flow response shouldn't be there ... Pls let me know if it solve your issue
I am attempting to receive JSON messages into BizTalk using the bLogical REST Start Kit for BizTalk (http://biztalkrest.codeplex.com/).
I am able to successfully receive a message, transform it, and return a response from my Orchestration, but when I transform the response back out through the BizTalkRESTResponseHandler, the HTTP Content-Type is being forced back to 'application/xml', even though I'm explicitly setting it to 'application/json'. The Content-Type is confirmed by tracing the Request and Response in Fiddler, as well as SoapUI.
The Accept: value on the Request is 'application/json'
Any ideas how I can trace further into the Wcf-Custom adapter stack to see where the Content-Type is being reset?
You can solve this by adding a HttpResponseMessageProperty before returning the message in the IDispatchMessageInspector. You can either do this directly in the BizTalkRESTResponseHandler IDispatchMessageInspector or in a separate one.
To do it in the BizTalkRESTResponseHandler get the source and add the following 3 lines of code in the BeforeSendReply method just above the "reply = newReply" in the end.
HttpResponseMessageProperty prop = new HttpResponseMessageProperty();
newReply.Properties.Add(HttpResponseMessageProperty.Name, prop);
prop.Headers.Add("Content-Type", "application/json;charset=utf-8");
Now instead of getting:
You will get this:
I am using Spring Integration in my project.
Endpoints used in application are in-bound gateway, header based router, transformer, spliter, service activator.
In case of success flow(not any exception), in-bound gateway reply-channel getting desired response and client gets that response which is fine but in case of any exception, I want to send customized error response which is not working as per my requirement.
I am using error-channel to accomplish above requirement but not succeeding in that.
Please find my configuration of in-bound gateway, error channel etc.
I have not use any chain in configuration.
<int-http:inbound-gateway id="inboundGateway"
supported-methods="GET, POST" request-channel="requestChannel"
path="/services/tylv/{requestParam}" reply-channel="responseChannel"
error-channel="errorChannel">
</int-http:inbound-gateway>
<int:transformer ref="errorHandler"
input-channel="errorChannel" method="generateErrorResponse"
output-channel="responseChannel" />
<bean id="errorHandler"
class="com.csam.wsc.enabling.integration.transformer.ErrorHandler" />
In case of exception , com.csam.wsc.enabling.integration.transformer.ErrorHandler.generateErrorResponse(ErrorMessage) successfully called.This API handle exceptions, generate Error Response Packet but it is not being sent to client, just only HTTP Status Code 200 sent.
Ideally it should be sent because transformer's output-channel is reply-channel of inbound-gateway which is already sending response packet along with status code 200 in case of success (no any exception).
I think in case of error-channel , in-bound gateway reply-channel is not working, but I am not sure.
Please help me in configuring error-channel.
You should store the message's headers before the error reaches the error channel and then you should create a new message with the stored headers and route that new message to response channel.
MessageBuilder.fromMessage(errorResponseMessage).copyHeadersIfAbsent(storedHeaders).build();