Sometimes we may need to abort
RUNNING instances of a SOA composite or abort single long running instance.
It’s pretty easy in em console but sometimes it won’t work so I came up with below java
program which will help you to abort instances. You can change program
according to your need.
import java.util.Hashtable;
import java.util.List;
import javax.naming.Context;
import oracle.soa.management.facade.Component;
import oracle.soa.management.facade.ComponentInstance;
import oracle.soa.management.facade.Composite;
import oracle.soa.management.facade.Locator;
import oracle.soa.management.facade.LocatorFactory;
import oracle.soa.management.util.ComponentInstanceFilter;
import oracle.soa.management.util.CompositeInstanceFilter;
import oracle.soa.management.facade.CompositeInstance;
import oracle.soa.management.CompositeDN;
public class abortComposite {
public abortComposite() {
super();
}
public void abortRunningComposite() {
try {
Locator locator = null;
Hashtable jndiProps =
new Hashtable();
//Connection Details to
Connect to Server
jndiProps.put(Context.PROVIDER_URL,
"t3://soahost:soaport");
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
jndiProps.put(Context.SECURITY_PRINCIPAL, "weblogic");
jndiProps.put(Context.SECURITY_CREDENTIALS, "XXXXX");
jndiProps.put("dedicated.connection", "true");
//Connect to SOA Server
locator =
LocatorFactory.createLocator(jndiProps);
System.out.println("Connected to SOA Server.");
CompositeInstanceFilter
filter = new CompositeInstanceFilter();
String
compositeName="YourCompositeName";
//filter.setId("1238098"); Use this incase if you want to delete
specific instance id
filter.setState(CompositeInstance.STATE_RUNNING);
filter.setCompositeName(compositeName);
List<CompositeInstance> compositeInstances =
locator.getCompositeInstances(filter);
for(int
i=0;i<compositeInstances.size();i++)
((CompositeInstance)compositeInstances.get(i)).abort();
}catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args) {
abortComposite abortcomposite = new
abortComposite();
abortcomposite.abortRunningComposite();
}
}
Steps:-
Set Classpath
export CLASSPATH=$CLASSPATH:$ORACLE_FMW_HOME/oracle_common/soa/modules/oracle.soa.mgmt_11.1.1/soa-infra-mgmt.jar:$ORACLE_FMW_HOME/oracle_common/modules/oracle.fabriccommon_11.1.1/fabric-common.jar:$ORACLE_FMW_HOME/wlserver_10.3/server/lib/weblogic.jar:$ORACLE_FMW_HOME/oracle_common/modules/oracle.jrf_11.1.1/jrf-api.jar
Set Classpath
export CLASSPATH=$CLASSPATH:$ORACLE_FMW_HOME/oracle_common/soa/modules/oracle.soa.mgmt_11.1.1/soa-infra-mgmt.jar:$ORACLE_FMW_HOME/oracle_common/modules/oracle.fabriccommon_11.1.1/fabric-common.jar:$ORACLE_FMW_HOME/wlserver_10.3/server/lib/weblogic.jar:$ORACLE_FMW_HOME/oracle_common/modules/oracle.jrf_11.1.1/jrf-api.jar
I need a program to do RUNNING instances of a SOA composite and I find best solution using java api here.thank you.
ReplyDeleteRegards,
Oracle SOA Training,
weblogic training in hyderabad.
Nice too see this post helped you.
DeleteSudhakara-
ReplyDeleteI am getting the following error when I execute the class on my soa domain:
SEVERE: Failed to create a DirectConnectionFactory instance (oracle.soa.api.JNDIDirectConnectionFactory): oracle.soa.api.JNDIDirectConnectionFactory
Can you tell me why this is happening??
-Regards
Ricardo
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging…!!..
ReplyDeleteOracle SOA Online Training
Hi dude, Im getting the below error.
ReplyDeleteException in thread "main" java.lang.NoSuchMethodError: oracle.soa.management.internal.facade.Locator.getFlowInstance(J)Loracle/soa/management/facade/flow/FlowInstance;
at oracle.soa.management.internal.facade.FlowBasedCompositeInstanceImpl.abort(FlowBasedCompositeInstanceImpl.java:390)
at bpmclient.model.PerformActions.abortRunningComposite(PerformActions.java:56)
at bpmclient.model.PerformActions.main(PerformActions.java:30)