activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jobanovi <Josip.Bano...@corvitro.com>
Subject Re: ActiveMQInputStream & Message Acknowledgement
Date Thu, 22 Aug 2013 13:01:35 GMT
Hello!

I have similar issue with ActiveMQ 5.8.0.
I am sending a WAV file over AMQ using IOStreams. I don't have a problem
with transfering the file from the producer side to the consumer side. But
there is a problem on the consumer side with message acknowledgement (I
think) and I can play the file only after I purge the queue via Jconsole
(messages never get dequeued even the acknowledgement is set to AUTO). 
Here is consumer side code:

		final ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(
				this.brokerURI);
		final Connection connection = (ActiveMQConnection) connectionFactory
				.createConnection();
		connection.start();

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

		final String queueName = destinationName;//to add something after '?'
		final Queue destination = session.createQueue(queueName);
		final InputStream amqInputStream = ((ActiveMQConnection) connection)
				.createInputStream(destination);
		
		final AudioInputStream ais = AudioSystem
				.getAudioInputStream(new BufferedInputStream(amqInputStream));
		final File file = new File(
				"D:/josip/workspaces(my)/test_ws/AMQStreaming/src/resources/ante3.wav");
		
		if (file.exists()) {

			file.delete();

			file.createNewFile();
		}
		
		*//HERE the data is written to ante3.wav file and it works, but on this
line of code application stops untill I manually purge the queue via
Jconsole*
		AudioSystem.write(ais, AudioFileFormat.Type.WAVE, file);
		
		amqInputStream.close();
		ais.close();
		
		///this part of code plays the file/
		final Line.Info linfo = new Line.Info(Clip.class);
		final Line line = AudioSystem.getLine(linfo);
		final Clip clip = (Clip) line;
		clip.addLineListener(this);
		final AudioInputStream fileAis = AudioSystem.getAudioInputStream(file);
		clip.open(fileAis);
		clip.start();

		fileAis.close();



--
View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQInputStream-Message-Acknowledgement-tp2348643p4670577.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message