Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grails Camel Routing Plugin Not recognising sendMessage #50

Open
anixan opened this issue Aug 6, 2015 · 8 comments
Open

Grails Camel Routing Plugin Not recognising sendMessage #50

anixan opened this issue Aug 6, 2015 · 8 comments

Comments

@anixan
Copy link

anixan commented Aug 6, 2015

Hi All,

We have a project that we recently required the use of Camel in. This projects is a Groovy/Grails project and I have installed the Routing 1.4.1 plugin.

I then proceeded to create a new route as specified in the documentation which is shown below:

package some_package

import org.apache.camel.builder.RouteBuilder

class TestRoute extends RouteBuilder {
    def grailsApplication

    @Override
    void configure() {
        def config = grailsApplication?.config

        // example:
         from('seda:input.queue').to('stream:out')

    }
}

Then I proceeded to setup a call to this Route in one of my Controllers using the following 'sendMessage' command:

//Camel Testing
def message = "This is some history"
sendMessage("seda:input.queue", message)

However when typing in the IDE the 'sendMessage' method it does say 'Type Not Found' which says to me maybe I am missing an import of something but according to the documentation this should be available to all Controllers and Services.

I added debug and the code hits the sendMessage line however does not get into the routing method.

Can someone please help with this?

Thanks

@anixan
Copy link
Author

anixan commented Aug 6, 2015

The documentation clearly says "The plug-in provides a new method, "sendMessage", to all Controllers and Services for sending messages to endpoints." however when I start typing this in InteliJ it does not resolve and is shown as 'Type Not Found'

@padcom
Copy link
Owner

padcom commented Aug 7, 2015

Have you tried any of the provided examples? Which version of grails are you using?

@anixan
Copy link
Author

anixan commented Aug 7, 2015

Yes the code above I have tried is based on the documentation.

I am using Grails 2.4.3, have a missed some sort of setup step?

I was expecting to be able to see the output in the console in InteliJ but nothing is shown.

@anixan
Copy link
Author

anixan commented Aug 7, 2015

Hi,

So I installed everything again from scratch and used an older version of InteliJ and the simple example worked great.

Next I tried a more complex example of calling a service, however the app fails on startup, I have put the Service, Route and sendMessage data below:

Route

from("seda:input.queue").filter {
            it.in.body.contains("test")
        }.to("bean:TestService?method=printMsg")

Service

def printMsg(msg){
        println(msg)
    }

sendMessage

def myMessage = "this is a test message"
sendMessage("seda:input.queue", myMessage)

The error I get when running the app is below:

Error 2015-08-07 13:46:46,156 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener  - Error initializing the application: groovy.lang.MissingMethodException: No signature of method: org.grails.plugins.routing.processor.PredicateProcessor.to() is applicable for argument types: (java.lang.String) values: [bean:TestService?method=printMsg]
Possible solutions: is(java.lang.Object), any(), use([Ljava.lang.Object;), getAt(java.lang.String), with(groovy.lang.Closure), any(groovy.lang.Closure)
Message: groovy.lang.MissingMethodException: No signature of method: org.grails.plugins.routing.processor.PredicateProcessor.to() is applicable for argument types: (java.lang.String) values: [bean:TestService?method=printMsg]
Possible solutions: is(java.lang.Object), any(), use([Ljava.lang.Object;), getAt(java.lang.String), with(groovy.lang.Closure), any(groovy.lang.Closure)

I hope you can help.

@anixan
Copy link
Author

anixan commented Aug 7, 2015

Ok so i removed the filter piece and the application loaded.

However when the sendMessage got run I got the following error:

Message: No bean could be found in the registry for: TestService

I then tried to add the bean manually using the following code but still get the same error:

void configure() {
        def config = grailsApplication?.config

        SimpleRegistry registry = new SimpleRegistry();
        registry.put("TestService", new TestService());
        CamelContext context = new DefaultCamelContext(registry);

        from("seda:input.queue").to("bean:TestService?method=printMsg")

    }

@padcom
Copy link
Owner

padcom commented Aug 7, 2015

I have not maintained this plugin for a while now but from the looks of it I'd say it is not compatible with this version of grails. Try an older version 2.0, maybe even 1.x

@anixan
Copy link
Author

anixan commented Aug 10, 2015

Hi,

I cannot revert the project to a previous version, is there any other way to get the plugin to pickup the Bean for processing?

Thanks

@anixan
Copy link
Author

anixan commented Aug 10, 2015

Hi,

Ok I got it to work I inspected all beans currently loaded and corrected my call.

This can be closed.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants