activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Viali.Lee" <Viali....@Hotmail.COM>
Subject about Producer crashed when sending jms stream...
Date Fri, 10 Aug 2007 08:54:39 GMT

I tried to send a file to ActiveMQ through 
http://activemq.apache.org/jms-streams.html Jms Streams . And I stop the
sending process when the data is still being sent..however, the messages
which have been sent are still in the destination queue. What I want to know
is how to delete those messages when the producer crashed ??

package JMSStreams;
import java.io.*;
import java.util.Date;
import javax.jms.*;
import org.apache.activemq.*;

public class JmsStreamProducer 
{
	public static void main(String[] args) throws Exception 
	{
		ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory("tcp://localhost:61616");
		ActiveMQConnection connection = (ActiveMQConnection)
connectionFactory.createConnection();
		connection.start();

		ActiveMQSession session = (ActiveMQSession)
connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

		Destination destination = session.createQueue("message.larger.input");
		OutputStream out = connection.createOutputStream(destination);
		FileInputStream fileread = new FileInputStream(new
File("D://big-file.xml"));
		byte[] b = new byte[1024];
		int read = 0;
		boolean send = true;

		while ((read = fileread.read(b)) != -1) {
			if (send) {
				System.out.println("Begin To Send Large Message At "
						+ (new Date()));
				send = false;
			}
			out.write(b, 0, read);
		}
		fileread.close();
		out.close();

		session.close();
		connection.close();
		System.out.println("Finish Sending Large Message At " + (new Date()));
	}
}
-- 
View this message in context: http://www.nabble.com/about-Producer-crashed-when-sending-jms-stream...-tf4247394s2354.html#a12087511
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Mime
View raw message