Hi,

I think your problem is in the code writing data to the file. ActiveMQ
encodes text as UTF-8, so you need to use something like that when writing
them to the file. See

http://www.thedundua.com/david/2011/12/29/java-filewriter-and-utf-8/

for more info.

Regards
--
Dejan Bosanac
----------------------
Red Hat, Inc.
FuseSource is now part of Red Hat
[email protected]
Twitter: @dejanb
Blog: http://sensatic.net
ActiveMQ in Action: http://www.manning.com/snyder/


On Tue, Nov 5, 2013 at 11:50 PM, belaie <[email protected]> wrote:

> Hello
>
> I'm reading a que from ActiveMQ using ActiveMQ java client.  I'm have
> problem reading norwegian characters such as Å,Æ, Ø from message body in
> the
> que,    anyone can help?
>
> Here is my code in java:
>
>
>
> ActiveMQConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory(this.getHostNameConnectionString());
>
>             // Create a Connection
>             Connection connection = connectionFactory.createConnection();
>             connection.start();
>
>             // Create a Session
>             Session session = connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE);
>
>             // Create the destination (Topic or Queue)
>             Destination destination =
> session.createQueue(this.getQueName());
>
>             // Create a MessageConsumer from the Session to the Topic or
> Queue
>             MessageConsumer consumer = session.createConsumer(destination);
>
>
>             // Wait for a message 1 second, timeunut is in miliseconds
>             Message message = consumer.receive(1000);
>
>             if (message instanceof TextMessage) {
>
>                 File filetoWrite = new File(fileName);
>
>                 if(filetoWrite.exists()){
>                    filetoWrite.delete();
>                 }
>
>                 TextMessage textMessage = (TextMessage) message;
>
>
>                 FileWriter fw = new
> FileWriter(filetoWrite.getAbsoluteFile(),true);
>                 BufferedWriter bw = new BufferedWriter(fw);
>                 bw.write(textMessage.getText());
>                 bw.close();
>
>                 messagePayLoad = "done#";
>
>             } else {
>                 messagePayLoad  = "empty";
>             }
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Norwegian-character-ActiveMQ-consumer-problem-tp4673926.html
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>

Reply via email to