简体   繁体   中英

Riak for Grails Plugin - Failing to work

I'm trying to configure and test the Riak for Grails plugin. I've removed the hibernate plugin by removing it's dependency in BuildConfig. Note: I'm not attempting to use this against GORM - but merely querying using the spring data support.

I've had to add the following two lines to avoid errors at runtime after removing hibernate;

springConfig.addAlias "persistenceInterceptor", "riakPersistenceInterceptor"
springConfig.addAlias('transactionManager', 'riakTransactionManager')

The project compiles fine, and runs. However - as soon as I attempt to use any of the Riak methods I usually end up with a 404 - Object not found error, or something more elusive.

Documentation suggests I can use an autowired service;

import org.springframework.data.keyvalue.riak.core.RiakTemplate

class myClass {

    // Service injection
    def riakTemplate

    def myMethod() {
        riakTemplate.set("myBucket", "myKey", "A String")
    }

}

But this doesn't work. I've tried;

RiakTemplate riakTemplate = new riakTemplate("serviceurl", "mapredurl")
riakTemplate.set("myBucket", "myKey", "A String")

I'm running out of ideas. Is there a guide or something helpful to get this working?

Its worth noting I have Riak running on my localhost, and I can manage keys using Curl easily enough. So I don't think it's a Riak issue.

I'm possibly missing something obvious. :)

I'm running Grails 2.1.0.

Thank you!

I know this does not 'answer the question,' but for a current project we decided to abandon the plugin, because of similar problems, in favor of using Spring Rest directly in service classes. I think this approach would work well for you, too, since you mention at the top that you are not trying to use the plugin's GORM support.

You should find a direct Spring Rest approach fairly easy to implement with greater control over map reduce and leveraging 2i. I would also recommend starting with a Riak interface that attempts to follow Basho's own Java client so that you might find it easier to replace your Rest implementation with Basho's PBC implementation sometime in the future if you feel you need the performance advantages.

A particular note about the Riak plugin: it seems to have gone on indefinite hold a while ago, and the lead, Jonathan Brisbin, seems to be particularly focused on the new Spring Data - REST project lately - maybe new work on the Riak plugin will 'spring' out of this?

-Todd

I was hit with this issue as well and found it is due to the fact that the default configuration is to use the DefaultErrorHandler in the underlying RestTemplate.

To have the RiakTemplate not fail on 404s you can set the property 'ignoreNotFound' to true and it will work again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM