Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9212831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:36:52+00:00 2026-06-18T01:36:52+00:00

I have a program that sends and receives messages over an exchange. My program

  • 0

I have a program that sends and receives messages over an exchange. My program needs to continue execution regardless of whether there is a message for it in the queue. Almost all the tutorials have blocking examples:

while (true) {
     QueueingConsumer.Delivery delivery = consumer.nextDelivery();
     System.out.println("Message: " + new String(delivery.getBody()));
     ch.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
}

I came across what I understand to be the asynchronous version i.e., the handleDelivery function is called (callback) when a message is available in the queue:

 boolean autoAck = false;
 channel.basicConsume(queueName, autoAck, "myConsumerTag",
 new DefaultConsumer(channel) {
     @Override
     public void handleDelivery(String consumerTag,
                                Envelope envelope,
                                AMQP.BasicProperties properties,
                                byte[] body)
         throws IOException
     {
         String routingKey = envelope.getRoutingKey();
         String contentType = properties.contentType;
         long deliveryTag = envelope.getDeliveryTag();
         // (process the message components here ...)
         channel.basicAck(deliveryTag, false);
     }
 });

After reading over the documentation I’m still unsure whether the above code snippet is indeed asynchronous and I still can’t figure out how to get the actual message that was sent. Some help please.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T01:36:53+00:00Added an answer on June 18, 2026 at 1:36 am

    With out trying the second code snippet I can say that it is possible it does what you want. However it presumably does this but using a thread internally (which will be blocked while waiting for a new message). What I do is stick the while loop in a new Thread so that only that thread is blocked and the rest of your program continues asyncrhonously

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small program, that sends sms messages over SerialPort. It works nice
I have a simple RabbitMQ test program that sends and then receives a message
I have just started work on asmall program that sends text over net (TON)
I have a small program that sends and receives data from server and client
I am writing a Perl program that sends and receives messages from two sockets
I have a Java program that connects to a webserver using SSL/TLS, and sends
I have a Flash program that needs to make url requests to send data
I have a model program that represents message flow along a chain of servers:
My Context I have a TCP networking program that sends large objects that have
I have two programs that send and receives messages back and forth from each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.