Java Reference
In-Depth Information
import javax.jms.JMSConnectionFactory;
import javax.jms.JMSContext;
import javax.jms.Queue;
public class JmsMessageController {
private JmsMessageModel jmsMessageModel;
@Resource(mappedName = "jms/myQueue")
private Queue myQueue;
private JMSContext context;
public String sendMsg() {
return "confirmation";
private void sendJMSMessageToMyQueue(String messageData) {
context.createProducer().send(myQueue, messageData);
As we can see, all we had to do was to inject an instance of the JmsMessageModel
class we developed earlier and add a simple method that will invoke the generated
sendJMSMessageToMyQueue() method, passing the message text as a parameter.
Next, we need to modify the generated index.xhtml file to add a form binding the
msgText variable of JmsMessageModel to a text field and a command button that
invokes the sendMsg() method when it is clicked. The code is as follows:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns=""
<title>Send JMS Message</title>
Search WWH ::

Custom Search