hawkeye
hawkeye

Reputation: 35732

Does JMS have a concept of a queue peek?

From a general Computer Science perspective - when we think of a Queue in a logical sense - we think of being able to 'peek' the first item in the queue.

When I look at the JMS API - it has a MessageListener - which has an OnMessage() method. This feels a little bit like "don't call us- we'll call you."

Does JMS have a concept of a queue peek?

Upvotes: 6

Views: 5969

Answers (2)

Evgeniy Dorofeev
Evgeniy Dorofeev

Reputation: 136062

1) If you want to receive messages synchroneously use MessageConsumer.receive

2) Basically, 'peek' in queues means to return, but do not remove, the head of the queue. For this you can use QueueBrowser to look at messages on a queue without removing them.

Upvotes: 6

JB Nizet
JB Nizet

Reputation: 692003

JMS has a QueueReceiver, which, well, receives messages. You can set a MessageListener to this QueueReceiver to be notified of new messages.

Upvotes: 0

Related Questions