activemq中的Virtaultopic使用范例

  • 生产者端代码
package cn.wonhigh.dc.amq.consumer;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;

public class QueueProducerTest {

	public static final String QUEUE_NAME = "cn.wonhigh.dc.test1";

	public static void main(String[] args) throws Exception {
		ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
				ActiveMQConnection.DEFAULT_USER,
				ActiveMQConnection.DEFAULT_PASSWORD,
				"tcp://172.17.210.156:3046");
		Connection connection = connectionFactory.createConnection();
		connection.start();
		Session session = connection.createSession(false,
				Session.AUTO_ACKNOWLEDGE);
		Queue queue = session.createQueue(QUEUE_NAME);
		MessageProducer producer = session.createProducer(queue);
		for (int i = 0; i < 20; i++) {
			TextMessage textMessage = session.createTextMessage("message-->"
					+ i);
			producer.send(textMessage);
		}
	}
}


  • 消费者端代码
package cn.wonhigh.dc.amq.consumer;


import java.util.concurrent.atomic.AtomicInteger;


import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.Queue;
import javax.jms.Session;


import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;


public class VirtualTopicConsumerTest {


	public static final String VIRTUAL_QUEUE_NAME_A = "Consumer.A.VirtualTopic.test";
	public static final String VIRTUAL_QUEUE_NAME_B = "Consumer.B.VirtualTopic.test";


