我是新毕业的大学生刚进公司就给发了个活在学校没学过所以请教下各位大侠这两个一个是启动TOMCAT的 一个是产生消息的
我想知道,消息发送到哪里了,我怎么才才能让接收到的消息在控制台中打印出来
import org.apache.activemq.broker.BrokerService;/**
 * This example demonstrates how to run an embedded broker inside your Java code
 * 
 * @version $Revision: 565003 $
 */
public final class EmbeddedBroker {    private EmbeddedBroker() {
    }    public static void main(String[] args) throws Exception {
        BrokerService broker = new BrokerService();
        broker.setUseJmx(true);
        broker.addConnector("tcp://localhost:61616");
        broker.start();        // now lets wait forever to avoid the JVM terminating immediately
        Object lock = new Object();
        synchronized (lock) {
            lock.wait();
        }
    }
}import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.MapMessage;import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.util.IndentPrinter;import sun.misc.BASE64Decoder;/**
 * A simple tool for publishing messages
 * 
 * @version $Revision: 1.2 $
 */
public class ProducerTest {    private Destination destination;
    private int messageCount;
    private boolean verbose = true;
    private int messageSize = 255;
    private long timeToLive;
    private String user = ActiveMQConnection.DEFAULT_USER;
    private String password = ActiveMQConnection.DEFAULT_PASSWORD;
    private String url = "tcp://10.1.80.6:61616";
    private String subject = "IMS.RawEvent";   //IMS.RawPerf   IMS.StandardAlert
    private boolean topic = false;
    private boolean transacted;
    private boolean persistent;    public static void main(String[] args) {
        ProducerTest producerTest = new ProducerTest();
        String[] unknown = CommandLineSupport.setOptions(producerTest, args);
        if (unknown.length > 0) {
            System.out.println("Unknown options: " + Arrays.toString(unknown));
            System.exit(-1);
        }
        producerTest.run();
    }    public void run() {
        Connection connection = null;
        try {
            System.out.println("Connecting to URL: " + url);            // Create the connection.
            ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(user, password, url);
            connection = connectionFactory.createConnection();
            connection.start();            // Create the session
            Session session = connection.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
            if (topic) {
                destination = session.createTopic(subject);
            } else {
                destination = session.createQueue(subject);
            }            // Create the producer.
            MessageProducer producer = session.createProducer(destination);
            if (persistent) {
                producer.setDeliveryMode(DeliveryMode.PERSISTENT);
            } else {
                producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
            }
            if (timeToLive != 0) {
                producer.setTimeToLive(timeToLive);
            }            // Start sending messages
            sendLoop(session, producer);            System.out.println("Done.");            // Use the ActiveMQConnection interface to dump the connection
            // stats.
            ActiveMQConnection c = (ActiveMQConnection)connection;
            c.getConnectionStats().dump(new IndentPrinter());        } catch (Exception e) {
            System.out.println("Caught: " + e);
            e.printStackTrace();
        } finally {
            try {
                connection.close();
            } catch (Throwable ignore) {
            }
        }
    }    protected void sendLoop(Session session, MessageProducer producer) throws Exception {        for (int i = 0; i < messageCount || messageCount == 0; i++) {            long start = Calendar.getInstance().getTimeInMillis();
            String strTIME = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
            
            MapMessage messagep = session.createMapMessage(); 
            
/**********XXXXX是监控指标的英文名称,YYYYY是指标的采集值************/
            //Perf
            messagep.setBytes("CLASSNAME", "BusinessSystem".getBytes());
            messagep.setBytes("SCENE", "epri".getBytes());/**sgjj为门户系统厂商的缩写*/
            messagep.setBytes("TIME", strTIME.getBytes());
            messagep.setBytes("MAINDATA", "Name=企业门户".getBytes());
            messagep.setBytes("XXXXX", "YYYYY".getBytes());
            messagep.clearBody();
            messagep.clearProperties();
                        
            System.out.println("Send Message Number>> " + (i+1));            producer.send(messagep);            if (transacted) {
                session.commit();
            }        }    }    private String createMessageText(int index) {
        StringBuffer buffer = new StringBuffer(messageSize);
        buffer.append("Message: " + index + " sent at: " + new Date());
        if (buffer.length() > messageSize) {
            return buffer.substring(0, messageSize);
        }
        for (int i = buffer.length(); i < messageSize; i++) {
            buffer.append(' ');
        }
        return buffer.toString();
    }    public void setPersistent(boolean durable) {
        this.persistent = durable;
    }    public void setMessageCount(int messageCount) {
        this.messageCount = messageCount;
    }    public void setMessageSize(int messageSize) {
        this.messageSize = messageSize;
    }    public void setPassword(String pwd) {
        this.password = pwd;
    }
    public void setSubject(String subject) {
        this.subject = subject;
    }    public void setTimeToLive(long timeToLive) {
        this.timeToLive = timeToLive;
    }    public void setTopic(boolean topic) {
        this.topic = topic;
    }    public void setQueue(boolean queue) {
        this.topic = !queue;
    }    public void setTransacted(boolean transacted) {
        this.transacted = transacted;
    }    public void setUrl(String url) {
        this.url = url;
    }    public void setUser(String user) {
        this.user = user;
    }    public void setVerbose(boolean verbose) {
        this.verbose = verbose;
    }
}