Reputation: 531
I am using grails 3.0.4 and install-plugin doesn't work anymore. I have added routing plugin in gradle dependencies but I can use the command grails create-route as in the online examples. I have created my own route class in grails-app/routes but when I run grails doesn't seem to use the route at all. Is there extra config that I have to do like create a bean somewhere?
my class is as follows:
import org.apache.camel.builder.RouteBuilder
class TrackingMessageRoute extends RouteBuilder {
def grailsApplication
@Override
void configure() {
def config = grailsApplication?.config
from('seda:input.queue').to('stream:out')
from('mina2:tcp://localhost:553').to('stream:out')
}
}
Upvotes: 1
Views: 1022
Reputation: 531
Its true that the routing plugin has not been updated for grails 3 but like @jstell suggested, using camel libraries is actually easy. This is how I implemented my solution:
In build.gradle under dependencies add the following dependencies depending on the components you want to use as follows.
runtime "org.apache.camel:camel-core:2.15.3" runtime "org.apache.camel:camel-groovy:2.15.3" runtime "org.apache.camel:camel-stream:2.15.3" //runtime "org.apache.camel:camel-netty:2.15.3" runtime "org.apache.camel:camel-netty4:2.15.3" runtime "org.apache.camel:camel-spring:2.15.3" runtime "org.apache.camel:camel-jms:2.15.3" runtime "org.apache.activemq:activemq-camel:5.11.1" runtime "org.apache.activemq:activemq-pool:5.11.1"
Create a route that extends RouteBuilder as follows:
class TrackingMessageRoute extends RouteBuilder {
def grailsApplication
@Override
void configure() {
def config = grailsApplication?.config
//from('netty4:tcp://192.168.254.3:553?sync=true&decoders=#decoders&encoder=#encoder').to('activemq:queue:Mimacs.Tracking.Queue')
from('netty4:tcp://192.168.254.3:553?serverInitializerFactory=#sif&keepAlive=true&sync=true&allowDefaultCodec=false').to('activemq:queue:Mimacs.Tracking.Queue')
from('activemq:queue:Mimacs.Tracking.Queue').bean(MimacsMessageListener.class)
}
}
CamelContext camelContext = new DefaultCamelContext(registry) camelContext.addComponent("activemq",ActiveMQComponent.activeMQComponent("failover:tcp://localhost:61616")) camelContext.addRoutes new TrackingMessageRoute() camelContext.start()
NB. I left out certains part of code that do not affect this answer. If you have these then you ar good to go.
Upvotes: 2
Reputation: 706
The routing plugin has not yet been updated for Grails 3. See https://github.com/grails/grails-core/wiki/Grails-3-Priority-Upgrade-Plugins for the Grails 3 readiness status of several important plugins.
Since Grails 3 is closely tied to Spring boot, it should be relatively easy to use Camel libraries directly (without need for a plugin). See http://camel.apache.org/spring-boot.html for potentially helpful info.
Upvotes: 1