activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anlima <>
Subject Synchonous delivery of messages
Date Thu, 26 Mar 2015 08:33:06 GMT

we are evaluating ActiveMQ as the messaging component for our distributed
software system.
What we have are different processes (possibly running on different
computers) that should communicate with each other.

But that means we want (in most cases) synchronous communication. That is,
the sender sends a message to the message broker (activeMQ) which
immediately delivers the message to the recipient. If the recipient isn't
available, the sender should get an error on sending.

We thought we could use the Queues for that. The sender (Producer) and
recipient (Consumer) open the same queue and communicate over that. However
in our test examples the broker just queues the messages it receives, even
if no Consumer is registered for that queue (example code below).
Is it possible to have "real" synchonous messaging with ActiveMQ like we
want it?

And here the example (Producer) code:

// Create a ConnectionFactory
ConnectionFactory connectionFactory=new ActiveMQConnectionFactory("admin",
"admin", ActiveMQConnection.DEFAULT_BROKER_URL);

// Create a Connection
Connection connection = connectionFactory.createConnection();

// Create a Session
Session session = connection.createSession(false,

// Create the destination
Destination destination = session.createQueue("testQ");

// Create a MessageProducer from the Session to the Queue
MessageProducer producer = session.createProducer(destination);

// Create a messages
TextMessage message = session.createTextMessage("Helloworld");


The problem is that "producer.send(message) returns after ActiveMQ received
the message. We want it to return after the Consumer received it or throw an
error or there is no Consumer.

View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message