Setting up redis-gorm on a grails 5 projects - grails

I am setting up redis-gorm for my grails project.
I have followed their documentation, but thing are'nt going well.
implementation 'org.grails.plugins:redis-gorm:5.0.13'
application.yml
grails:
redis-gorm:
host: "localhost"
port: 6379
pooled: true
resources: 15
timeout: 25000
Weather i set the static mapWith = "redis" in the doamain class or not i get a class not found exception and the application stops
Caused by: java.lang.ClassNotFoundException: org.grails.datastore.gorm.bean.factory.AbstractMappingContextFactoryBean
Any idea as to what i might have missed?

Related

Rails CQL cannot connect to AWS Keyspaces (AWS Cassandra)

I am trying to connect from a Ruby on Rails application to AWS Keyspaces (AWS Cassandra), but I cannot manage to do it. I use the cequel gem and generated the config/cequel.yml which contains a similar thing to the following:
development:
host: "CONTACT_POINT"
username: "USER"
password: "PASS"
port: 9142
keyspace: key_development
max_retries: 3
retry_delay: 0.5
newrelic: true
ssl: true
server_cert: 'config/certs/AmazonRootCA1.pem'
replication:
class: NetworkTopologyStrategy
datacenter1: 3
datacenter2: 2
durable_writes: false
(Credentials where used in another app and they work which is working as expected.)
when I try to run:
rake cequel:keyspace:create
I get the following errors:
Cassandra::Errors::NoHostsAvailable: All attempted hosts failed: x.xxx.xxx.xxx (Cassandra::Errors::ServerError: Internal Server Error)
Set the dc to us-east-1 . drop the replication definition.

What is the difference between open_timeout and read_timeout in sunspot

I need a way to increase the sunspot query timeout in local development. As I was checking the sunspot code I got this code in sunspot.
solr:
hostname: localhost
port: 8983
log_level: WARNING
path: /solr/production
read_timeout: 20
open_timeout: 1
auto_index_callback: after_commit
auto_remove_callback: after_commit
Here we have two things read_timeout and open_timeout which looks similar to my problem. Since there is no documentation for it. So, can anybody tell me the purpose of both the things

HikariCP for Grails 3

I have a hard time setting up HikariCP in Grails 3.
The only thing I could realize by myself is that application.yml/dataSource.pooled must be false. The rest is kinda mystery:
This gist seems like configuration for Grails 2
Other SO questions are dealing with Grails 2 too - 1, 2
HikariCP issue with Grails 3 but with a crazy config
How can I setup HikariCP with Grails 3?
So I just got this working as expected. All you need to do is include the Hikari dependency, and set pooled: true in your application.yml.
Additional properties can be set on the Hikari connection pool by specifying them in the properties section on the dataSource
Do not create a dataSource bean in resources.groovy, as this will cause all sorts of problems if pooled is set to true, and is largely ignored if pooled is false (apart from consuming and leaving idle the entire pool of connections)
build.gradle extract:
...
compile 'com.zaxxer:HikariCP:2.7.7'
...
application.yml extract:
...
dataSource:
pooled: true
driverClassName: "org.postgresql.Driver"
postgresql:
extensions:
sequence_per_table: false
logSql: false
dbCreate: ""
username: "username"
password: "password"
url: "jdbc:postgresql://..."
properties:
maximumPoolSize: 30
registerMbeans: true
connectionTimeout: 30000
...
Its not clear to me exactly how grails/gorm detects the connection pool provider, and I'm not sure what would happen if you had two connection providers configured. I just made sure that the default tomcat dependency was missing from my build.gradle
# Remove this line from build.gradle if you have it
runtime 'org.apache.tomcat:tomcat-jdbc'

OracleDrive returned null for h2 in functional tests

Trying to add integration tests to an existing Grails 3.2.3 project, I've added the following lines to my application.yml:
environments:
test:
dataSource:
dbCreate: create-drop
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
pooled: true
driverClassName: org.h2.Driver
username: sa
password:
However, when running my integration tests, I get a message saying that the OracleDriver returns null:
ERROR org.apache.tomcat.jdbc.pool.ConnectionPool - Unable to create initial connections of pool.
java.sql.SQLException: Driver:oracle.jdbc.OracleDriver#2da84919 returned null for URL:jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
I'm in the test environment, having added the '-Dgrails.env=test' flag in my JUnit VMOptions in Intellij IDEA. I tried commenting the default datasource, with no success.
PS: I also get the error when commenting all datasources from application.yml, event the test one.
PPS: when running the integration tests through Gradle, the problem disappears.