	public static void main(String[] args) throws Exception {
		ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
				ActiveMQConnection.DEFAULT_USER,
				ActiveMQConnection.DEFAULT_PASSWORD,
				"tcp://172.17.210.156:3046");
		Connection connection = connectionFactory.createConnection();
		connection.start();
		Session session = connection.createSession(false,
				Session.AUTO_ACKNOWLEDGE);
		Queue queue = new ActiveMQQueue(VIRTUAL_QUEUE_NAME_A);
		MessageConsumer consumer1 = session.createConsumer(queue);
		MessageConsumer consumer2 = session.createConsumer(queue);
		final AtomicInteger autoIncrease1 = new AtomicInteger(0);
		MessageListener messageListener1 = new MessageListener() {


			@Override
			public void onMessage(Message message) {
				try {
					System.out.println(autoIncrease1.incrementAndGet()
							+ " => receive from " + VIRTUAL_QUEUE_NAME_A + ": "
							+ message);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}


		};
		consumer1.setMessageListener(messageListener1);
		
		final AtomicInteger autoIncrease2 = new AtomicInteger(0);
		MessageListener messageListener2 = new MessageListener() {


			@Override
			public void onMessage(Message message) {
				try {
					System.out.println(autoIncrease2.incrementAndGet()
							+ " => receive from CC-->" + VIRTUAL_QUEUE_NAME_A + ": "
							+ message);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}


		};
		consumer2.setMessageListener(messageListener2);


		MessageConsumer consumer3 = session.createConsumer(session
				.createQueue(VIRTUAL_QUEUE_NAME_B));
		final AtomicInteger autoIncrease3 = new AtomicInteger(0);
		MessageListener messageListener3 = new MessageListener() {


			@Override
			public void onMessage(Message message) {
				try {
					System.out.println(autoIncrease3.incrementAndGet()
							+ " => receive from " + VIRTUAL_QUEUE_NAME_B + ": "
							+ message);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}


		};
		consumer3.setMessageListener(messageListener3);
	}
}


  • 输出结果:
1 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 5, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:1, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584260, arrival = 0, brokerInTime = 1416223422560, brokerOutTime = 1416223422563, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->0}
1 => receive from Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 5, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:1, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584260, arrival = 0, brokerInTime = 1416223422560, brokerOutTime = 1416223422582, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->0}
2 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 6, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:2, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584284, arrival = 0, brokerInTime = 1416223422584, brokerOutTime = 1416223422587, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->1}
1 => receive from CC-->Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 6, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:2, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584284, arrival = 0, brokerInTime = 1416223422584, brokerOutTime = 1416223422592, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->1}
3 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 7, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:3, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584294, arrival = 0, brokerInTime = 1416223422594, brokerOutTime = 1416223422595, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->2}
2 => receive from Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 7, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:3, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584294, arrival = 0, brokerInTime = 1416223422594, brokerOutTime = 1416223422603, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->2}
4 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 8, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:4, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584304, arrival = 0, brokerInTime = 1416223422604, brokerOutTime = 1416223422608, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->3}
2 => receive from CC-->Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 8, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:4, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584304, arrival = 0, brokerInTime = 1416223422604, brokerOutTime = 1416223422638, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->3}
5 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 9, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:5, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584341, arrival = 0, brokerInTime = 1416223422642, brokerOutTime = 1416223422643, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->4}
3 => receive from Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 9, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:5, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584341, arrival = 0, brokerInTime = 1416223422642, brokerOutTime = 1416223422652, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->4}
6 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 10, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:6, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584353, arrival = 0, brokerInTime = 1416223422653, brokerOutTime = 1416223422655, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->5}
3 => receive from CC-->Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 10, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:6, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584353, arrival = 0, brokerInTime = 1416223422653, brokerOutTime = 1416223422662, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->5}
7 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 11, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:7, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584365, arrival = 0, brokerInTime = 1416223422665, brokerOutTime = 1416223422666, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->6}
4 => receive from Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 11, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:7, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584365, arrival = 0, brokerInTime = 1416223422665, brokerOutTime = 1416223422671, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->6}
8 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 12, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:8, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584374, arrival = 0, brokerInTime = 1416223422673, brokerOutTime = 1416223422674, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->7}
4 => receive from CC-->Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 12, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:8, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584374, arrival = 0, brokerInTime = 1416223422673, brokerOutTime = 1416223422682, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->7}
9 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 13, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:9, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584385, arrival = 0, brokerInTime = 1416223422684, brokerOutTime = 1416223422685, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->8}
5 => receive from Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 13, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:9, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584385, arrival = 0, brokerInTime = 1416223422684, brokerOutTime = 1416223422691, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->8}
10 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 14, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:10, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584393, arrival = 0, brokerInTime = 1416223422693, brokerOutTime = 1416223422693, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->9}
5 => receive from CC-->Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 14, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:10, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584393, arrival = 0, brokerInTime = 1416223422693, brokerOutTime = 1416223422698, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->9}
11 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 15, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:11, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584402, arrival = 0, brokerInTime = 1416223422701, brokerOutTime = 1416223422702, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->10}
6 => receive from Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 15, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:11, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584402, arrival = 0, brokerInTime = 1416223422701, brokerOutTime = 1416223422707, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->10}
12 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 16, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:12, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584409, arrival = 0, brokerInTime = 1416223422709, brokerOutTime = 1416223422710, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->11}
6 => receive from CC-->Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 16, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:12, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584409, arrival = 0, brokerInTime = 1416223422709, brokerOutTime = 1416223422714, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->11}
13 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 17, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:13, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584417, arrival = 0, brokerInTime = 1416223422716, brokerOutTime = 1416223422717, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->12}
7 => receive from Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 17, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:13, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584417, arrival = 0, brokerInTime = 1416223422716, brokerOutTime = 1416223422746, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->12}
14 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 18, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:14, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584449, arrival = 0, brokerInTime = 1416223422749, brokerOutTime = 1416223422749, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->13}
7 => receive from CC-->Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 18, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:14, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584449, arrival = 0, brokerInTime = 1416223422749, brokerOutTime = 1416223422758, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->13}
15 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 19, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:15, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584462, arrival = 0, brokerInTime = 1416223422761, brokerOutTime = 1416223422762, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->14}
8 => receive from Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 19, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:15, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584462, arrival = 0, brokerInTime = 1416223422761, brokerOutTime = 1416223422774, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->14}
16 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 20, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:16, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584476, arrival = 0, brokerInTime = 1416223422776, brokerOutTime = 1416223422777, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->15}
8 => receive from CC-->Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 20, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:16, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584476, arrival = 0, brokerInTime = 1416223422776, brokerOutTime = 1416223422786, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->15}
17 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 21, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:17, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584488, arrival = 0, brokerInTime = 1416223422787, brokerOutTime = 1416223422788, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->16}
9 => receive from Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 21, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:17, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584488, arrival = 0, brokerInTime = 1416223422787, brokerOutTime = 1416223422795, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->16}
18 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 22, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:18, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584498, arrival = 0, brokerInTime = 1416223422797, brokerOutTime = 1416223422798, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->17}
9 => receive from CC-->Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 22, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:18, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584498, arrival = 0, brokerInTime = 1416223422797, brokerOutTime = 1416223422806, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->17}
19 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 23, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:19, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584508, arrival = 0, brokerInTime = 1416223422808, brokerOutTime = 1416223422809, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->18}
10 => receive from Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 23, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:19, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584508, arrival = 0, brokerInTime = 1416223422808, brokerOutTime = 1416223422815, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->18}
20 => receive from Consumer.B.VirtualTopic.test: ActiveMQTextMessage {commandId = 24, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:20, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584517, arrival = 0, brokerInTime = 1416223422816, brokerOutTime = 1416223422817, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->19}
10 => receive from CC-->Consumer.A.VirtualTopic.test: ActiveMQTextMessage {commandId = 24, responseRequired = true, messageId = ID:szsknb093-58065-1416223584050-1:1:1:1:20, originalDestination = null, originalTransactionId = null, producerId = ID:szsknb093-58065-1416223584050-1:1:1:1, destination = topic://VirtualTopic.test, transactionId = null, expiration = 0, timestamp = 1416223584517, arrival = 0, brokerInTime = 1416223422816, brokerOutTime = 1416223422822, correlationId = null, replyTo = null, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, droppable = false, text = message-->19}


  • 结论:


你可能感兴趣的:(activemq中的Virtaultopic使用范例)