How to skip a service execution in Flow services.

Hi All,

I have a flow service called “com.xx.addition”. In 5th line of that service i am calling another service called as “com.xx.getValue”.

If I run “addition” service it will run the “getValue” service. I dont want to execute the getValue service. How to skip it at runtime. ?

I can delete/diable the getValue from the addition service but i am using that getValue in lot more services. Please help, how to skip a service execution in flow services.

Thanks,
Guru

If you don’t want to execute the “getValue” forever, like what you said, you can just delete or disable it.

If you want to skip it depends on some run-time variable, you can use the branch step.

Hi,

Thanks for the quick reply.
But in my actual code I have used storePipeline,restorePipeline services. So I want to keep this services in Dev environment and actual environment i want to skip these services execution.

Can you have any idea how can i skip (or any properties) these services execution in actual environment.

Thanks,
Guru

Yes delete/disable just make sense for it not execute it.

HTH,
RMG

How about generate a service “isDev”, return true in development environment and false in production, then branch the variable in your flow, only invoke some services when it’s true.

Just for savePipeline and restorePipeline functionalities, you can use the pipeline debug properties(version 8 or higher) instead of invoke these two services.

Yes, your corret if the code is in begging level. But in my case the code written long back and now I have to disable these (save,restore invokes) services in all of the packages(30) with out touching the code. So I am looking for a property/option where I can specify the service names global, which skip the execution at runtime.

I believe you cannot disable just the steps in the back ground ie the dead code and yes you can disable the package from the manifest file…Check the underlying service’s flow.xml or node.ndf if that is possible option in your case.

HTH,
RMG

I don’t think there is such a property. But if you are worry about the workload to change all 30 packages, you can use the java service below to automatically disable all the services you don’t want to execute in a flow service.

Two intpus:
String - serviceName - the NSName string of a flow service you want to disable something
String List - blacklist - the NSName string list of services you want to disabled

No outpus:

In code tab:
IDataCursor pipelineCursor = pipeline.getCursor();
String serviceName = IDataUtil.getString( pipelineCursor, “serviceName” );
String blacklist = IDataUtil.getStringArray( pipelineCursor, “blacklist” );
pipelineCursor.destroy();

NSNode nsNode = Namespace.current().getNode(serviceName);
if (nsNode instanceof FlowSvcImpl){
FlowSvcImpl flowService = (FlowSvcImpl)nsNode;
FlowRoot flowRoot = flowService.getFlowRoot();
disable(flowRoot, Arrays.asList(blacklist));
}

In shared tab:
Imports:
com.wm.app.b2b.server.ns.Namespace
com.wm.lang.ns.NSNode
com.wm.lang.flow.FlowRoot
com.wm.lang.flow.FlowElement
com.wm.lang.flow.FlowInvoke
com.wm.app.b2b.server.FlowSvcImpl
java.util.List
java.util.Arrays

public static void disable(FlowElement element, final List blacklist){
int nodeCount = element.getNodeCount();
for (int i = 0; i < nodeCount; i++){
FlowElement childElement = element.getNodeAt(i);
String childElementType = childElement.getFlowType();
if (childElementType.equals(FlowElement.TYPE_INVOKE)){
FlowInvoke invokeElement = (FlowInvoke)childElement;
String service = invokeElement.getService().toString();
if (blacklist.contains(service)){
childElement.setEnabled(false);
}
}else{
disable(childElement, blacklist);
}
}
}

This service can’t disable a transformer service invoked in a map step, if you also want to disable them, you need to add additional code for FlowElement.TYPE_MAPINVOKE, I am lazy :slight_smile:

1 Like

yes you have a work around sample above:)