如何使用Jhipster使用RabbitMQ创建新队列?

如何使用Jhipster使用RabbitMQ创建新队列?,rabbitmq,jhipster,spring-rabbit,Rabbitmq,Jhipster,Spring Rabbit,我创建了一个新的jhipster微服务。 我已经添加了RabbitMQ模块。 这是功能性的。 尽管如此,我还是希望手动创建队列,我尝试将其添加到CloudMessagingConfiguration中,但它不会抛出任何这些方法。 你知道怎么做吗 它似乎更倾向于JHIPSTER配置,而不是RABBITMQ。 可能是因为spring云消息传递和spring amqp api之间的差异 谢谢 @Configuration @Profile(JHipsterConstants.SPRING_PROFIL

我创建了一个新的jhipster微服务。 我已经添加了RabbitMQ模块。 这是功能性的。 尽管如此,我还是希望手动创建队列,我尝试将其添加到CloudMessagingConfiguration中,但它不会抛出任何这些方法。 你知道怎么做吗

它似乎更倾向于JHIPSTER配置,而不是RABBITMQ。 可能是因为spring云消息传递和spring amqp api之间的差异

谢谢

@Configuration
@Profile(JHipsterConstants.SPRING_PROFILE_CLOUD)
@EnableRabbit
public class CloudMessagingConfiguration extends AbstractCloudConfig {

private final Logger log = LoggerFactory.getLogger(CloudMessagingConfiguration.class); 

@Bean
public ConnectionFactory rabbitFactory() {
    return connectionFactory().rabbitConnectionFactory();
}

   /**
   * Added thanks to the comment of Gary Russell
   * Required for executing adminstration functions against an AMQP Broker 
   */ 
   @Bean
   public AmqpAdmin amqpAdmin() {
     return new RabbitAdmin(rabbitFactory()); 
   } 

/**
 * This queue will be declared. This means it will be created if it does not exist. Once declared, you can do something
 * like the following:
 * 
 * @RabbitListener(queues = "#{@myDurableQueue}")
 * @Transactional
 * public void handleMyDurableQueueMessage(CustomDurableDto myMessage) {
 *    // Anything you wanenter code heret! This can also return a non-void which will queue it back in to the queue attached to @RabbitListener
 * }
 */
@Bean
public Queue myDurableQueue() {
    // This queue has the following properties:
    // name: my_durable
    // durable: true
    // exclusive: false
    // auto_delete: false
    return new Queue("my_durable", true, false, false);
}

/**
 * The following is a complete declaration of an exchange, a queue and a exchange-queue binding
 */
@Bean
public TopicExchange emailExchange() {
    return new TopicExchange("email", true, false);
}

@Bean
public Queue inboundEmailQueue() {
    return new Queue("email_inbound", true, false, false);
}

@Bean
public Binding inboundEmailExchangeBinding() {
    // Important part is the routing key -- this is just an example
    return BindingBuilder.bind(inboundEmailQueue()).to(emailExchange()).with("from.*");
}

}

您需要向配置中添加一个
RabbitAdmin
@Bean
,它将自动检测和声明交换/队列/绑定


请参阅。

我添加了以下行`@Bean public ConnectionFactory rabbitFactory(){return ConnectionFactory().rabbitConnectionFactory();}/***对AMQP代理执行管理函数所需的行*/@Bean public AmqpAdmin AmqpAdmin(){return new RabbitAdmin(rabbitFactory());}`但它从未进入CloudMessagingConfiguration类。你知道Jhipster为什么不加载该文件吗?不要在注释中添加代码-它不可读;改为编辑问题。抱歉-我对Jhipster一无所知。