Spike Arrest gives an execution error if placed after a Javascript policy with org level resource URL

Not applicable

Hello,

Spike Arrest policy

<SpikeArrest name="Spike-Arrest-1" > 
  <DisplayName>Spike Arrest-1</DisplayName>
  <Rate>60pm</Rate>
</SpikeArrest>

Javascript policy right before Spike Arrest.

<Javascript timeLimit="200" name="rate-limit-config"> 
  <DisplayName>rate-limit-config</DisplayName>
  <Properties/>
  <ResourceURL>jsc://rate-limit-config.js</ResourceURL>
</Javascript>

rate-limit-config.js is at the org level.

The Javascript policy works fine. I could see all its properties as expected in the trace.

Stack trace:

Path : /organizations/xyz/maskconfigs/default . Returning empty DebugMaskDataConfigurationBean
2018-08-07 10:43:12,655 org:xyz env:staging api:workspaces-nodejs rev:4 messageid:wdst2vapg22-39559-30681-1 Apigee-Main-8 ERROR MESSAGING.FLOW - AbstractAsyncExecutionStrategy$AsyncExecutionTask.call() : Exception caught java.lang.NullPointerException: null at
com.apigee.steps.ratelimit.RateLimitExecution.enforceSpikeArrest(RateLimitExecution.java:141) ~[ratelimit-1.0.0.jar:na] at
com.apigee.steps.ratelimit.RateLimitExecution.execute(RateLimitExecution.java:102) ~[ratelimit-1.0.0.jar:na] at
com.apigee.messaging.runtime.steps.StepExecution.execute(StepExecution.java:146) ~[message-processor-1.0.0.jar:na] at
com.apigee.flow.execution.AbstractAsyncExecutionStrategy$AsyncExecutionTask.call(AbstractAsyncExecutionStrategy.java:74) [message-flow-1.0.0.jar:na] at
com.apigee.flow.execution.AbstractAsyncExecutionStrategy$AsyncExecutionTask.call(AbstractAsyncExecutionStrategy.java:45) [message-flow-1.0.0.jar:na] at
java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_144] at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_144] at
java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_144] at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_144] at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)[na:1.8.0_144] at
java.lang.Thread.run(Thread.java:748) [na:1.8.0_144]


2018-08-07 10:43:14,714 IoReceiver - /172.24.20.212:5672 ERROR o.a.q.c.AMQConnection - AMQConnection.deliverJMSExceptionToExceptionListenerOrLog() : Throwable Received but no listener set: org.apache.qpid.AMQException: ch=0 id=0 ExecutionException(errorCode=NOT_FOUND, commandId=0, classCode=7, commandCode=1, fieldIndex=0, description=not-found: Exchange type not implemented: (/builddir/build/BUILD/qpid-cpp-1.37.0/src/qpid/broker/SessionAdapter.cpp:104), errorInfo={}) [error code 404: not found]

I have attached an image describing the sequence of the policies.

If I remove the JS policy, Spike Arrest works fine, without any execution error..

Hoping to get a solution for this.

Thanks.

1 4 663
4 REPLIES 4

can u share the api-proxy code?

I am using it in a shared flow. But even if I use it in an api-proxy, the error is still the same.

I can't be certain exactly what is causing the problem, without knowing the version of the software you are running.

But I think the general cause looks likely to be: you are overwriting a variable that the SpikeArrest policy is depending on.

I haven't see your JS code, but ... I suspect that you are writing variables from within JS. Try changing the names of the variables. For example, replace all use of dot (.) with underscore (_) in the variables you set, from within JavaScript.

If that does not change things, then I want to see the list of variables you are setting within the JS policy. You can get that from the Trace UI.

Thank you for replying. The version is 4.18.01.

This is my JS code

/*
Rate config for throttling all v2 APIs

To change the rate for any env, modify the "rate" property
 */

var env = context.getVariable('environment.name');
var rate_value = "60pm";
var clientId = context.getVariable('client_id');
var rateConf = {
    "dev2": {
        "enable": true,
        "rate": rate_value
    },
    "dev3": {
        "enable": true,
        "rate": rate_value
    },
    "dev4": {
        "enable": true,
        "rate": rate_value
    },
    "qc": {
        "enable": true,
        "rate": rate_value
    },
    "qc2": {
        "enable": true,
        "rate": rate_value
    },
    "qc3": {
        "enable": true,
        "rate": rate_value
    },
    "qc4": {
        "enable": true,
        "rate": rate_value
    },
    "apict": {
        "enable": true,
        "rate": rate_value
    },
    "preview": {
        "enable": true,
        "rate": rate_value
    },
    "preview2": {
        "enable": true,
        "rate": rate_value
    },
    "staging": {
        "enable": true,
        "rate": rate_value
    },
    "staging2": {
        "enable": true,
        "rate": rate_value
    },
    "prod": {
        "enable": true,
        "rate": rate_value
    },
    "prod-wdl": {
        "enable": true,
        "rate": rate_value
    }
};

context.setVariable('get_rate', rateConf[env].rate);
context.setVariable('throttle', rateConf[env].enable);