Hello! 
 
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). I am
using ActiveMQ 5.8.0.
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/ActiveMQ-streaming-Message-Acknowledgement-tp4670607.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to