运行integrat后,activeMQ平滑关闭

时间:2015-03-27 21:19:14

标签: maven testing jms activemq

我正在使用ActiveMQ使用mvn build运行我的集成测试。我的pom.xml首先触发activemq,然后触发集成测试,以便他们可以使用上面的activeMQ实例来传输消息。

它工作正常但没有顺利关闭..当mvn构建结束并且所有测试都成功时,构建看起来很好。但activemq在关闭时吐出以下错误: -

'[INFO] Apache ActiveMQ 5.7.0 (localhost, ID:LB3290FPF-54398-1427490319466-0:1) is shutting down
Exception in thread "ActiveMQ ShutdownHook" java.lang.NoClassDefFoundError: org/apache/activemq/transport/vm/VMTransportFactory
at org.apache.activemq.broker.BrokerService.stop(BrokerService.java:750)
at org.apache.activemq.xbean.XBeanBrokerService.stop(XBeanBrokerService.java:91)
at org.apache.activemq.broker.BrokerService.containerShutdown(BrokerService.java:2303)
at org.apache.activemq.broker.BrokerService$6.run(BrokerService.java:2270)
Caused by: java.lang.ClassNotFoundException: org.apache.activemq.transport.vm.VMTransportFactory
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
... 4 more
[INFO] Connector tcp://localhost:61616?useJmx=true&persistent=false Stopped'

当maven构建完成时,是否有一种方法可以让Maven顺利关闭activeMQ而不会超过Exceptions?以下是一些相关的细节: -

  1. activeMQ uri: tcp:// localhost:61616?useJmx = false& persistent = false
  2. fork:true
  3. activeMQ-core:5.7.0
  4. maven-activemq-plugin:5.7.0

2 个答案:

答案 0 :(得分:0)

您需要将useShutdownHook="false"添加到XML配置的<broker>元素中。嵌入ActiveMQ但未正确配置时会出现此问题。

示例配置

<amq:broker useJmx="false" persistent="false" useShutdownHook="false">
...
</amq:broker>

<强>参考:

类似的主题:

ActiveMQ embedded broker, exception in shutdown hook

Unable to shutdown embedded activeMQ service using the built in BrokerService.stop call

希望它有所帮助。

答案 1 :(得分:0)

您可以在完成集成测试后停止activemq实例。只需将以下几行添加到pom。

<execution>
    <id>stop-activemq</id>
    <goals>
         <goal>stop</goal>
    </goals>
    <phase>post-integration-test</phase>
</execution>