Spring Boot ActiveMQ-端口已在使用:1099

Spring Boot ActiveMQ-端口已在使用:1099,spring,spring-boot,jms,activemq,Spring,Spring Boot,Jms,Activemq,我是ActiveMQ新手,我需要创建spring引导应用程序,其中有publis ActiveMQ队列。因此,我创建了简单的SpringBoot应用程序 @SpringBootApplication @EnableJms public class Application { @Bean JmsListenerContainerFactory<?> myJmsContainerFactory(ConnectionFactory connectionFactory) {

我是ActiveMQ新手,我需要创建spring引导应用程序,其中有publis ActiveMQ队列。因此,我创建了简单的SpringBoot应用程序

@SpringBootApplication
@EnableJms
public class Application {

  @Bean 
  JmsListenerContainerFactory<?> myJmsContainerFactory(ConnectionFactory connectionFactory) {
      SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory();
      factory.setConnectionFactory(connectionFactory);
      return factory;
  }

  public static void main(String[] args) {
      FileSystemUtils.deleteRecursively(new File("activemq-data"));
      // Launch the application
      ApplicationContext context = SpringApplication.run(Application.class, args);
      System.out.println(" ************************ Asyn queue start ************************ ");        
  }
}
但当我运行Testing.main时,会出现以下错误:

[main]调试org.apache.activemq.broker.jmx.ManagementContext-无法创建本地注册表 java.rmi.server.ExportException:端口已在使用:1099;嵌套异常是: java.net.BindException:地址已在使用中:JVM\u Bind 位于sun.rmi.transport.tcp.tcpttransport.listen(tcpttransport.java:341) 位于sun.rmi.transport.tcp.tcpttransport.exportObject(tcpttransport.java:249) 位于sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:411) 位于sun.rmi.transport.LiveRef.exportObject(LiveRef.java:147) 位于sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:208) 位于sun.rmi.registry.RegistryImpl.setup(RegistryImpl.java:152) 位于sun.rmi.registry.RegistryImpl。(RegistryImpl.java:112) 位于java.rmi.registry.LocateRegistry.createRegistry(LocateRegistry.java:239) 位于org.apache.activemq.broker.jmx.ManagementContext.createConnector(ManagementContext.java:418) 位于org.apache.activemq.broker.jmx.ManagementContext.findtigerbeanserver(ManagementContext.java:363) 位于org.apache.activemq.broker.jmx.ManagementContext.findMBeanServer(ManagementContext.java:330) 位于org.apache.activemq.broker.jmx.ManagementContext.getMBeanServer(ManagementContext.java:172) 位于org.apache.activemq.broker.jmx.ManagementContext.start(ManagementContext.java:80) 位于org.apache.activemq.broker.BrokerService.startManagementContext(BrokerService.java:2031) 位于org.apache.activemq.broker.BrokerService.start(BrokerService.java:477)


我认为问题在于测试方法。但我不知道什么是错误的。有人能帮我吗?谢谢。

您是否尝试运行
netstat
命令来检查端口是否正在使用

对于linux
netstat-pnlt | grep 1099


对于windows
netstat-np TCP |查找“1099”

是否尝试运行
netstat
命令来检查端口是否正在使用

对于linux
netstat-pnlt | grep 1099


对于windows
netstat-np TCP |查找“1099”

我知道SpringBoot应用程序正在使用该端口。启动SpringBoot应用程序后,将打印以下日志:

[           main] o.apache.activemq.broker.BrokerService   : Using Persistence Adapter: MemoryPersistenceAdapter
[           main] o.apache.activemq.broker.BrokerService   : ActiveMQ 5.4.2 JMS Message Broker (localhost) is starting
[           main] o.apache.activemq.broker.BrokerService   : For help or more information please see: http://activemq.apache.org/
[  JMX connector] o.a.a.broker.jmx.ManagementContext       : JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
[           main] o.apache.activemq.broker.BrokerService   : ActiveMQ JMS Message Broker (localhost, ID:CZ408016-49987-1470397291692-0:1) started
[           main] o.a.activemq.broker.TransportConnector   : Connector vm://localhost Started
[           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
[           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 2147483647
[           main] c.c.e.asynqueue.spring.Application       : Started Application in 3.117 seconds (JVM running for 4.52)
但我假设我可以通过以下代码连接到broker:

ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost");
// Create a Connection
Connection connection = connectionFactory.createConnection();
connection.start();

我知道SpringBoot应用程序正在使用该端口。启动SpringBoot应用程序后,将打印以下日志:

[           main] o.apache.activemq.broker.BrokerService   : Using Persistence Adapter: MemoryPersistenceAdapter
[           main] o.apache.activemq.broker.BrokerService   : ActiveMQ 5.4.2 JMS Message Broker (localhost) is starting
[           main] o.apache.activemq.broker.BrokerService   : For help or more information please see: http://activemq.apache.org/
[  JMX connector] o.a.a.broker.jmx.ManagementContext       : JMX consoles can connect to service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
[           main] o.apache.activemq.broker.BrokerService   : ActiveMQ JMS Message Broker (localhost, ID:CZ408016-49987-1470397291692-0:1) started
[           main] o.a.activemq.broker.TransportConnector   : Connector vm://localhost Started
[           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
[           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 2147483647
[           main] c.c.e.asynqueue.spring.Application       : Started Application in 3.117 seconds (JVM running for 4.52)
但我假设我可以通过以下代码连接到broker:

ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost");
// Create a Connection
Connection connection = connectionFactory.createConnection();
connection.start();