Unresponsive EPR when using ServiceInvoker from Action class
khuevu May 19, 2013 10:18 PMHi all,
I am doing a POC on invoking multiple services and aggregate the result and return synchronously.
I have the following esb, in which, two services "google", "bing" are declared, which have inVM listeners. They just return the simple text "GOOGLE SEARCH" and "BING SEARCH" respectively. The aggregator service invokes the 2 services using the custom action class.
<services> <service category="extra" description="Blah blah" invmScope="GLOBAL" name="google"> <actions mep="RequestResponse"> <action class="org.jboss.soa.esb.actions.routing.http.HttpRouter" name="routeToBackendService1"> <property name="method" value="GET"/> <property name="endpointUrl" value="http://localhost:8000/google.html"/> </action> <action class="org.jboss.soa.esb.actions.SystemPrintln" name="printGoogle"> <property name="message" value="Google Response"/> </action> </actions> </service> <service category="extra" description="Blah blah" invmScope="GLOBAL" name="bing"> <actions mep="RequestResponse"> <action class="org.jboss.soa.esb.actions.routing.http.HttpRouter" name="routeToBackendService2"> <property name="method" value="GET"/> <property name="endpointUrl" value="http://localhost:8000/bing.html"/> </action> <action class="org.jboss.soa.esb.actions.SystemPrintln" name="printBing"> <property name="message" value="BIng Response"/> </action> </actions> </service> <service category="Aggregation" description="This service to handle portingService requests" invmScope="GLOBAL" name="aggregation"> <listeners> <http-gateway name="HTTP" urlPattern="aggregate/*"> <property name="synchronousTimeout" value="60000"/> </http-gateway> </listeners> <actions mep="RequestResponse"> <action class="org.jboss.soa.esb.actions.SystemPrintln" name="printRequest"> <property name="message" value="ORIGINAL Request"/> </action> <action class="org.test.esb.AggregateServiceInvoker" name="aggregateTest"> <property name="destinations"> <route-to service-category="extra" service-name="google"/> <route-to service-category="extra" service-name="bing"/> </property> </action> </actions> </service> </services>
My AggregateServiceInvoker class:
public class AggregateServiceInvoker extends AbstractActionPipelineProcessor { private ConfigTree configTree; private List<ServiceInvoker> invokers; private long timeout; public AggregateServiceInvoker(ConfigTree configTree) { this.configTree = configTree; } @Override public void initialise() throws ActionLifecycleException { //recipient list timeout = configTree.getLongAttribute("time-out", 30000L); ConfigTree[] destList = configTree.getChildren("route-to"); invokers = new ArrayList<ServiceInvoker>(); for (ConfigTree conf : destList) { String category = conf.getAttribute("service-category"); String name = conf.getAttribute("service-name"); System.out.println("Category: " + category + " name: " + name); //Service service = new Service(category, name); ServiceInvoker invoker; try { invoker = new ServiceInvoker(category, name); invokers.add(invoker); } catch (MessageDeliverException e) { throw new ActionLifecycleException(e); } } } @Override public Message process(Message message) throws ActionProcessingException { System.out.println(configTree.toXml()); System.out.println(message.getBody()); for (ServiceInvoker invoker : invokers) { try { System.out.println("Invoking service: " + invoker.getServiceName()); Message m1 = invoker.deliverSync(message, timeout); System.out.println("COMPLETED"); } catch (FaultMessageException | MessageDeliverException | RegistryException e) { e.printStackTrace(); } } System.out.println("AFTER : " + message.getBody()); return message; } }
When I test by sending request to: http://localhost:8080/test-aggregation/http/aggregate/ahh
It always fails to return the first service. With a Unresponsive EPR: InVMEpr:
10:13:25,770 INFO [STDOUT] body: [ objects: {org.jboss.soa.esb.message.defaultEntry=[B@18590ff4} ] 10:13:25,770 INFO [STDOUT] Invoking service: google 10:13:25,779 INFO [STDOUT] Google Response: 10:13:25,780 INFO [STDOUT] [GOOGLE SEARCH]. 10:13:55,777 INFO [ServiceInvoker] Unresponsive EPR: InVMEpr [ PortReference < <wsa:Address invm://6578747261242424242424242424242424676f6f676c65/false?false#10000/>, <wsa:ReferenceProperties jbossesb:type : urn:jboss/esb/epr/type/invm/>, <wsa:ReferenceProperties jbossesb:passByValue : false/> > ] for message: header: [ To: InVMEpr [ PortReference < <wsa:Address invm://4167677265676174696f6e2424242424242424242424246167677265676174696f6e/false?false#10000/>, <wsa:ReferenceProperties jbossesb:type : urn:jboss/esb/epr/type/invm/>, <wsa:ReferenceProperties jbossesb:passByValue : false/> > ] ReplyTo: InVMEpr [ PortReference < <wsa:Address invm://thread-186-4/>, <wsa:ReferenceProperties jbossesb:type : urn:jboss/esb/epr/type/invm/>, <wsa:ReferenceProperties jbossesb:passByValue : false/>, <wsa:ReferenceProperties jbossesb:temporaryEPR : true/> > ] MessageID: 16e3db91-f1e6-4a21-8cb6-82d306a1ad1f ] 10:13:55,778 INFO [ServiceInvoker] Delivering message [header: [ To: InVMEpr [ PortReference < <wsa:Address invm://4167677265676174696f6e2424242424242424242424246167677265676174696f6e/false?false#10000/>, <wsa:ReferenceProperties jbossesb:type : urn:jboss/esb/epr/type/invm/>, <wsa:ReferenceProperties jbossesb:passByValue : false/> > ] ReplyTo: InVMEpr [ PortReference < <wsa:Address invm://thread-186-4/>, <wsa:ReferenceProperties jbossesb:type : urn:jboss/esb/epr/type/invm/>, <wsa:ReferenceProperties jbossesb:passByValue : false/>, <wsa:ReferenceProperties jbossesb:temporaryEPR : true/> > ] MessageID: 16e3db91-f1e6-4a21-8cb6-82d306a1ad1f ]] to DLQ. 10:13:55,794 INFO [InquiryHelper] uddi:juddi.apache.org:eb6eb036-98f5-4fa1-8fd5-ce4fa853faba is modified Mon May 20 09:30:51 SGT 2013 1369013451516 10:13:55,933 ERROR [STDERR] org.jboss.soa.esb.listeners.message.ResponseTimeoutException: No response received for service [extra:google]. 10:13:55,935 ERROR [STDERR] at org.jboss.soa.esb.client.ServiceInvoker.post(ServiceInvoker.java:462) 10:13:55,935 ERROR [STDERR] at org.jboss.soa.esb.client.ServiceInvoker.deliverSync(ServiceInvoker.java:221) 10:13:55,935 ERROR [STDERR] at org.khuevu.test.esb.AggregateServiceInvoker.process(Unknown Source) 10:13:55,936 ERROR [STDERR] at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:667) 10:13:55,936 ERROR [STDERR] at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:614) 10:13:55,936 ERROR [STDERR] at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.process(ActionProcessingPipeline.java:442) 10:13:55,936 ERROR [STDERR] at org.jboss.soa.esb.listeners.message.MessageAwareListener$TransactionalRunner.run(MessageAwareListener.java:587) 10:13:55,937 ERROR [STDERR] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 10:13:55,938 ERROR [STDERR] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 10:13:55,938 ERROR [STDERR] at java.lang.Thread.run(Thread.java:722) 10:13:55,938 INFO [STDOUT] Invoking service: bing 10:13:55,957 INFO [STDOUT] BIng Response: 10:13:55,957 INFO [STDOUT] [BING SEARCH ]. 10:13:55,958 INFO [STDOUT] COMPLETED: with message length: 10:13:55,958 INFO [STDOUT] AFTER : body: [ objects: {org.jboss.soa.esb.http.HttpResponse#response=org.jboss.soa.esb.http.HttpResponse@5bdd48cf, org.jboss.soa.esb.message.defaultEntry=BING SEARCH } ]
The second service is invoked without any problem.
The first service is invoked and completed but fail to return to the current context.
Strang things are:
- Response from Google Service is already returned to client (displayed in the browser) before the ERROR occurs.
- In the action class code, I didn't append any of the response message to the return message, but response from BIng Service is automatically appended ? (AFTER: body...)
Any suggestion would be greatly appreciated.
Thank you,
Khue.