java - How can I set time for consumer side in RABBITMQ -


This is my code and I set two sets on auto, the exchange finally created the consumer for several minutes The message is not sending at this time I want to stop the consumer side automatically, maybe you are not fully understanding my punishment.

How can I decide that ^^

and how can I get the document object (s) on the server side

  public Void init Consumer () {{ConnectionFactory Factory = New ConnectionFeature (try); Connection connection = factory.New connection (); Channel channel = connection.createChannel (); Channel.queueDeclare (this.queueName, this.maintain, false, this.queueAutoDelete, blank); Channel.exchangeDeclare (this.exchangeName, this.exchangeType, this.maintain, this.exchangeAutoDelete, zero); Channel.queueBind (this.queueName, this.exchangeName, this.routingKey); Quewing Consumer Consumer = New Quaking Consumer (Channel); Channel.basicConsume (this.queueName, Incorrect, Consumer); While (true) {QueueingConsumer.Delivery Delivery = Consumer. NxtDelivery (); System.out.println ("[x] received" + new string (delivery. Gatebodie ()); Channel. Bassic one (delivery.getfree). GetDeliveryTag (), false); }} Hold (exception e) {System.out.println ("exception error atitConsumer ()"); }}    

You can use the overloaded version of the next delivery (), in which The timeout parameter is:

  Qiing the closure. Delivery distribution = faucet; Long timeout = 2 * 60 * 1000; Delivery in millisecond = 2 min 2 = queuingConsumer.nextDelivery (timeout); If (delivery == empty) {// Close your customer here - no events have occurred / before the expiration of / and} {/ process on the message given here}   

Hope that helps.

Comments