I prefer a deep explanation about Topics and Queues instead of a simple comparison, if you really want to learn the differences, then an extensive explanation will be good:
In default configuration, Consumers in the Queue
and in the Topic
"receive" the messages, they don't "get" the messages, they "listen" and the Broker "sends" the messages.
The Broker "pushes" messages to the consumers.
It's because pushing messages have a high throughput, and it's scalable.
This process is always asynchronous.
You can "get" messages in a Queue
, but not in a Topic
. When you "get" a message, this process is synchronous, and it isn't scalable.

In the Queue
, with many consumers, only the first consumer receives the message.
Generally, the Queue
delivery the messages using a Round Robin pattern.
The Round Robin pattern is a way to distribute the messages equally, the broker sends the first message to consumer A, then sends the second message to consumer B, then sends to consumer C. After sending to all consumers, the broker sends the next message to consumer A again, and so on.
In the Topic
all subscribers listening it will receive the messages.
If one of the subscribers in the Topic
is offline and the others subscribers receive the message, the offline subscriber will lose that message.
And If all subscribers are offline, the message will be lost.

In Topic
if you configure a subscriber as durable then if it goes down, the broker waits the subscriber come back online:
Scenario where Non-Durable Subscriber offline lost messages

Scenario where Durable Subscriber offline doesn't lose messages

In other hand, if the consumer in the Queue
is offline, the Broker will wait the consumer come back (Obviously if the queue isn't a competing consumers).
In summary, when the Broker receives a new message, it looks for one of the consumers listening the queue, get the reference of one of them, and send the message. When the Broker receives an acknowledgment (confirmation) from the consumer that the message was received with success, the Broker deletes Queue
's message.
When is a Topic
, The Broker consults all subscribers currently listening it, sends the message to everyone, and waits for their return (acknowledge), when all subscribers send an ok, it deletes the message.
Grouping Messages in a Queue
In a queue with competing consumers, or in a cluster of brokers, you can provide a way to identify a set of related messages.
Using group id you can guarantee the order in which messages are processed. e.g. you don’t want to process the update to an order until an insert has been done.
The messages could be related by anything - a customer order number, for example. Basically a JMS broker provides a guarantee that any messages that belong to a specific group will always be consumed by a common consumer.