简体   繁体   English

如何在Apache Tomee下配置ActiveMQ内存设置?

[英]How to configure ActiveMQ memory settings under Apache Tomee?

I have an embedded ActiveMQ under Apache TomEE. 我在Apache TomEE下有一个嵌入式ActiveMQ。 TomEE configures JMS in a file called tomee.xml, in my case, it's configured like this TomEE在名为tomee.xml的文件中配置JMS,在我的例子中,它是这样配置的

<Resource id="Default JMS Resource Adapter" type="ActiveMQResourceAdapter">
    BrokerXmlConfig = broker:(tcp://localhost:61616)?persistent=true
    ServerUrl = tcp://localhost:61616
    DataSource = MyDataSource
</Resource>

Now, I'd like to specify custom memory settings, which is done in the activemq.xml file. 现在,我想指定自定义内存设置,这在activemq.xml文件中完成。 TomEE can load activemq.xml configuration using Spring XBeans if I add , like this (I think) 如果我添加,TomEE可以使用Spring XBeans加载activemq.xml配置,就像这样(我认为)

<Resource id="Default JMS Resource Adapter" type="ActiveMQResourceAdapter">
    BrokerXmlConfig = xbean:file:conf/activemq.xml
    ServerUrl = tcp://localhost:61616
    DataSource = MyDataSource
</Resource>

See http://tomee.apache.org/jms-resources-and-mdb-container.html 请参见http://tomee.apache.org/jms-resources-and-mdb-container.html

Is that right? 那正确吗?

I've added the 5 jars into tomee's lib path, just as indicated in the link above. 我已经将5个罐子添加到了tomee的lib路径中,就像上面链接中所示。

And then, I have an activemq.xml like this 然后,我有一个像这样的activemq.xml

<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding 
    copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may 
    obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed 
    on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the 
    License. -->
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">

    <!-- Allows us to use system properties as variables in this configuration file -->
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <value>file:${activemq.conf}/credentials.properties</value>
        </property>
    </bean>
    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}">
        <destinationPolicy>
            <policyMap>
                <policyEntries>
                    <policyEntry queue=">" producerFlowControl="false" prioritizedMessages="true" useCache="false" expireMessagesPeriod="0" queuePrefetch="1" />
                    <pendingQueuePolicy>
                        <vmQueueCursor />
                    </pendingQueuePolicy>
                </policyEntries>
            </policyMap>
        </destinationPolicy>

        <systemUsage>
            <systemUsage>
                <memoryUsage>
                    <memoryUsage limit="128 mb" />
                </memoryUsage>
                <storeUsage>
                    <storeUsage limit="100 gb" />
                </storeUsage>
                <tempUsage>
                    <tempUsage limit="50 gb" />
                </tempUsage>
            </systemUsage>
        </systemUsage>

        <transportConnectors>
            <transportConnector name="anythingHere" uri="broker:(tcp://localhost:61616)?persistent=true"/>
        </transportConnectors>
    </broker>
</beans>

but obviously, I am doing something wrong here, because JMS does not start and returns an error message like 但很明显,我在这里做错了,因为JMS没有启动并返回错误信息

SEVERE: Failed to connect to broker [tcp://localhost:61616]: Could not connect to
broker URL: tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused
javax.jms.JMSException: Could not connect to broker URL: tcp://localhost:61616. Reason:
java.net.ConnectException: Connection refused

what am I missing here? 我在这里想念的是什么?

UPDATE - more info then 更新 - 然后更多信息

then I've added the absolute path to the activemq.xml file because I could not make it work from inside eclipse (I know, this is probably more like eclipse's fault) 然后我添加了activemq.xml文件的绝对路径,因为我无法让它在eclipse中工作(我知道,这可能更像是eclipse的错误)

then I've changed some invalid XML such as 然后我改变了一些无效的XML,例如

<!--             <destinationPolicy> -->
<!--                 <policyMap> -->
<!--                     <policyEntries> -->
<!--                         <policyEntry queue=">" producerFlowControl="false" prioritizedMessages="true" useCache="false" expireMessagesPeriod="0" queuePrefetch="1" /> -->
<!--                         <pendingQueuePolicy> -->
<!--                             <vmQueueCursor /> -->
<!--                         </pendingQueuePolicy> -->
<!--                     </policyEntries> -->
<!--                 </policyMap> -->
<!--             </destinationPolicy> -->

and replaced with site's default 并替换为网站的默认值

<destinationPolicy>
        <policyMap>
          <policyEntries>
            <policyEntry topic=">" producerFlowControl="true">
                <!-- The constantPendingMessageLimitStrategy is used to prevent
                     slow topic consumers to block producers and affect other consumers
                     by limiting the number of messages that are retained
                     For more information, see:

                     http://activemq.apache.org/slow-consumer-handling.html

                -->
              <pendingMessageLimitStrategy>
                <constantPendingMessageLimitStrategy limit="1000"/>
              </pendingMessageLimitStrategy>
            </policyEntry>
            <policyEntry queue=">" producerFlowControl="true" memoryLimit="1mb">
              <!-- Use VM cursor for better latency
                   For more information, see:

                   http://activemq.apache.org/message-cursors.html

              <pendingQueuePolicy>
                <vmQueueCursor/>
              </pendingQueuePolicy>
              -->
            </policyEntry>
          </policyEntries>
        </policyMap>
    </destinationPolicy>

after adding kahadb from the maven repository and switching from activemq-all to activemq-spring and defining the bean into activemq.xml as 从maven存储库添加kahadb并从activemq-all切换到activemq-spring并将bean定义为activemq.xml之后

    </broker>

    <bean id="oracle-ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
        <property name="url" value="jdbc:oracle:thin:@localhost:1521:XE"/>
        <property name="username" value="xxx"/>
        <property name="password" value="xxx"/>
        <property name="poolPreparedStatements" value="true"/>
      </bean>

</beans>

finally.... I am getting a new error 终于......我收到了一个新的错误

SEVERE: Failed to load: URL [file:/home/leoks/EclipseIndigo/workspace2/Servers     /TomEE1.6.0-STABLE-config/activemq.xml], reason: Error creating bean with name  'org.apache.activemq.xbean.XBeanBrokerService#0' defined in URL [file:/home/leoks /EclipseIndigo/workspace2/Servers/TomEE1.6.0-STABLE-config/activemq.xml]: Invocation of init method failed; nested exception is java.io.IOException: Transport Connector could not be registered in JMX: Transport scheme NOT recognized: [broker]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.activemq.xbean.XBeanBrokerService#0' defined in URL [file:/home/leoks/EclipseIndigo/workspace2/Servers/TomEE1.6.0-STABLE-config/activemq.xml]: Invocation of init method failed; nested exception is java.io.IOException: Transport Connector could not be registered in JMX: Transport scheme NOT recognized: [broker]

after some google, some solutions seems to be related somehow to the incapacity of activemq to load the XML (makes sense, since XML is a recent technology, invented in 96, almost 20 years ago) 一些谷歌之后,一些解决方案似乎与activemq无法加载XML无关(有意义,因为XML是最新技术,发明于96年,差不多20年前)

I am pulling my hair off. 我脱掉了头发。

I think you transport connector configuration should look like this: 我认为您的传输连接器配置应如下所示:

<transportConnectors>
    <transportConnector name="tcp" uri="tcp://0.0.0.0:61616"/>
</transportConnectors>

See the documentation for connectors. 请参阅连接器的文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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