Broker 10.5 | webMethods Broker Documentation | webMethods Broker Messaging Programmer's Guide | Coding Messaging Client Applications | A Basic JMS Sender-Receiver Client | Implementing Message Sending and Reception
Implementing Message Sending and Reception
The following lines of code from the sender application show how to define and send a simple text message.

public void sendAMessage(String messageText)
TextMessage msg = session.createTextMessage();
The following code block from the receiver application shows an implementation for receiving a simple text message:

Message msg = receiver.receive();
if (msg instanceof TextMessage) {
System.out.println("Received message: " +
((TextMessage) msg).getText());
} else {
System.out.println("Received message: " + msg.toString());
The receive() method in this sample application receives one message at a time (that is, a single message each time it is called). In a production application, you would typically call receive() from within a loop so it is able to receive messages continuously.