You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/09/20 01:53:17 UTC

[GitHub] [pulsar] RollBack2010 opened a new issue #12098: Delayed message is not valid

RollBack2010 opened a new issue #12098:
URL: https://github.com/apache/pulsar/issues/12098


   1. Download apache-pulsar-2.8.0-bin.tar.gz
   
   2. Execute "pulsar-daemon start standalone" to start the service
   
   3. Producer code:
   
      ```java
          @GetMapping("/base/sendMsg")
          public MessageId sendMsg(String msg) throws PulsarClientException {
              PulsarClient pulsarFactory = pulsarConf.pulsarFactory();
      
              Producer<byte[]> producer1 = pulsarFactory.newProducer()
                      .topic("my-topic")
      
                      .create();
              MessageId send = producer1.newMessage().deliverAfter(3L, TimeUnit.MINUTES).value("Hello Pulsar!".getBytes()).send();
              return send;
          }
      ```
   
   4. Consumer Code
   
      ```java
       @Bean
          public void comsumerByListener() throws PulsarClientException {
              MessageListener myMessageListener = (consumer, msg) -> {
                  try {
                      System.out.println("Message received: " + new String(msg.getData()));
                      consumer.acknowledge(msg);
                  } catch (Exception e) {
                      consumer.negativeAcknowledge(msg);
                  }
              };
              PulsarClient pulsarFactory = pulsarConf.pulsarFactory();
              pulsarFactory.newConsumer()
                      .topic("my-topic")
                      .subscriptionName("my-subscriptionByListener")
                      .messageListener(myMessageListener)
                      .subscribe();
          }
      
      ```
   
   Sending " base/sendmsg " request, the consumer immediately got the message, " deliverafter ( 3l, timeunit.Minutes ) " three minutes of delay doesn't work, why?
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] RollBack2010 closed issue #12098: Delayed message is not valid

Posted by GitBox <gi...@apache.org>.
RollBack2010 closed issue #12098:
URL: https://github.com/apache/pulsar/issues/12098


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] RollBack2010 commented on issue #12098: Delayed message is not valid

Posted by GitBox <gi...@apache.org>.
RollBack2010 commented on issue #12098:
URL: https://github.com/apache/pulsar/issues/12098#issuecomment-922592436


   Pulsarconf code:
   
   ```java
   package com.project.pulsar.conf;
   
   import org.apache.pulsar.client.admin.PulsarAdmin;
   import org.apache.pulsar.client.api.PulsarClient;
   import org.apache.pulsar.client.api.PulsarClientException;
   import org.springframework.beans.factory.annotation.Value;
   import org.springframework.context.annotation.Bean;
   import org.springframework.context.annotation.Configuration;
   
   @Configuration
   public class PulsarConf {
       @Value("${pulsar.url}")
       String url;
       @Value("${pulsar.serviceHttpUrl}")
       String serviceHttpUrl;
   
       @Bean
       public PulsarClient pulsarFactory(){
           PulsarClient client = null;
           try {
               client = PulsarClient.builder()
                       .serviceUrl("pulsar://"+url)
                       .build();
           } catch (PulsarClientException e) {
               e.printStackTrace();
           }
           return client;
       }
       @Bean
       public PulsarAdmin pulsarAdminFactory(){
           PulsarAdmin admin =null;
           try {
               admin = PulsarAdmin.builder()
                       .serviceHttpUrl(serviceHttpUrl)
                       .build();
           } catch (PulsarClientException e) {
               e.printStackTrace();
           }
           return  admin;
       }
   }
   
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] wh-19970312 commented on issue #12098: Delayed message is not valid

Posted by GitBox <gi...@apache.org>.
wh-19970312 commented on issue #12098:
URL: https://github.com/apache/pulsar/issues/12098#issuecomment-1018059174


   I had the same problem. Did you solve it?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org