Java 如何在ApacheTomee下配置ActiveMQ内存设置?

Java 如何在ApacheTomee下配置ActiveMQ内存设置?,java,activemq,apache-tomee,Java,Activemq,Apache Tomee,我在ApacheTomee下有一个嵌入式ActiveMQ。TomEE在一个名为TomEE.xml的文件中配置JMS,在我的例子中,它的配置如下 <Resource id="Default JMS Resource Adapter" type="ActiveMQResourceAdapter"> BrokerXmlConfig = broker:(tcp://localhost:61616)?persistent=true ServerUrl = tcp://local

我在ApacheTomee下有一个嵌入式ActiveMQ。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>
<!-- 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>
我错过了什么

更新-更多信息,然后

然后,我将绝对路径添加到activemq.xml文件中,因为我无法从eclipse内部使其工作(我知道,这可能更像是eclipse的错误)

然后我更改了一些无效的XML,例如

<!--             <destinationPolicy> -->
<!--                 <policyMap> -->
<!--                     <policyEntries> -->
<!--                         <policyEntry queue=">" producerFlowControl="false" prioritizedMessages="true" useCache="false" expireMessagesPeriod="0" queuePrefetch="1" /> -->
<!--                         <pendingQueuePolicy> -->
<!--                             <vmQueueCursor /> -->
<!--                         </pendingQueuePolicy> -->
<!--                     </policyEntries> -->
<!--                 </policyMap> -->
<!--             </destinationPolicy> -->
经过一些google,一些解决方案似乎在某种程度上与activemq无法加载XML有关(这是有道理的,因为XML是一项最新技术,发明于96年,大约20年前)


我很紧张。

我认为您的传输连接器配置应该如下所示:

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


有关接头,请参见。

就在那里。。。现在我得到的原因是:java.io.IOException:无法加载xbean工厂:(…)原因是:java.lang.ClassNotFoundException:org.apache.activemq.xbean.XBeanBrokerFactory您在使用maven吗?如果是,将
activemqspring
工件添加到依赖项列表中。如果没有,那么手动将activemq安装中的
activemq spring-.jar
添加到类路径中。是的,我已经解决了这个问题。。。我快到了。我不得不删除一些无效的XML,现在我只想设置jdbcPersistenceAdapter。还必须使用tomee.xml中的绝对路径。。。似乎很难配置应该是simpleBTW的东西,试图从eclipse内部运行。不是Mavena毕竟,我最后修复的是连接器,它使用的是tomee语法,而不是您正确指出的activemq语法。谢谢
<!--             <destinationPolicy> -->
<!--                 <policyMap> -->
<!--                     <policyEntries> -->
<!--                         <policyEntry queue=">" producerFlowControl="false" prioritizedMessages="true" useCache="false" expireMessagesPeriod="0" queuePrefetch="1" /> -->
<!--                         <pendingQueuePolicy> -->
<!--                             <vmQueueCursor /> -->
<!--                         </pendingQueuePolicy> -->
<!--                     </policyEntries> -->
<!--                 </policyMap> -->
<!--             </destinationPolicy> -->
<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>
    </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>
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]
<transportConnectors>
    <transportConnector name="tcp" uri="tcp://0.0.0.0:61616"/>
</transportConnectors>