0

I am trying to connect to my Redis instance from a groovy script (ExecuteGroovyScript) and execute arbitrary commands such as LPUSH. I currently have RedisConnectionPoolService enabled and working fine for caching processors.

Is there any way to achieve this? Any examples are appreciated.

EDIT:

I got to the point where I can call a command but for some reason it fails, here is the code and error

enter image description here

service = context.getControllerServiceLookup().getControllerService("2b841623-35ed-1e1a-0a77-46087267939d")
service.getConnection().withCloseable { redis ->
   redis.listCommands().lPush("key".getBytes(), "1".getBytes())
}

enter image description here

1 Answer 1

1

If you have a RedisConnectionPoolService called service and call service.getConnection(), you will have a Spring Redis RedisConnection instance, so you can check their API for the kinds of calls you can make.

For LPUSH specifically you can call service.getConnection().listCommands().lpush()

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! Could you please take look at my edit? I am able to call functions but they keep failing due to various type errors. Any ideas?
There should be a stack trace in logs/nifi-app.log that should give you more information about the error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.