[SPRING] 서로 다른 스프링 부팅 응용 프로그램에서 서로 다른 포트에 2 개의 내장형 active-mq를 시작할 수 없습니다.
SPRING서로 다른 스프링 부팅 응용 프로그램에서 서로 다른 포트에 2 개의 내장형 active-mq를 시작할 수 없습니다.
스프링 부트 응용 프로그램이 2 개 있습니다. 각 응용 프로그램에는 활성 mq 브로커가 내장되어 있습니다.
동일한 PC에서 동시에 작동하는 2 개의 응용 프로그램이 필요하지만 지금은 작동하지 않습니다. 첫 번째 응용 프로그램은 항상 성공적으로 시작됩니다.
2018-02-02 11:48:20.095 INFO 7660 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@53045c6c: startup date [Fri Feb 02 11:48:20 MSK 2018]; root of context hierarchy
2018-02-02 11:48:20.923 INFO 7660 --- [ JMX connector] o.a.a.broker.jmx.ManagementContext : JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:7777/jmxrmi
2018-02-02 11:48:20.923 INFO 7660 --- [ main] o.apache.activemq.broker.BrokerService : Using Persistence Adapter: KahaDBPersistenceAdapter[D:\work\arbitrage_robot\root\activemq-data\localhost\KahaDB]
2018-02-02 11:48:21.231 INFO 7660 --- [ main] o.a.a.store.kahadb.MessageDatabase : KahaDB is version 6
2018-02-02 11:48:21.260 INFO 7660 --- [ main] o.a.a.store.kahadb.plist.PListStoreImpl : PListStore:[D:\work\arbitrage_robot\root\activemq-data\localhost\tmp_storage] started
2018-02-02 11:48:21.395 INFO 7660 --- [ main] o.apache.activemq.broker.BrokerService : Apache ActiveMQ 5.15.2 (localhost, ID:ntkachev-60101-1517561301266-0:1) is starting
2018-02-02 11:48:21.441 INFO 7660 --- [ main] o.a.a.t.TransportServerThreadSupport : Listening for connections at: tcp://127.0.0.1:61617?broker.persistent=false
2018-02-02 11:48:21.442 INFO 7660 --- [ main] o.a.activemq.broker.TransportConnector : Connector tcp://127.0.0.1:61617?broker.persistent=false started
2018-02-02 11:48:21.442 INFO 7660 --- [ main] o.apache.activemq.broker.BrokerService : Apache ActiveMQ 5.15.2 (localhost, ID:ntkachev-60101-1517561301266-0:1) started
2018-02-02 11:48:21.442 INFO 7660 --- [ main] o.apache.activemq.broker.BrokerService : For help or more information please see: http://activemq.apache.org
2018-02-02 11:48:23.002 INFO 7660 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-02-02 11:48:23.021 INFO 7660 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 2147483647
2018-02-02 11:48:23.024 INFO 7660 --- [ main] o.a.activemq.broker.TransportConnector : Connector vm://localhost started
2018-02-02 11:48:23.051 INFO 7660 --- [ main] pack.Application : Started Application in 3.337 seconds (JVM running for 3.922)
그러나 두 번째는 멈추어 인쇄합니다.
2018-02-02 11:48:30.450 INFO 17008 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@53045c6c: startup date [Fri Feb 02 11:48:30 MSK 2018]; root of context hierarchy
2018-02-02 11:48:31.296 INFO 17008 --- [ main] o.apache.activemq.broker.BrokerService : Using Persistence Adapter: KahaDBPersistenceAdapter[D:\work\app\root\activemq-data\localhost\KahaDB]
2018-02-02 11:48:31.297 INFO 17008 --- [ JMX connector] o.a.a.broker.jmx.ManagementContext : JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
2018-02-02 11:48:31.300 INFO 17008 --- [ main] o.a.activemq.store.SharedFileLocker : Database activemq-data\localhost\KahaDB\lock is locked by another server. This broker is now in slave mode waiting a lock to be acquired
두 응용 프로그램의 구성은 거의 같습니다.
@SpringBootApplication
public class Application {
@Bean
public BrokerService broker() throws Exception {
BrokerService broker = new BrokerService();
broker.addConnector("tcp://localhost:61616?broker.persistent=false");
return broker;
}
@JmsListener(destination = "robotCommand")
public void listen(String in) {
System.out.println(in);
}
종속성 :
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-kahadb-store</artifactId>
<version>5.15.2</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
<version>5.15.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-activemq</artifactId>
<version>1.5.10.RELEASE</version>
</dependency>
이 문제를 어떻게 해결할 수 있습니까? (시작시 매달리는 응용 프로그램)?
해결법
-
==============================
1.귀하의 구성 브로커. addConnector ( "tcp : // localhost : 61616? broker.persistent = false"); 잘못된 것입니다. 이는 ActiveMQConnectionFactory, http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html#HowdoIembedaBrokerinsideaConnection-UsingActiveMQConnectionFactory를 사용하여 브로커를 만드는 경우에만 수행 할 수 있습니다.
귀하의 구성 브로커. addConnector ( "tcp : // localhost : 61616? broker.persistent = false"); 잘못된 것입니다. 이는 ActiveMQConnectionFactory, http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html#HowdoIembedaBrokerinsideaConnection-UsingActiveMQConnectionFactory를 사용하여 브로커를 만드는 경우에만 수행 할 수 있습니다.
Using ActiveMQConnectionFactory An embedded broker can also be created using an ActiveMQConnectionFactory and using a vm connector as a uri. e.g. ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
시험
@Bean public BrokerService broker() throws Exception { BrokerService broker = new BrokerService(); broker.addConnector("tcp://localhost:61616"); broker.setPersistent(false); return broker; }
from https://stackoverflow.com/questions/48579060/could-not-start-2-embedded-active-mq-on-different-ports-within-different-spring by cc-by-sa and MIT license