- TextMessage
- ListMessage
- MapMesage
- StreamMessage
1、MqConsumerStream.java
package com.neohope.qpid.test; import org.apache.qpid.client.AMQAnyDestination; import org.apache.qpid.client.AMQConnection; import javax.jms.*; public class MqConsumerStream { public static void main(String[] args) throws Exception { Connection connection = new AMQConnection("amqp://guest:guest@test/?brokerlist='tcp://localhost:5672'"); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination queue = new AMQAnyDestination("ADDR:message_queue; {create: always}"); MessageConsumer consumer = session.createConsumer(queue); System.out.println("Receiving as StreamMessage"); StreamMessage m = (StreamMessage) consumer.receive(); System.out.println(m); System.out.println("=========================================="); System.out.println("Printing stream contents:"); try { while (true) System.out.println(m.readObject()); } catch (MessageEOFException e) { // DONE } } }