Thursday, May 17, 2012

Recovering the Oracle BPEL instances from the Recovery Queue – Oracle SOA Suite

 Recovering the Oracle BPEL instances from the Recovery Queue – Oracle SOA:

Sometimes the BPEL instances may go to the recovery queue, the instances in the recovery queue can be recovered manually to continue the processing.
Below are the some of the reasons the instances to go to manual recovery.
  1. There are not enough threads or memory to process the message.
  2. The server shuts down or crash before it finishes processing the BPEL message
  3. The engine could not finish processing the message before reaching the time-out as dictated by the transaction-timeout configuration

Recovering the BPEL instances:

Oracle SOA Suite 11g:

  1. Login  to EM console
  2. Right click on soa-infra  ,Click on Service Engine - BPEL
  3. Click on Recovery tab
  4. Change the Type accordingly(Invoke,Activity,Callback) and the Message state to “Undelivered”  and click on search
  5. All the recoverable messages that match the criteria will be displayed.
  6. Select the required messages and click on Recovery button.
 

Oracle SOA Suite 12c:

  1. Login  to EM console
  2. Click on Target Navigation
  3. Click on soa-infra
  4. Click on SOA Infrastructure - Service Engines - BPEL
  5. Click on Recovery tab
  6. Change the Type accordingly(Invoke,Activity,Callback) and the Message state to “Undelivered”  and click on search
  7. All the recoverable messages that match the criteria will be displayed.
  8. Select the required messages and click on Recovery button.
em_console_target_navigation


em_console_service_engines


em_console_recovery_messages




