Posted By:
DJALMA_BINA
Posted On:
Thursday, September 21, 2006 04:06 PM
I am building a sample application that uses Spring JMS Template to send a string message to an activeMQ server. Another spring bean receives the string message and displays it on the console. I am using these source codes : // SimpleJmsListener.java import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageListener; import javax.jms.TextMessage; public class SimpleJmsListener implements MessageListener { public void onMessage(Message message) { if (message instanceof TextMessage) { try { System.out.println(((TextMessage) message).getText()); } catch (JMSException ex) { throw new RuntimeException(ex); }
More>>
I am building a sample application that uses Spring JMS Template to send a string message to an activeMQ server.
Another spring bean receives the string message and displays it on the console.
I am using these source codes :
// SimpleJmsListener.java
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
public class SimpleJmsListener implements MessageListener {
public void onMessage(Message message) {
if (message instanceof TextMessage) {
try {
System.out.println(((TextMessage) message).getText());
} catch (JMSException ex) {
throw new RuntimeException(ex);
}
} else {
throw new IllegalArgumentException("Message must be of type TextMessage");
}
}
}
// SimpleJmsSender.java
import javax.jms.*;
import org.springframework.jms.core.*;
public class SimpleJmsSender {
private JmsTemplate jmsTemplate;
private Destination destination;
public void sendMessage() {
jmsTemplate.convertAndSend("Example Message");
}
public JmsTemplate getTemplate() {
return jmsTemplate;
}
public void setTemplate(JmsTemplate jmsTemplate) {
this.jmsTemplate = jmsTemplate;
}
public Destination getDestination() {
return destination;
}
public void setDestination(Destination destination) {
this.destination = destination;
}
}
and the application context file is this :
-
-
-
-
-
-
-
-
-
-
-
-
How it could be my in index.jsp with a message sender form to the JMS server?
Thanks.