10 Replies Latest reply on Jul 21, 2014 1:09 PM by Tom Cunningham

    Invoke Service From ESB

    Poyan Gerami Novice

      What is the recomanded way to invoke an service from an action class inside the esb pipeline ?

      I have try to use ServiceInvoker but dont get it work,

      this is the code inside the proccess method:

       ServiceInvoker s = new ServiceInvoker("SMSDeliveryAlternative","SMSDeliveryServiceAlternative");

      When i run this in the server i get the WARN below in an loop :

      2008-02-08 14:40:09,813 WARN [ssage.ActionProcessingPipeline] No reply to address defined for reply message! To: JMSEpr [ PortReference < <wsa:Address jms://localhost:1299/queue/DeadMessageQueue/>, <wsa:ReferenceProperties jbossesb:java.naming.provider.url : localhost:1299/>, <wsa:ReferenceProperties jbossesb:destination-type : queue/>, <wsa:ReferenceProperties jbossesb:specification-version : 1.1/>, <wsa:ReferenceProperties jbossesb:connection-factory : ConnectionFactory/>, <wsa:ReferenceProperties jbossesb:persistent : true/>, <wsa:ReferenceProperties jbossesb:acknowledge-mode : 1/>, <wsa:ReferenceProperties jbossesb:type : urn:jboss/esb/epr/type/jms/> > ] MessageID: ID:JBM-4 RelatesTo: jms:correlationID#c6ec89c6-c881-47dc-b0fe-c2a7e35e011f

        • 1. Re: Invoke Service From ESB
          Burr Sutter Master

          We just made a few tests in this area based on another thread. So using SI in an action does work. Things to look at:
          - does the second service run standalone, cleanly with no error?
          - is there anything strange in the message like non-serializable object attachments (I've been guilty of leaving that off in some of the quickstarts)?


          • 2. Re: Invoke Service From ESB
            Bernd Koecke Novice


            may be the attribute mep="OneWay" is missing in your definition of the DeadLetterService. You can find it in 'jbossesb.esb/META-INF/jboss-esb.xml'. There should be a part like:

            <service name="JBossESB-Internal" category="DeadLetterService">
             <actions mep="OneWay">

            I think there will be an endless loop, if this attribute is missing and a message should be stored in the DeadLetterQueue. But I haven't tried it, I only looked into the code, so I may be wrong.

            Hope that helps,

            • 3. Re: Invoke Service From ESB
              Poyan Gerami Novice

              thanks guys, i get it work, actually it was an space in the configuration for the service so when i remove that it start working,
              but still is SI the recomended way to call an service from an action class ? is thair any disadvantage with that ?

              • 4. Re: Invoke Service From ESB
                Bernard Tison Newbie

                The ServiceInvoker is indeed the recommended way to call another service from within an action class, because the ServiceInvoker hides all the implementation and location details for you. You just have to supply the category and name of the Service, and the ServiceInvoker transparently does the rest (service lookup in the registry, obtaining a suitable courier, handle message redelivery in case of faults, ...).

                Alternatively, if the service call inside your action is just for routing purposes, you might want to consider StaticRouter or ContentBasedRouter actions shipped with the ESB



                • 5. Re: Invoke Service From ESB
                  joe_boy12 Novice

                  hello folks


                  I am trying to build an error handling service which gets called from processException method of an Action - however this is a Synch call, initiated on Http Gateway - I have a common.esb deployed on JBoss SOA5.1 which is common for all the .esb applications we have. Things work fine until the exception is raised and processException method is called, the moment I use SI to call this error handling service from Action, there is an endless loop which keeps throwing following warning.


                  INFO  [org.jboss.soa.esb.client.ServiceInvoker] (pool-37-thread-1) Unresponsive EPR: InVMEpr xxxxxxxxxxxxxxxx


                  INFO  [org.jboss.soa.esb.client.ServiceInvoker] (pool-37-thread-1) Service: Infrastructure:HandleErrorService not found in the registry


                  WARN  [org.jboss.internal.soa.esb.couriers.InVMCourier] (Thread-28) InVMCourier pickup caught: org.jboss.internal.soa.esb.couriers.transport.InVMException: Could not locate service entry for epr InVMEpr [ PortReference < <wsa:Address invm://496e66726173747275637475726524242424242424242424242448616e646c654572726f7253657276696365/false?false#10000/>, <wsa:ReferenceProperties jbossesb:passByValue : false/> > ]


                  this is how my jboss-esb.xml looks like for common.esb


                  <jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.2.0.xsd" parameterReloadSecs="5">
                    <service category="Infrastructure" name="HandleErrorService" description="" invmScope="GLOBAL">
                     <actions mep="RequestResponse">
                      <action name="PrintMe" class="org.jboss.soa.esb.actions.SystemPrintln">
                      <property name="message" value="HandleErrorService called" />
                      <property name="printfull" value="false" />

                      <action name="baseAction" class="com.nike.esb.common.action.BaseErrorHandlingAction" process="processErrors"/>


                  and this is how I am calling it.


                  public void processException(Message message, Throwable t) throws ActionProcessingException
                  if( message != null )
                       try {
                    Service myService = new Service("Infrastructure", "HandleErrorService");
                    ServiceInvoker si = new ServiceInvoker(myService);
                    si.deliverSync(message, 1000);
                       } catch (Exception e) {
                     throw new ActionProcessingException(e.getMessage(), e);


                  I can see the service registered in jmx-console, the surprising thing is the http client does get the perfect custom reply telling the exact error - however on server console there is an endless warning loop. Any guesses?

                  • 6. Re: Invoke Service From ESB
                    joe_boy12 Novice

                    By closely looking at logs looks like my business service (pool-37-thread-1) and error handling service (invoked by SI - pool-21-thread-1) run in two different threads, which pool-21-thread-1 returns the response to client - thread pool-37-thread-1 keeps on throwing warning that service not found in registry and there is one more thread (Thread-27) which keeps on throwing following warning...


                    InVMException: Could not locate service entry for epr

                    • 7. Re: Invoke Service From ESB
                      Tom Cunningham Master

                      Please post a full stack trace and a full description of what you are doing and what you are seeing.

                      • 8. Re: Invoke Service From ESB
                        Hans Wolffenbuttel Expert



                        If you have a message which is running through the pipeline of a service, it will have a 'replyto' and a 'from' EPR definition. If you want to resend the current message you will have to ajust the replyto to null, because otherwise the message invoker will assume that you have already put the right locations in.


                        If you have for example a service called 'testcategory','testname' and you have a request response defined, the message will contain the from EPR and the replyto EPR. If you invoke a synchronous serviceInvoker to service 'testcat2','testname2', you will have to reset the replyto EPR, because other wise the message will go to the 'testname'-replyto-EPR instead of the replyto EPR of te serviceinvoker that called 'testname2'. The serviceInvoker will timeout and an unresponsive EPR exception will be thrown.


                        There is a default action 'org.jboss.soa.esb.actions.SyncServiceInvoker' which does all that.






                        • 9. Re: Invoke Service From ESB
                          Sameer Joshi Newbie

                          Hello Joe,


                          I realize this is a 3 yr old post, but were you able to get this resolved and if so, how?



                          • 10. Re: Invoke Service From ESB
                            Tom Cunningham Master



                            What exactly is your issue?  Have you tried the approaches that Hans suggests?