product-apim
product-apim copied to clipboard
[4.0.0] Error when Deploying a Custom Policy in Admin Portal
Description:
The following error gets logged in the console when creating a custom policy from the admin portal
ERROR - PolicyUtil Error in deploying execution plan
org.wso2.carbon.event.processor.core.exception.ExecutionPlanConfigurationException: Couldn't parse execution plan:
@Plan:name('global_c2')
@Plan:description('ExecutionPlan for global_c2')
@Import('org.wso2.throttle.processed.request.stream:1.0.0')
define stream RequestStream (messageID string, appKey string, appTier string, subscriptionKey string, apiKey string, apiTier string, subscriptionTier string, resourceKey string, resourceTier string, userId string, apiContext string, apiVersion string, appTenant string, apiTenant string, appId string, apiName string, propertiesMap string);
@Export('org.wso2.throttle.globalThrottle.stream:1.0.0')
define stream GlobalThrottleStream (throttleKey string, isThrottled bool, expiryTimeStamp long);
FROM RequestStream SELECT userId, (userId = = '[email protected]') AS isEligible, str: concat('[email protected]', '') as throttleKey INSERT INTO EligibilityStream; FROM EligibilityStream [ isEligible = = true ] # throttler: timeBatch(1 min) SELECT throttleKey, (count(userId) >= 5) as isThrottled, expiryTimeStamp group by throttleKey INSERT ALL EVENTS into ResultStream;
from ResultStream#throttler:emitOnStateChange(throttleKey, isThrottled)
select *
insert into GlobalThrottleStream;
at org.wso2.carbon.event.processor.core.internal.CarbonEventProcessorService.deployExecutionPlan(CarbonEventProcessorService.java:131) ~[?:?]
at org.wso2.carbon.apimgt.throttle.policy.deployer.utils.PolicyUtil.deployPolicy(PolicyUtil.java:133) ~[org.wso2.carbon.apimgt.throttle.policy.deployer_9.0.174.jar:?]
at org.wso2.carbon.apimgt.throttle.policy.deployer.utils.ThrottlePolicyJMSMessageListener.lambda$handleNotificationMessage$3(ThrottlePolicyJMSMessageListener.java:184) ~[org.wso2.carbon.apimgt.throttle.policy.deployer_9.0.174.jar:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_241]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_241]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_241]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_241]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_241]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_241]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_241]
Steps to reproduce:
- Log in to the admin portal
- Navigate to the Custom Policies tab
- Add a new custom policy. Use
$userId
as the Key Template and use the given sample siddhi query. When theAdd
button is clicked, the UI will show that the custom policy was successfully added, but the above mentioned error will be logged in the server console.
Affected Product Version:
API-M 4.0.0

This was due to incorrect equals sign('= =') in the sample policy. After correcting this I was able to create the policy without any errors.