|
Hi all,
I'm attempting to configure my Grails app to consume messages off a remote ActiveMQ instance. I installed the jms plugin, wrote my service that will consume messages off the queue. I also added activemq as a compile time dependency in BuildConfig.groovy. I then added the following bean definition in the resources.groovy:
jmsConnectionFactory(SingleConnectionFactory){
targetConnectionFactory = { ActiveMQConnectionFactory cf ->
brokerURL = 'tcp://localhost:61616'
}
}
I fire up my ActiveMQ server, and it happily starts running on port 61616. When starting up my grails app, I get a java.net.BindException: Address already in use. Looks like the Grails app is trying to start up it's own embedded activemq instance on the same port. Anybody have any ideas on how to configure an external ActiveMQ server for message consumption? Cheers, Marco. |
|
The provided configuration snippet is correct and the jms plugin itself is not dependent on any message broker afaik. Are you sure that you didn't install the activemq plugin too? Andre Am 14.12.2010 um 13:26 schrieb Marco Vermeulen: Hi all, I'm attempting to configure my Grails app to consume messages off a remote ActiveMQ instance. I installed the jms plugin, wrote my service that will consume messages off the queue. I also added activemq as a compile time dependency in BuildConfig.groovy. I then added the following bean definition in the resources.groovy: |
|
Facing the same issue, Any helpful update ?
Jigar |
|
http://gpc.github.com/grails-jms/docs/manual/index.html
jmsConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) {
brokerURL = 'tcp://localhost:61616'
}So what you're saying the configuration option doesn't connect to a separately running instance of ActiveMQ? Matthias. 2012/2/26 jigar <[hidden email]> Facing the same issue, Any helpful update ? |
|
I was trying with activeMQ plugin which I found made to run in embedded mode so that won't help, I switched to jms plugin and now
I have two projects 1. Consumer 2. Service provider in both jms plugin is installed, grails 2.0.1, groovy 1.8 in consumer's `resources.groovy` <code> import org.springframework.jms.connection.SingleConnectionFactory import org.apache.activemq.ActiveMQConnectionFactory beans = { jmsConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) { brokerURL = 'vm://localhost' } otherJmsConnectionFactory(SingleConnectionFactory) { targetConnectionFactory = { ActiveMQConnectionFactory cf -> brokerURL = 'tcp://localhost:8999'// … something else } } } </code> and in config.groovy <code> jms { templates { other { meta { parentBean = 'standardJmsTemplate' } connectionFactoryBean = "otherJmsConnectionFactory" // use different connection factory } } } </code> and in service provider's resources.groovy <code> beans = { jmsConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) { brokerURL = 'tcp://localhost:8999' } } </code> and service <code> package serviceprovider import grails.plugin.jms.* class ServiceProviderService { def jmsService static transactional = true static exposes = ['jms1'] @Queue(name='msg1.new') def createMessage(msg) { print "Called1" return null } } </code> and from consumer's controller <code> jmsService.send(queue:'msg1.new', params.body, "other") </code> which turns into <code> | Error 2012-02-25 01:29:31,269 [http-bio-8080-exec-6] ERROR errors.GrailsExceptionResolver - ConnectException occurred when processing request: [POST] /JMSExample/message/save - parameters: body: 3 create: Create Connection refused: connect. Stacktrace follows: Message: Connection refused: connect Line | Method ->> 333 | doConnect in java.net.PlainSocketImpl - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 195 | connectToAddress in '' | 182 | connect . . . . . . . . in '' | 366 | connect in java.net.SocksSocketImpl | 529 | connect . . . . . . . . in java.net.Socket | 435 | connect in org.apache.activemq.transport.tcp.TcpTransport | 401 | doStart . . . . . . . . in '' | 53 | start in org.apache.activemq.util.ServiceSupport | 57 | start . . . . . . . . . in org.apache.activemq.transport.TransportFilter | 72 | start in org.apache.activemq.transport.WireFormatNegotiator | 57 | start . . . . . . . . . in org.apache.activemq.transport.TransportFilter | 263 | createActiveMQConnection in org.apache.activemq.ActiveMQConnectionFactory | 227 | createActiveMQConnection in '' | 175 | createConnection in '' | 173 | doCall . . . . . . . . . in grails.plugin.jms.JmsService$_send_closure4 | 169 | send in grails.plugin.jms.JmsService | 10 | doCall . . . . . . . . . in example.domain.MessageController$_closure1 | 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker | 908 | run . . . . . . . . . . in '' ^ 662 | run in java.lang.Thread </code> I run both of the projects from the same host on different port(webserver's port) and If I try to call |
|
It sounds like the
otherJmsConnectionFactory isn't picked up. In that case why don't you just modify the original bean and be done with it? I kind of don't understand the need to have multiple factories at this point.
Don't get me wrong here - I'm just trying to figure out your case..
|
|
Thanks Matthias,
I thought to use one connectionFactory to grab the connections for other service provider, Correct me if I am wrong, Followed http://forum.springsource.org/showthread.php?50334-Submitting-JMS-messages-on-to-a-remote-queue to have brokerURL point to same host with no luck, Could you please help |
|
Could it by any chance be the URL that's wrong? The default port for ActiveMQ is 61616 not 8999.
Matthias
2012/2/27 jigar <[hidden email]> Thanks Matthias, |
|
Now the conf in both resources.groovy project is
import org.springframework.jms.connection.SingleConnectionFactory import org.apache.activemq.ActiveMQConnectionFactory beans = { jmsConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) { brokerURL = 'tcp://127.0.0.1:61616' } } and when I try to call from consumer it says the above error, I didn't find any reference to 'otherJmsTemplate' | Running Grails application | Server running. Browse to http://localhost:8080/JMSExample | Error 2012-02-26 23:41:05,604 [http-bio-8080-exec-6] ERROR errors.GrailsExceptionResolver - NoSuchBeanDefinitionException occurred when processing request: [POST] /JMSExample/message/save - parameters: body: 456456 create: Create No bean named 'otherJmsTemplate' is defined. Stacktrace follows: Message: No bean named 'otherJmsTemplate' is defined Line | Method ->> 395 | normalizeServiceCtx in grails.plugin.jms.JmsService - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 166 | send in '' | 10 | doCall . . . . . . in example.domain.MessageController$_closure1 | 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker | 908 | run . . . . . . . . in '' ^ 662 | run in java.lang.Thread |
|
There's no definition of bean otherJmsTemplate in your beans configuration. beans = { brokerURL = 'tcp://127.0.0.1:61616' }jmsConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) { } No bean named 'otherJmsTemplate' is defined. Stacktrace follows: Message: No bean named 'otherJmsTemplate' is defined Define the bean as you did before - this should work.
Matthias
|
|
Still the same error that bean name was different by the way
|
|
The error was there because while calling the service I by mistake added
jmsService.send(queue:'msg1.new', params.body, "other") and that was causing the exception Now there is no exception but it doesn't come to service ever , It seems there is a minor mistake Here is the configuration if you could point out the mistake Consumer Project: -------------------------------------------------------------------------- class MessageController { def jmsService def scaffold = true def save = { jmsService.send(queue:'msg1.new', params.body) flash.message = "Message queued for persistence" redirect(action: "list") } } ------------------------------------------------------------------------------------------ resouces.groovy (Same in both project) import org.springframework.jms.connection.SingleConnectionFactory import org.apache.activemq.ActiveMQConnectionFactory beans = { jmsConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) { brokerURL = 'vm://localhost' } } ----------------------------------------------------------------------------------------- Service Project: -------------------------------------------------------------------- resources.groovy (same as above project) ------------------------------------------------------------------ Service package serviceprovider import grails.plugin.jms.* class ServiceProviderService { def jmsService static transactional = true static exposes = ['jms1'] @Queue(name='msg1.new') def createMessage(msg) { print "Called1" sleep(2000) // slow it down return null } } I don't see any message and it gets submitted successfully ![]() |
| Powered by Nabble | Edit this page |
