嵌入Grails应用程序的ActiveMQ代理不会侦听外部连接

时间:2011-07-27 00:48:51

标签: grails activemq

我已经使用grails-activemq插件将ActiveMQ代理嵌入到Tomcat 7中运行的Grails应用程序中。问题是代理只是在侦听本地连接。 netstat -an显示了这一点:

tcp        0      0 127.0.0.1:61616             0.0.0.0:*                   LISTEN

我在tomcat / conf / context.xml中设置了JNDI,就像这样

<Context>
    <Resource name="jms/ConnectionFactory" auth="Container"
        type="org.apache.activemq.ActiveMQConnectionFactory" description="JMS Connection Factory"
        factory="org.apache.activemq.jndi.JNDIReferenceFactory"
        brokerURL="tcp://10.39.95.39:61616"
    brokerName="LocalActiveMQBroker"/>
    <Resource name="jms/letterCountQueue" auth="Container"
        type="org.apache.activemq.command.ActiveMQQueue" description="letterCountQueue"
        factory="org.apache.activemq.jndi.JNDIReferenceFactory" physicalName="letterCountQueue"/>
</Context>

grails-app / conf / spring / resources.groovy包含

import org.apache.activemq.ActiveMQConnectionFactory
import org.apache.activemq.broker.TransportConnector
import org.apache.activemq.command.ActiveMQQueue
import org.apache.activemq.xbean.XBeanBrokerService

import org.springframework.jms.core.JmsTemplate
import org.springframework.jms.connection.SingleConnectionFactory
import org.springframework.jms.listener.DefaultMessageListenerContainer

beans = {

    jmsBroker(XBeanBrokerService) {
        useJmx = 'false'
        persistent = 'false'
        transportConnectors = [new TransportConnector(uri: new URI('tcp://10.39.95.39:61616'))]
    }

    jmsFactory(ActiveMQConnectionFactory) {
        brokerURL = 'tcp://10.39.95.39:61616'
    }

    notificationQueue(ActiveMQQueue, 'queue.notification')

    jmsTemplate(JmsTemplate) {
        connectionFactory =  { SingleConnectionFactory cf ->
            targetConnectionFactory = ref('jmsFactory')
        }
    }
}

我在哪里指定或接受默认情况下代理不监听localhost之外的连接?我怎么能改变它?

非常感谢,
李格雷

1 个答案:

答案 0 :(得分:0)

我遇到了类似您的类似问题。尝试像这样修改%ACTIVEMQ_HOME%/conf/activemq.xml

<transportConnectors>
    <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
    <transportConnector name="openwire" uri="tcp://192.168.1.252:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
</transportConnectors>