Wednesday, February 4, 2015

Oracle SOA : Get list of instances that are recoverable using SOA managment api's Ver1

There are five message states

1. Undelivered
2. Resolved
3. Delivered
4. Cancelled
5. Exhausted

The int value for the above state is as below
0 for Undelivered
1 for Resolved
2 for delivered
3 for Cancelled
4 for exhausted
This is set in the mfilter.setState(0);



package com.raylabs.bpel;
import java.util.Hashtable;
import java.util.List;
import java.util.ListIterator;
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.util.MessageFilter;
import oracle.soa.management.facade.bpm.BPMInvokeMessage;
public class Class1 {
public Class1() {
super();
}
public static void main(String[] args) {
Locator locator = null;
BPELServiceEngine mBPELServiceEngine = null;
MessageFilter mfilter = null;
try {
try {
locator =
LocatorFactory.createLocator(getConnectionForLocator());
System.out.println("Got locator succesfully ");
} catch (Exception e) {
System.out.println("Exception while getting locator");
e.printStackTrace();
}
try {
mBPELServiceEngine =
(BPELServiceEngine)locator.getServiceEngine(Locator.SE_BPEL);
System.out.println("Got BPELServiceEngine handle succesfully ");
} catch (Exception e) {
System.out.println("Exception BPELServiceEngine handle ");
e.printStackTrace();
}
mfilter = new MessageFilter();
mfilter.setState(0);
List<BPMInvokeMessage> recoverable;
try {
recoverable = mBPELServiceEngine.getInvokeMessages(mfilter);
ListIterator it = recoverable.listIterator();
System.out.println(recoverable.size());
while (it.hasNext()) {
BPMInvokeMessage invokemsg = (BPMInvokeMessage)it.next();
System.out.println(invokemsg.getCompositeDN() + "," +
invokemsg.getCreationTime() + "," +
invokemsg.getEcid());
}
} catch (Exception e) {
System.out.println("Exception while getting recoverable instances");
e.printStackTrace();
}
} catch (Exception e) {
System.out.println("Unknown Exception ");
e.printStackTrace();
} finally {
try {
locator.close();
System.out.println("Locator closed successfully");
} catch (Exception e) {
System.out.println("Exception while closing Locator handle");
e.printStackTrace();
}
}
}
public static Hashtable getConnectionForLocator() {
Hashtable jndiProps = new Hashtable();
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
jndiProps.put(Context.PROVIDER_URL,
"t3://xxx:1234/soa-infra");
jndiProps.put(Context.SECURITY_PRINCIPAL, "xxx");
jndiProps.put(Context.SECURITY_CREDENTIALS, "xxxx");
jndiProps.put("dedicated.connection", "true");
return jndiProps;
}
}


Jdev libraries



Note :
If you get "org.omg.CORBA.MARSHAL:   vmcid: 0x0  minor code: 0  completed: No" exceptions then use weblogic.jar instead of wlclient.jar

No comments:

Post a Comment