Hi,

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();
connection.start();

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

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

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

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

session.close();
connection.close();


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: 
http://activemq.2283324.n4.nabble.com/Synchonous-delivery-of-messages-tp4693836.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to