This commit is contained in:
Dejan Bosanac 2015-02-12 11:35:06 +01:00
parent 2b17fd8050
commit 7d14ddb0d1
6 changed files with 234 additions and 49 deletions

View File

@ -71,6 +71,10 @@
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>slf4j-log4j12</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -116,7 +120,13 @@
<include>org.apache.geronimo.specs:geronimo-annotation_1.0_spec</include> <include>org.apache.geronimo.specs:geronimo-annotation_1.0_spec</include>
<include>org.slf4j:slf4j-api</include> <include>org.slf4j:slf4j-api</include>
<include>org.slf4j:slf4j-log4j12</include> <include>org.slf4j:slf4j-log4j12</include>
<include>org.slf4j:jcl-over-slf4j</include>
<include>log4j:log4j</include> <include>log4j:log4j</include>
<include>org.springframework:spring-core</include>
<include>org.springframework:spring-beans</include>
<include>org.springframework:spring-context</include>
<include>org.springframework:spring-expression</include>
<include>org.apache.xbean:xbean-spring</include>
</includes> </includes>
</artifactSet> </artifactSet>
@ -140,6 +150,11 @@
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource> <resource>META-INF/spring.schemas</resource>
</transformer> </transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.apache.activemq.console.command.ShellCommand</mainClass>
</transformer>
</transformers> </transformers>
</configuration> </configuration>
</execution> </execution>

View File

@ -0,0 +1,109 @@
<!--
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.
-->
<!-- START SNIPPET: example -->
<beans
xmlns="http://www.springframework.org/schema/beans"
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">
<!--
The <broker> element is used to configure the ActiveMQ broker.
-->
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="activemq-data">
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry topic=">" expireMessagesPeriod="0" optimizedDispatch="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>
</policyEntries>
</policyMap>
</destinationPolicy>
<!--
The managementContext is used to configure how ActiveMQ is exposed in
JMX. By default, ActiveMQ uses the MBean server that is started by
the JVM. For more information, see:
http://activemq.apache.org/jmx.html
-->
<managementContext>
<managementContext createConnector="true"/>
</managementContext>
<!--
Configure message persistence for the broker. The default persistence
mechanism is the KahaDB store (identified by the kahaDB tag).
For more information, see:
http://activemq.apache.org/persistence.html
-->
<persistenceAdapter>
<kahaDB directory="activemq-data/kahadb"/>
</persistenceAdapter>
<!--
The systemUsage controls the maximum amount of space the broker will
use before disabling caching and/or slowing down producers. For more information, see:
http://activemq.apache.org/producer-flow-control.html
-->
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage percentOfJvmHeap="70" />
</memoryUsage>
<storeUsage>
<storeUsage limit="100 gb"/>
</storeUsage>
<tempUsage>
<tempUsage limit="50 gb"/>
</tempUsage>
</systemUsage>
</systemUsage>
<!--
The transport connectors expose ActiveMQ over a given protocol to
clients and other brokers. For more information, see:
http://activemq.apache.org/configuring-transports.html
-->
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0: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+nio://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
</broker>
</beans>
<!-- END SNIPPET: example -->

View File

@ -0,0 +1,43 @@
## ---------------------------------------------------------------------------
## 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.
## ---------------------------------------------------------------------------
#
# This file controls most of the logging in ActiveMQ which is mainly based around
# the commons logging API.
#
log4j.rootLogger=INFO, console
log4j.logger.org.apache.activemq.spring=WARN
log4j.logger.org.apache.activemq.web.handler=WARN
log4j.logger.org.springframework=WARN
log4j.logger.org.apache.xbean=WARN
log4j.logger.org.apache.camel=INFO
log4j.logger.org.eclipse.jetty=WARN
# When debugging or reporting problems to the ActiveMQ team,
# comment out the above lines and uncomment the next.
#log4j.rootLogger=DEBUG, logfile, console
# Or for more fine grained debug logging uncomment one of these
#log4j.logger.org.apache.activemq=DEBUG
#log4j.logger.org.apache.camel=DEBUG
# Console appender
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%5p | %m%n
log4j.appender.console.threshold=INFO

View File

@ -48,7 +48,9 @@ public class ConsumerCommand extends AbstractCommand {
LOG.info("Running " + parallelThreads + " parallel threads"); LOG.info("Running " + parallelThreads + " parallel threads");
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerUrl); ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerUrl);
Connection conn = factory.createConnection(user, password); Connection conn = null;
try {
conn = factory.createConnection(user, password);
conn.start(); conn.start();
Session sess; Session sess;
@ -73,6 +75,11 @@ public class ConsumerCommand extends AbstractCommand {
} }
active.await(); active.await();
} finally {
if (conn != null) {
conn.close();
}
}
} }
public String getBrokerUrl() { public String getBrokerUrl() {

View File

@ -55,7 +55,9 @@ public class ProducerCommand extends AbstractCommand {
LOG.info("Running " + parallelThreads + " parallel threads"); LOG.info("Running " + parallelThreads + " parallel threads");
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerUrl); ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerUrl);
Connection conn = factory.createConnection(user, password); Connection conn = null;
try {
conn = factory.createConnection(user, password);
conn.start(); conn.start();
Session sess; Session sess;
@ -83,6 +85,11 @@ public class ProducerCommand extends AbstractCommand {
} }
active.await(); active.await();
} finally {
if (conn != null) {
conn.close();
}
}
} }
public String getBrokerUrl() { public String getBrokerUrl() {

View File

@ -109,6 +109,10 @@ public class ShellCommand extends AbstractCommand {
} }
} }
public static void main(String[] args) {
main(args, System.in, System.out);
}
public boolean isInteractive() { public boolean isInteractive() {
return interactive; return interactive;
} }