你的我没看 我前几天刚做了 一个activeMQ 的程序
等会 我给你发!
等会 我给你发!
解决方案 »
- 求推荐一本大数据量处理的书
- struts 跳转,希望地址栏的后缀名是.jsp而不是.do之类的,怎么办?
- apache 和 tomcat整合问题(急等,一定加分!!!)
- Java中集合类和数组的效率等多个问题
- Hibernate映射问题一个字段又是主键又是外键来帮忙 100分在线等
- 最近要开发图像矢量化课题(java开发),有谁能推荐关于这方面的算法和java书? 或者是参考资料,万事开头难,万分感谢~
- webservices服务器端怎样部署多个文件(服务)啊
- 看《精通JBoss-EJB与Web Services开发精解》,问两个Web Services基本问题,谢谢!
- 怎么样在Jtable表格作任意一个格里加JButton按扭?求救
- 谁有jbuilder8的serial number 和 key ,谢谢!!!!
- quartz-jobs.xml的配置问题
- 用java和OCI来连接oracle10g
Connection connection = null;
try {
System.out.println("Connecting to URL: " + url);
System.out.println("Publishing a Message with size " + messageSize
+ " to " + (topic ? "topic" : "queue" + ": " + subject));
System.out.println("Using "
+ (persistent ? "persistent" : "non-persistent"
+ " messages"));
System.out.println("Sleeping between publish " + sleepTime + " ms");
if (timeToLive != 0) {
System.out.println("Messages time to live " + timeToLive
+ " ms");
} // 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);
} //QueueSession sessionQ =(QueueSession)connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
//QueueReceiver receiver=sessionQ.createReceiver((Queue) destination);
// Create the producer.
MessageProducer producer = session.createProducer(destination);
/*
try{
TextMessage tm = (TextMessage) receiver.receive();
System.out.println("receive successful!");
String messageContent = tm.getText();
System.out.println("The content of the receiving message is:" + messageContent); }catch(Exception ex){
ex.getStackTrace();
ex.getMessage();
}finally{
receiver.close();
}
*/
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) {
}
}
}