Apache camel 将消息发送到ActiveMQ嵌入式代理挂起

Apache camel 将消息发送到ActiveMQ嵌入式代理挂起,apache-camel,activemq,Apache Camel,Activemq,我想在单元测试中模拟我的activemq实例。因此,我将队列设置为: camelContext = new DefaultCamelContext(); camelContext.setErrorHandlerBuilder(new LoggingErrorHandlerBuilder()); camelContext.getShutdownStrategy().setTimeout(SHUTDOWN_TIMEOUT_SECONDS); routePolicy

我想在单元测试中模拟我的activemq实例。因此,我将队列设置为:

    camelContext = new DefaultCamelContext();
    camelContext.setErrorHandlerBuilder(new LoggingErrorHandlerBuilder());
    camelContext.getShutdownStrategy().setTimeout(SHUTDOWN_TIMEOUT_SECONDS);

    routePolicy = new RoutePolicy();
    routePolicy.setCamelContext(camelContext);

    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
    connectionFactory.setBrokerURL("vm:localhost");
    // use a pooled connection factory between the module and the queue
    pooledConnectionFactory = new PooledConnectionFactory(connectionFactory);

    // how many connections should there be in the session pool?
    pooledConnectionFactory.setMaxConnections(this.maxConnections);
    pooledConnectionFactory.setMaximumActiveSessionPerConnection(this.maxActiveSessionPerConnection);
    pooledConnectionFactory.setCreateConnectionOnStartup(true);
    pooledConnectionFactory.setBlockIfSessionPoolIsFull(false);

    JmsConfiguration jmsConfiguration = new JmsConfiguration(pooledConnectionFactory);
    jmsConfiguration.setDeliveryPersistent(false);

    ActiveMQComponent activeMQComponent = ActiveMQComponent.activeMQComponent("vm:localhost");
但是,当我向队列发送消息时,如下所示:

producerTemplate.sendBody(uri, message);
这一进程仍悬而未决

FailoverTransport.oneway:600

你知道我使用嵌入式代理会做错什么吗?当连接到tcp端点时,这一切都可以正常工作。

您需要将URL更改为
vm://localhost
(甚至
vm://localhost?broker.persistent=false,这在单元测试中很常见,以避免磁盘上的临时数据)。

仍然挂起,在同一位置。