14 comments:

  1. Hi Albin, can you tell me if is there any way of doing this recovery from the command line?

    ReplyDelete
    Replies
    1. There are five message states for each type
      1. Undelivered
      2. Resolved
      3. Delivered
      4. Cancelled
      5. Exhausted

      The Classes mentioned below are used only to recover messages in Undelivered Message state.


      • FaultRecoveryForInvoke.java- It recovers Undelivered recoverable Invoke instances based on Composite Name.
      • FaultRecoveryForInvokeAll.java- It recovers all the Undelivered recoverable Invoke instances.
      • FaultRecoveryForCallback.java- It recovers Undelivered recoverable Callback instances based on Composite Name.
      • FaultRecoveryForCallbackAll.java- It recovers all the Undelivered recoverable Callback instances.



      The state set for undelivered instances is 0 in the code.



      For recovering messages from other states ,the filter.setState(x) can be changed to :-

      0 for Undelivered
      1 for Resolved
      2 for delivered
      3 for Cancelled
      4 for exhausted



      The jar files used for the code are :-

      1.fabric-common.jar
      2.oracle-soa-client-api.jar
      3.soa-infra-mgmt.jar
      4.weblogic.jar
      5.wlcient.jar
      6.wsclient_extended.jar
      7.wlfullclient.jar

      Delete
    2. /*Created: Tue Apr 23 17:25:11 GMT+05:30 2013
      Author: archit.bharadwaj

      This Java code is used to recover all recoverable instances under Invoke which are in Undelivered state as on BPEL Recovery Console.



      */
      package abc;

      import java.util.Hashtable;
      import java.util.List;
      import java.util.ListIterator;
      import java.util.Scanner;
      import javax.naming.Context;
      import oracle.soa.management.facade.Locator;
      import oracle.soa.management.facade.LocatorFactory;
      import oracle.soa.management.facade.bpel.BPELServiceEngine;
      import oracle.soa.management.facade.bpm.BPMInvokeMessage;
      import oracle.soa.management.util.MessageFilter;

      public class FaultRecoveryForInvoke{
      private Locator locator = null;
      private BPELServiceEngine mBPELServiceEngine;


      public FaultRecoveryForInvoke(){
      System.out.println("Inside Constructor");
      locator = this.getLocator();

      try{
      System.out.println("Try Block of Constructor");
      mBPELServiceEngine=(BPELServiceEngine)locator.getServiceEngine(Locator.SE_BPEL);
      }
      catch (Exception e){
      e.printStackTrace();
      }
      }


      // Setting up connection properties

      public Hashtable getJndiProps(){
      System.out.println("Inside getJndiProps");
      Hashtable jndiProps = new Hashtable();
      jndiProps.put(Context.PROVIDER_URL,"t3://172.18.79.22:8001/soa-infra");
      jndiProps.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
      jndiProps.put(Context.SECURITY_PRINCIPAL, "weblogic");
      jndiProps.put(Context.SECURITY_CREDENTIALS, "welcome1");
      jndiProps.put("dedicated.connection", "true");
      System.out.println("Connection Successfull");
      return jndiProps;
      }

      //Creating the locator to set up the connection to the server

      public Locator getLocator(){
      System.out.println("Inside getLocator");
      try{
      System.out.println("Try Block of getLocator");
      return LocatorFactory.createLocator(getJndiProps());
      }
      catch(Exception e){
      e.printStackTrace();
      }
      return null;
      }

      // Reovering all recoverable faults listed under invoke and having the state Undelivered as on BPEL Recovery Console

      public void recoverFaults(){
      System.out.println("Inside recoverFaults");
      try{
      int i=1;
      System.out.println("Try Block of recoverFaults");
      MessageFilter filter=new MessageFilter();

      //Input Composite Name
      Scanner sc=new Scanner(System.in);
      System.out.println("Enter The Composite Name");
      String CompositeName=sc.next();

      //filters can be set according to desired criteria
      filter.setCompositeName(CompositeName);
      filter.setState(0);

      //Getting all recoverable messages
      System.out.println("Getting Recoverable messages");
      List recoverable=mBPELServiceEngine.getInvokeMessages(filter);
      ListIterator it=recoverable.listIterator();
      while(it.hasNext()){
      System.out.println("Record number----->>>"+i+"\t"+it.next());
      i++;
      }
      System.out.println("total number of records-------->>>>>"+recoverable.size());

      //Recovering all recoverable messages
      mBPELServiceEngine.recoverInvokeMessages(recoverable);
      System.out.println("Messages Retried in one chance");
      }

      catch (Exception e){
      e.printStackTrace();
      }
      }
      public static void main(String[] args){
      // calling the method recoverFaults
      FaultRecoveryForInvoke faultRecovery = new FaultRecoveryForInvoke();
      faultRecovery.recoverFaults();
      }
      }

      Delete
    3. /*Created: Tue Apr 23 17:25:11 GMT+05:30 2013
      Author: archit.bharadwaj

      This Java code is used to recover all recoverable instances under Callabck which are in Undelivered state as on BPEL Recovery Console.
      This code recovers instances on the basis of CompositeNames.


      */
      package abc;

      import java.util.Hashtable;
      import java.util.List;
      import java.util.ListIterator;
      import java.util.Scanner;
      import javax.naming.Context;
      import oracle.soa.management.facade.Locator;
      import oracle.soa.management.facade.LocatorFactory;
      import oracle.soa.management.facade.bpel.BPELServiceEngine;
      import oracle.soa.management.facade.bpm.BPMCallbackMessage;
      import oracle.soa.management.util.MessageFilter;

      public class FaultRecoveryForCallback{
      private Locator locator = null;
      private BPELServiceEngine mBPELServiceEngine;


      public FaultRecoveryForCallback(){
      System.out.println("Inside Constructor");
      locator = this.getLocator();

      try{
      System.out.println("Try Block of Constructor");
      mBPELServiceEngine=(BPELServiceEngine)locator.getServiceEngine(Locator.SE_BPEL);
      }
      catch (Exception e){
      e.printStackTrace();
      }
      }


      // Setting up connection properties

      public Hashtable getJndiProps(){
      System.out.println("Inside getJndiProps");
      Hashtable jndiProps = new Hashtable();
      jndiProps.put(Context.PROVIDER_URL,"t3://172.18.79.90:8001/soa-infra");
      jndiProps.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
      jndiProps.put(Context.SECURITY_PRINCIPAL, "weblogic");
      jndiProps.put(Context.SECURITY_CREDENTIALS, "welcome1");
      jndiProps.put("dedicated.connection", "true");
      System.out.println("Connection Successfull");
      return jndiProps;
      }

      //Creating the locator to set up the connection to the server

      public Locator getLocator(){
      System.out.println("Inside getLocator");
      try{
      System.out.println("Try Block of getLocator");
      return LocatorFactory.createLocator(getJndiProps());
      }
      catch(Exception e){
      e.printStackTrace();
      }
      return null;
      }

      // Reovering all recoverable faults listed under callabck and having the state Undelivered as on BPEL Recovery Console

      public void recoverFaults(){
      System.out.println("Inside recoverFaults");
      try{
      int i=1;
      System.out.println("Try Block of recoverFaults");
      MessageFilter filter=new MessageFilter();

      //Input Composite Name
      Scanner sc=new Scanner(System.in);
      System.out.println("Enter The Composite Name");
      String CompositeName=sc.next();

      //filters can be set according to desired criteria
      filter.setCompositeName(CompositeName);
      filter.setState(0);

      //Getting all recoverable messages
      System.out.println("Getting Recoverable messages");
      List recoverable=mBPELServiceEngine.getCallbackMessages(filter);
      ListIterator it=recoverable.listIterator();
      while(it.hasNext()){
      System.out.println("Record number----->>>"+i+"\t"+it.next());
      i++;
      }
      System.out.println("total number of records-------->>>>>"+recoverable.size());

      //Recovering all recoverable messages
      mBPELServiceEngine.recoverCallbackMessages(recoverable);
      System.out.println("Messages Retried in one chance");
      }

      catch (Exception e){
      e.printStackTrace();
      }
      }
      public static void main(String[] args){
      // calling the method recoverFaults
      FaultRecoveryForCallback faultRecovery = new FaultRecoveryForCallback();
      faultRecovery.recoverFaults();
      }
      }

      Delete
    4. Simply comment the below part in the above codes to achieve FaultRecoveryForCallbackAll.java and FaultRecoveryForInvokeAll.java for their functionalities as mentioned in my first post :-

      /*
      Scanner sc=new Scanner(System.in);
      System.out.println("Enter The Composite Name");
      String CompositeName=sc.next();

      //filters can be set according to desired criteria
      filter.setCompositeName(CompositeName); */

      Delete
    5. The Wlfullclient.jar is not available in the Oracle/Middleware directory on the local machine and it needs to be created.
      The steps to do the same are as follows :-

      1. Go to the path C:\Oracle\Middleware\wlserver_10.3\server\lib using command prompt.
      2. Type the command java -jar wljarbuilder.jar
      3. Wlfullclient.jar is created in the directory mentioned above

      Delete
    6. code shared by archit prints output as recovered but unable to see any istance in EM.Pls help

      Delete
  2. We can't recover by default from command line but the Java API's can be used to develop a utility to recover the instances from commandline.

    Regards
    Albin I

    ReplyDelete
  3. Hi Albin,

    Have you tried WLST for this anytime?

    Tx,
    Deepak

    ReplyDelete
  4. I did not tried this but this should be possible even through the WLST script using the MBean.


    Regards
    Albin I

    ReplyDelete
  5. Hi Albin,

    What is the difference between recover invoke, callback or activity and which appears in what situation. In my composite I am calling a Human workflow and after human workflow completes we are calling another service. If any error occurs in Human workflow then its coming into invoke recovery and if any error occurs after human workflow then its coming into activity recovery. Please let me know if you want me to explain it again

    ReplyDelete
    Replies
    1. I could not able to find any proper documentation related to this anyhow based on my experience i am writing the below details-

      If a calling process has the receive activity to receive the call back from the other process
      and encountoured some issues(like transformation and assign issues) before reciving the callback then the calling process
      instance will be rolled backed to the previous
      transaction point and the instance will goes to the recovery queue as a callback type.


      If a calling process has a invoke activity and the instance failed after the invoke activity then the instance will be rolled backed to the
      previous transaction point and the instance will goes to the recovery queue as a invoke type.


      If the instance failes other than the above scenarios in any of the activities then the instance will goes to the recovery queue as a Activity type.

      Delete
  6. Hi, My service is calling a plsql custom package and which is calling another plsql custom package. Instance is going into Recovery. Please advice.

    ReplyDelete
  7. Hi Albin,

    I want to access my bpel payload in a java class, which has been called from my fault polcy. Can you tell me how to do that????

    ReplyDelete