简体   繁体   English

Jenkins的JMS ActiveMQ锁

[英]JMS ActiveMQ lock with Jenkins

My project uses JMS with ActiveMQ and it works fine, both in production and when I run my tests local computer. 我的项目将JMS与ActiveMQ结合使用,并且在生产环境中以及运行测试本地计算机时都可以正常运行。 My problem occurs when Jenkins runs my tests (the same ones that are successful in my computer), I get the following entry in the console output: 当詹金斯(Jenkins)运行我的测试(在我的计算机中成功执行的测试)时,出现了我的问题,我在控制台输出中得到以下条目:

2016-11-17 12:17:19,277 INFO oaactivemq.store.SharedFileLocker Database activemq-data/localhost/KahaDB/lock is locked... waiting 10 seconds for the database to be unlocked. 2016-11-17 12:17:19,277信息oaactivemq.store.SharedFileLocker数据库activemq-data / localhost / KahaDB /锁已锁定...等待10秒钟,数据库将被解锁。 Reason: java.io.IOException: File 'activemq-data/localhost/KahaDB/lock' could not be locked. 原因:java.io.IOException:无法锁定文件'activemq-data / localhost / KahaDB / lock'。

Has anyone had the same experience and encountered a solution for the problem? 有没有人有相同的经验并遇到过解决问题的方法? Will be much grateful for your help! 将非常感谢您的帮助!

More details of the console output: 控制台输出的更多详细信息:

2016-11-17 12:17:09,193 WARN oaabroker.jmx.ManagementContext Failed to start jmx connector: Cannot bind to URL [rmi://localhost:1099/jmxrmi]: javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is java.rmi.AlreadyBoundException: jmxrmi]. 2016-11-17 12:17:09,193警告oaabroker.jmx.ManagementContext无法启动jmx连接器:无法绑定到URL [rmi:// localhost:1099 / jmxrmi]:javax.naming.NameAlreadyBoundException:jmxrmi [根异常是java .rmi.AlreadyBoundException:jmxrmi]。 Will restart management to re-create jmx connector, trying to remedy this issue. 将重新启动管理以重新创建jmx连接器,以尝试解决此问题。

2016-11-17 12:17:09,257 INFO oaastore.kahadb.plist.PListStore PListStore:[/var/lib/jenkins/jobs/mydir/workspace/myproject/activemq-data/localhost/tmp_storage] started 2016-11-17 12:17:09,257信息oaastore.kahadb.plist.PListStore PListStore:[/ var / lib / jenkins / jobs / mydir / workspace / myproject / activemq-data / localhost / tmp_storage]已启动

2016-11-17 12:17:09,271 INFO oaactivemq.broker.BrokerService Using Persistence Adapter: KahaDBPersistenceAdapter[/var/lib/jenkins/jobs/mydir/workspace/myproject/activemq-data/localhost/KahaDB] 2016-11-17 12:17:09,271使用持久适配器的信息oaactivemq.broker.BrokerService:KahaDBPersistenceAdapter [/ var / lib / jenkins / jobs / mydir / workspace / myproject / activemq-data / localhost / KahaDB]

2016-11-17 12:17:09,277 INFO oaactivemq.store.SharedFileLocker Database activemq-data/localhost/KahaDB/lock is locked... waiting 10 seconds for the database to be unlocked. 2016-11-17 12:17:09,277信息oaactivemq.store.SharedFileLocker数据库activemq-data / localhost / KahaDB /锁被锁定...等待10秒钟,数据库将被解锁。 Reason: java.io.IOException: File 'activemq-data/localhost/KahaDB/lock' could not be locked. 原因:java.io.IOException:无法锁定文件'activemq-data / localhost / KahaDB / lock'。

There is a previous ActiveMQ process still running that has locked the data store. 以前的ActiveMQ进程仍在运行,该进程已锁定数据存储。 This new instance you see is running as a "slave" and polling to acquire the lock. 您看到的这个新实例正在作为“从属”运行并正在轮询以获取锁。

I was able to figure out the problem. 我能够找出问题所在。 The build process running in Jenkins hanged during the testing phase and I was forced to abort it, which left a lock in the directory: dir-tests\\activemq-data\\localhost\\KahaDB. 在Jenkins中运行的构建过程在测试阶段挂起,我被迫中止该过程,这在目录dir-tests \\ activemq-data \\ localhost \\ KahaDB中留下了锁。 There are two ways to address this problem: 有两种方法可以解决此问题:

1) The most direct and correct solution is to delete dir-tests\\activemq-data\\localhost\\KahaDB\\lock, however I do not have access nor permissions in the remote Jenkins machine. 1)最直接,最正确的解决方案是删除dir-tests \\ activemq-data \\ localhost \\ KahaDB \\ lock,但是我在远程Jenkins计算机上没有访问权限。

2) We can easily create the Jms broker with a different name, eg 2)我们可以轻松创建具有不同名称的Jms代理,例如

 brokerService.setBrokerName("MyDummyBrokerName");

This causes Active-MQ to use the directory dir-tests\\activemq-data\\MyDummyBrokerName\\KahaDB, which means that it will use a different lock. 这将导致Active-MQ使用目录dir-tests \\ activemq-data \\ MyDummyBrokerName \\ KahaDB,这意味着它将使用其他锁。 However, this is a workaround and not a final solution because the old lock and corresponding directory will remain in Jenkins. 但是,这是一种解决方法,而不是最终解决方案,因为旧锁和相应的目录将保留在Jenkins中。 Nevertheless, it solves the problem for the time being and the old locks can be deleted later. 但是,它暂时解决了该问题,以后可以删除旧锁。

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

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