Zuul Proxy not able to route, resulting in com.netflix.zuul.exception.ZuulException: Forwarding error

I have simple services as:
transactions-core-service and transactions-api-service.
transactions-api-service invokes transactions-core-service to return a list of transactions. transactions-api-service is enabled with hystrix command.
Both are registered in Eureka server with below services ids:
TRANSACTIONS-API-SERVICE n/a (1) (1) UP (1) - 192.168.2.12:transactions-api-service:8083
TRANSACTIONS-CORE-SERVICE n/a (1) (1) UP (1) - 192.168.2.12:transactions-core-service:8087
Below is Zuul server:
#SpringBootApplication
#Controller
#EnableZuulProxy
public class ZuulApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(ZuulApplication.class).web(true).run(args);
}
}
Zuul Configurations:
===============================================
info:
component: Zuul Server
server:
port: 8765
endpoints:
restart:
enabled: true
shutdown:
enabled: true
health:
sensitive: false
zuul:
ignoredServices: "*"
routes:
transactions-api-service:
path: transactions/accounts/**
serviceId: transactions-api-service
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
logging:
level:
ROOT: INFO
org.springframework.web: DEBUG
===============================================
When I try to invoke transactions-api-service with url (http://localhost:8765/transactions/accounts/123/transactions/786) I get Zuul Exception:
2016-02-13 11:29:29.050 WARN 4936 --- [nio-8765-exec-1]
o.s.c.n.z.filters.post.SendErrorFilter : Error during filtering
com.netflix.zuul.exception.ZuulException: Forwarding error
at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward(RibbonRoutingFilter.java:131)
~[spring-cloud-net flix-core-1.1.0.M3.jar:1.1.0.M3]
at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.run(RibbonRoutingFilter.java:76)
~[spring-cloud-netflix- core-1.1.0.M3.jar:1.1.0.M3] ......
If I invoke the transactions-api-service individually (with localhost /accounts/123/transactions/786), it works fine.
Am I missing any configurations on Zuul?
You need to change zuul execution timeout by adding this property in application.yml of zuul server:
# Increase the Hystrix timeout to 60s (globally)
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 60000
Please refer to this thread on netflix issues: https://github.com/spring-cloud/spring-cloud-netflix/issues/321
Faced same issue. In my case, zuul was using service discovery. As a solution, below configuration worked like a charm.
ribbon.ReadTimeout=60000
Reference to the property usage is here.
You have an incorrect indentation. Instead of:
zuul:
ignoredServices: "*"
routes:
transactions-api-service:
path: transactions/accounts/**
serviceId: transactions-api-service
It should be:
zuul:
ignoredServices: "*"
routes:
transactions-api-service:
path: transactions/accounts/**
serviceId: transactions-api-service
you can use this to avoid 500 error
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=1000000
zuul.host.connect-timeout-millis=10000
zuul.host.socket-timeout-millis=1000000
In case if your Zuul gateway uses discovery service for service lookup in that case you can disable the hystrix timeout or increase the hysterix timeout as below :
# Disable Hystrix timeout globally (for all services)
hystrix.command.default.execution.timeout.enabled: false
#To disable timeout foror particular service,
hystrix.command.<serviceName>.execution.timeout.enabled: false
# Increase the Hystrix timeout to 60s (globally)
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 60000
# Increase the Hystrix timeout to 60s (per service)
hystrix.command.<serviceName>.execution.isolation.thread.timeoutInMilliseconds: 60000
I was having same issue with zuul server, it got resolved with below property
Let's say you have 2 clients clientA and clientB,
so for clientA, spring.application.name=clientA and server.port=1111
for clientB spring.application.name=clientB and server.port=2222 in there respective application.propeties files.
You want to connect this 2 servers to ZuulServer which is running on port 8087.
add below properties in you ZuulServer application.properties file
spring.application.name=gateway-service
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
clientA.ribbon.listOfServers=http://localhost:1111
clientB.ribbon.listOfServers=http://localhost:2222
server.port=8087
Note: I am using Eureka Client with my Zuul Server. you can skip that part. Adding this solution in case its helpful for someone.

Resources