How to create a new Queue with RabbitMQ with Jhipster?












0















I have created a new jhipster microservice.
I have added the RabbitMQ module.
It is functionnal.
Nevertheless I wanted to create manually queue, I have tried to add it in CloudMessagingConfiguration but it does not go throw any of these methods.
Do you have any idea how to do it?



It seems more relative to JHIPSTER configuration rather to RABBITMQ.
Perhaps is it due to the difference between spring cloud messaging and spring amqp api ?



Thanks



@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.*");
}


}










share|improve this question





























    0















    I have created a new jhipster microservice.
    I have added the RabbitMQ module.
    It is functionnal.
    Nevertheless I wanted to create manually queue, I have tried to add it in CloudMessagingConfiguration but it does not go throw any of these methods.
    Do you have any idea how to do it?



    It seems more relative to JHIPSTER configuration rather to RABBITMQ.
    Perhaps is it due to the difference between spring cloud messaging and spring amqp api ?



    Thanks



    @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.*");
    }


    }










    share|improve this question



























      0












      0








      0








      I have created a new jhipster microservice.
      I have added the RabbitMQ module.
      It is functionnal.
      Nevertheless I wanted to create manually queue, I have tried to add it in CloudMessagingConfiguration but it does not go throw any of these methods.
      Do you have any idea how to do it?



      It seems more relative to JHIPSTER configuration rather to RABBITMQ.
      Perhaps is it due to the difference between spring cloud messaging and spring amqp api ?



      Thanks



      @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.*");
      }


      }










      share|improve this question
















      I have created a new jhipster microservice.
      I have added the RabbitMQ module.
      It is functionnal.
      Nevertheless I wanted to create manually queue, I have tried to add it in CloudMessagingConfiguration but it does not go throw any of these methods.
      Do you have any idea how to do it?



      It seems more relative to JHIPSTER configuration rather to RABBITMQ.
      Perhaps is it due to the difference between spring cloud messaging and spring amqp api ?



      Thanks



      @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.*");
      }


      }







      rabbitmq jhipster spring-rabbitmq






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 '18 at 13:52







      flefevre

















      asked Nov 20 '18 at 8:58









      flefevreflefevre

      225




      225
























          1 Answer
          1






          active

          oldest

          votes


















          1














          You need to add a RabbitAdmin @Bean to the configuration and it will automatically detect and declare the exchange/queue/binding.



          See the Spring AMQP documentation.






          share|improve this answer
























          • I have added the following lines ` @Bean public ConnectionFactory rabbitFactory() { return connectionFactory().rabbitConnectionFactory(); } /** * Required for executing adminstration functions against an AMQP Broker */ @Bean public AmqpAdmin amqpAdmin() { return new RabbitAdmin(rabbitFactory()); } ` But it never go into the CloudMessagingConfiguration class Any idea why Jhipster do not load the file?

            – flefevre
            Nov 20 '18 at 16:16













          • Don't put code in comments - it's unreadable; edit the question instead. Sorry - I don't know anything about JHipster.

            – Gary Russell
            Nov 20 '18 at 16:39











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389405%2fhow-to-create-a-new-queue-with-rabbitmq-with-jhipster%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You need to add a RabbitAdmin @Bean to the configuration and it will automatically detect and declare the exchange/queue/binding.



          See the Spring AMQP documentation.






          share|improve this answer
























          • I have added the following lines ` @Bean public ConnectionFactory rabbitFactory() { return connectionFactory().rabbitConnectionFactory(); } /** * Required for executing adminstration functions against an AMQP Broker */ @Bean public AmqpAdmin amqpAdmin() { return new RabbitAdmin(rabbitFactory()); } ` But it never go into the CloudMessagingConfiguration class Any idea why Jhipster do not load the file?

            – flefevre
            Nov 20 '18 at 16:16













          • Don't put code in comments - it's unreadable; edit the question instead. Sorry - I don't know anything about JHipster.

            – Gary Russell
            Nov 20 '18 at 16:39
















          1














          You need to add a RabbitAdmin @Bean to the configuration and it will automatically detect and declare the exchange/queue/binding.



          See the Spring AMQP documentation.






          share|improve this answer
























          • I have added the following lines ` @Bean public ConnectionFactory rabbitFactory() { return connectionFactory().rabbitConnectionFactory(); } /** * Required for executing adminstration functions against an AMQP Broker */ @Bean public AmqpAdmin amqpAdmin() { return new RabbitAdmin(rabbitFactory()); } ` But it never go into the CloudMessagingConfiguration class Any idea why Jhipster do not load the file?

            – flefevre
            Nov 20 '18 at 16:16













          • Don't put code in comments - it's unreadable; edit the question instead. Sorry - I don't know anything about JHipster.

            – Gary Russell
            Nov 20 '18 at 16:39














          1












          1








          1







          You need to add a RabbitAdmin @Bean to the configuration and it will automatically detect and declare the exchange/queue/binding.



          See the Spring AMQP documentation.






          share|improve this answer













          You need to add a RabbitAdmin @Bean to the configuration and it will automatically detect and declare the exchange/queue/binding.



          See the Spring AMQP documentation.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 '18 at 14:06









          Gary RussellGary Russell

          80k74472




          80k74472













          • I have added the following lines ` @Bean public ConnectionFactory rabbitFactory() { return connectionFactory().rabbitConnectionFactory(); } /** * Required for executing adminstration functions against an AMQP Broker */ @Bean public AmqpAdmin amqpAdmin() { return new RabbitAdmin(rabbitFactory()); } ` But it never go into the CloudMessagingConfiguration class Any idea why Jhipster do not load the file?

            – flefevre
            Nov 20 '18 at 16:16













          • Don't put code in comments - it's unreadable; edit the question instead. Sorry - I don't know anything about JHipster.

            – Gary Russell
            Nov 20 '18 at 16:39



















          • I have added the following lines ` @Bean public ConnectionFactory rabbitFactory() { return connectionFactory().rabbitConnectionFactory(); } /** * Required for executing adminstration functions against an AMQP Broker */ @Bean public AmqpAdmin amqpAdmin() { return new RabbitAdmin(rabbitFactory()); } ` But it never go into the CloudMessagingConfiguration class Any idea why Jhipster do not load the file?

            – flefevre
            Nov 20 '18 at 16:16













          • Don't put code in comments - it's unreadable; edit the question instead. Sorry - I don't know anything about JHipster.

            – Gary Russell
            Nov 20 '18 at 16:39

















          I have added the following lines ` @Bean public ConnectionFactory rabbitFactory() { return connectionFactory().rabbitConnectionFactory(); } /** * Required for executing adminstration functions against an AMQP Broker */ @Bean public AmqpAdmin amqpAdmin() { return new RabbitAdmin(rabbitFactory()); } ` But it never go into the CloudMessagingConfiguration class Any idea why Jhipster do not load the file?

          – flefevre
          Nov 20 '18 at 16:16







          I have added the following lines ` @Bean public ConnectionFactory rabbitFactory() { return connectionFactory().rabbitConnectionFactory(); } /** * Required for executing adminstration functions against an AMQP Broker */ @Bean public AmqpAdmin amqpAdmin() { return new RabbitAdmin(rabbitFactory()); } ` But it never go into the CloudMessagingConfiguration class Any idea why Jhipster do not load the file?

          – flefevre
          Nov 20 '18 at 16:16















          Don't put code in comments - it's unreadable; edit the question instead. Sorry - I don't know anything about JHipster.

          – Gary Russell
          Nov 20 '18 at 16:39





          Don't put code in comments - it's unreadable; edit the question instead. Sorry - I don't know anything about JHipster.

          – Gary Russell
          Nov 20 '18 at 16:39


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389405%2fhow-to-create-a-new-queue-with-rabbitmq-with-jhipster%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          How to fix TextFormField cause rebuild widget in Flutter

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith