JMS is by its very nature designed to support asynchronous message
delivery; there may be a way to make ActiveMQ support the kind of
synchronous messaging you're describing out of the box, but I'm not sure
what it is.

With that being said, you could solve this problem by having your consumers
explicitly ack all messages (that aren't themselves acks) and treat any
message not acked within a short time period of your choosing to mean that
the consumer is not available.  Or you could set each message with a short
expiration window and have each producer watch the DLQ for messages they
produced, which would indicate that the message wasn't consumed in time
(and so again, the consumer isn't connected).  Or you could have a
handshaking/negotiation phase at the beginning when the two sides establish
that the other is there before anyone tries to send any data.  Or...

So ActiveMQ could be made to meet your needs in any of a number of ways,
but in all of those cases you'd need to add code in your application to
detect the non-presence of the consumer since (as far as I know) you won't
get it for free.

On Thu, Mar 26, 2015 at 2:33 AM, anlima <activ...@mherrn.de> wrote:

> 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