Is there a way to test a choice router for the following scenario which is based on the http.status? I am seeking a way to test the first condition of the router
<flow>
<choice>
<when expression="#[message.inboundProperties['http.status'] !=201">
......
<otherwise>
.....
</otherwise>
</choice>
</flow>
I want to verify that a javax.ws.rs.core.Response with can be correctly handled by the HTTP endpoint.
The flow doesn't have an inbound endpoint (thus it's a private flow) so to test it
create a test flow in a test XML config file that you will load side by side with your other Mule configuration XML files,
add an inbound VM endpoint to this test flow and make it call the private flow you want to test,
in your functional test case, use the Mule Client to dispatch a test message over the VM endpoint, setting properties on this test message that will end-up as inbound properties in the private flow.
Related
We have a requirement to service the GUI with a SI service. The GUI communicates with the backend over JMS queues, and will wait for a response on a tmp queue that is specified in the jms replyTo header property.
So there can be 10 gui's making queries to the backend, and receiving messages on their individual tmp queues.
So I wrote a SI service using inbound gateway that looks like this
<int:channel id="inChannel" />
<int:channel id="outChannel" />
<int-jms:inbound-gateway id="jmsSampleService" request-destination-name="TEST_QUEUE_2" request-channel="inChannel"
connection-factory="qpidJmsConnectionFactory" extract-request-payload="true" error-channel="errorChannel" />
<int:service-activator input-channel="inChannel" ref="sampleService2" method="processMessage" />
public class SampleService2 {
public Response processMessage(Object obj) throws Exception {
LOG.info("Message received on sample service. ");
Thread.sleep(5000);
Response response = new ResponseImpl();
response.setPayload("Test response");
return response;
}
This works fine, i can see the service return a message back on the jmsReplyTo queue. However, this is a single threaded synchronous operation which means unless GUI1 was serviced, GUI2 's call will be blocked. I want to do this asynchronously since this is simply a method call on a class.
We were doing something similar in mule
<flow name="sampleServiceFlow">
<jms:inbound-endpoint queue="TEST_QUEUE" connector-ref="queryQpidConnector" />
<byte-array-to-object-transformer />
<component>
<spring-object bean="sampleService" />
</component>
<object-to-byte-array-transformer />
<expression-filter evaluator="groovy"
expression="message.getOutboundProperty('replyToQueueName') != null" />
<jms:outbound-endpoint queue="#[header:OUTBOUND:replyToQueueName]" connector-ref="queryQpidConnector" />
</flow>
Since the mule service does not have any txns, it is able to simply consume a message in auto-ack, and have the SampleService's method call service the call.
Is there a way of implementing something like this in SI? perhaps by using the message-driven-channel-adapter? Is there a way to propagate jms header properties between channels?
Simply use concurrency on the inbound gateway. concurrent-consumers is the min max-concurrent-consumers (if specified) is the max; the adapter's container with adjust the concurrency depending on demand.
I am not sure what you mean by
Is there a way to propagate jms header properties between channels?
The jms headers are mapped to integration headers and vice-versa.
I have a REST Service running in Tomcat server. I created this REST Service using Spring RESTTemplate. So is there a component in CAMEL to use this exposed Web service?
i have used http component. i am aware that we cannot use http component to expose a service. So please let me know which component to use.Here is a detailed description of the problem.
Service created in rest Template runs in a server which you can see in from part of camel code
i use camel to expose this service to another http service and the response of this service is the response from the other service.
so my camel code looks like this:
from("http://localhost:8080/rest/emp/dummy").to(http://anotherweservice.com")
I get this error.
Failed to create route route1: Route(route1)[[From[]] -> [process[com.routes..... because of uri must be specified and not empty
Have a look at http://camel.apache.org/how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html.
Using the Jetty component, this looks as follows:
from("jetty:http://0.0.0.0:8080/myapp?matchOnUriPrefix=true")
.log("myapp: httpPath = ${header.CamelHttpPath}")
.to("jetty:http://localhost:8082/remoteapp?bridgeEndpoint=true&throwExceptionOnFailure=false")
In this example, the request is forwarded to another Jetty Camel endpoint:
from("jetty:http://0.0.0.0:8082/remoteapp?matchOnUriPrefix=true")
.log("remoteapp: httpPath = ${header.CamelHttpPath}")
.setBody(simple("${header.CamelHttpPath}"));
The HTTP path /hello/world is transfered to the endpoint, as can be seen when the service is invoked with http://localhost:8080/myapp/hello/world. In this case the body /hello/world is returned. And in the log it says:
INFO myapp: httpPath = /hello/world
INFO remoteapp: httpPath = /hello/world
I have a simple Mule flow where I receive an XML message via an HTTP endpoint and then do some processing on it. One of the first steps is to send the message via another outbound HTTP endpoint to a web service. The service just saves the message and does no processing on it. Therefore I effectively want to ignore the return value of the outbound endpoint and continue processing the message that was originally received. I tried making the endpoint on-way, but then my current Mule message becomes empty.
How do I call a endpoint, but ignore any return and continue processing with my original message?
You could use a <wiretap>: http://www.mulesoft.org/documentation/display/current/Routing+Message+Processors#RoutingMessageProcessors-WireTap
Or use <async> scope: http://www.mulesoft.org/documentation/display/current/Async+Scope+Reference
Or use an <enricher> if you want store the response in a variable but leave the current payload alone: http://www.mulesoft.org/documentation/display/current/Message+Enricher
Note that wiretap and enricher are synchronous and will block further processing where async won't.
In this case Async should be a better option.
Async in Mule helps to continue with the processing ignoring the results of the message processors called inside the async.
ex:
<flow name="sample" >
<http:inbound-endpoint ...... />
.... Some processing.....
<async>
<http:outbound-endpoint ....... />
</async>
...... Continue with the processing with the original message....
</flow>
Hope this helps.
I am doing an integration poc to invoke a remote EJB servcie by ejb:connector and ejb:outbound-endpoint in component binding.
It works perfectly fine if I define methodArgumentTypes and method properties in ejb outbound endpoint
<flow name="ExternalServiceFlow" doc:name="ExternalServiceFlow">
<vm:inbound-endpoint exchange-pattern="request-response" path="serviceInput" doc:name="VM"/>
<ejb:outbound-endpoint connector-ref="weblogicEjbConnector" methodArgumentTypes="java.lang.String,com.fusa.ssg.datatype.Date,java.lang.String,com.fusa.ssg.datatype.AuditInfo" method="readAccountDetail" address="${external.ejb.service.address}"/>
</flow>
However, since I need to invoke other APIs in the same component binding, how can reuse the ExternalServiceFlow to invoke other methods besides readAccountDetail? I tried to remove the methodArgumentTypes and method properties, but the application started with exceptions
Element ejb:outbound-endpoint{address=${external.ejb.service.address}, connector-ref=weblogicEjbConnector, name=.ExternalServiceFlow:outbound-endpoint.32, protocol=ejb} must have all attributes for one of the sets: [ref] [method]
Please advise how I can reuse the same vm flow with different remote APIs call.
I have some problems in the next situation:
I have wso2esb and a there is proxy-service in the esb.
I call this proxy with parameters with parameter, e.g.
http://host:9643/service/myproxy?domain=first.
After that my proxy need to get to the next endpoint: http://first.mysite.com
if we have http://host:9643/service/myproxy?domain=second we will have to get to the http://second.mysite.com
You get your parameter inside the proxy service using.
<property name="domain" value="application/x-www-form-urlencoded" scope="axis2"/>
And then you need to use switch mediator inside proxy service's insequence and then based on the case you need use send mediator to send the message to required endpoing.
This will be helpful to understand the scenario.
http://docs.wso2.org/wiki/display/IntegrationPatterns/Dynamic+Router