Written By Archit Bhardwaj
There are three types of Recoverable messages in BPEL Recovery console
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 :-
Code For Fault Recovery For Callback for single service
***************************************************************************
package recovery.client;
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://manish.com:7501/soa-infra"); jndiProps.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory"); jndiProps.put(Context.SECURITY_PRINCIPAL, "manish"); jndiProps.put(Context.SECURITY_CREDENTIALS, "*******"); 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<BPMCallbackMessage> 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(); } }
************************************************************************
|
Thursday, April 25, 2013
Recovering the BPEL instances from Java
########
at 8:33 PM
Labels: BPEL Recovery, SOA Suite 11g
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment