I've got all my ajax send/receive working, however I need a java program to
be able to send/receive message from the ajax. Why does the ajax not
receive this? Do I need simulate a httppost instead of this?
ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory(BROKER_URL);
//Destination destination = client.getSession();
// 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.createTopic(CHANNEL);
// Create a MessageProducer from the Session to the Topic or
Queue
MessageProducer producer = session.createProducer(destination);
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
// Create a messages
String from = Thread.currentThread().getName();
String text = "<message type='chat' from='" + from + "'>Hello
World Yo!</message>";
//String text = "Hello world! From: " +
Thread.currentThread().getName() + " : " + this.hashCode();
TextMessage message = session.createTextMessage(text);
// Tell the producer to send the message
System.out.println("Sent message: "+ message.hashCode() + " : "
+ Thread.currentThread().getName());
producer.send(message);
// Clean up
session.close();
connection.close();
--
View this message in context:
http://www.nabble.com/Java-sending-message-to-listening-ajax-tf2222685.html#a6158009
Sent from the ActiveMQ - User forum at Nabble.com.