Example usage for javax.jms Session createTextMessage

List of usage examples for javax.jms Session createTextMessage

Introduction

In this page you can find the example usage for javax.jms Session createTextMessage.

Prototype


TextMessage createTextMessage(String text) throws JMSException;

Source Link

Document

Creates an initialized TextMessage object.

Usage

From source file:org.exist.monitoring.jms.JMSSender.java

public void send(final String object) {
    System.out.println(object);/* w w  w .ja va2  s.c om*/
    this.jmsTemplate.send(this.destination, new MessageCreator() {
        public Message createMessage(Session session) throws JMSException {
            return session.createTextMessage(object);
        }
    });
}

From source file:hu.vanio.jms.spring3.ibmmq.JmsQueueSender.java

public void simpleSend(final String message) {
    this.jmsTemplate.send(myDestination, new MessageCreator() {
        public Message createMessage(Session session) throws JMSException {
            return session.createTextMessage(message);
        }// w ww  .  java  2s  .  c  o  m
    });
}

From source file:org.vbossica.azurebox.servicebus.amqp.ClientConnectionIT.java

@Test
public void send_and_receive() {
    template.send(destinationName, new MessageCreator() {
        @Override//w  w  w. java 2s .  c o  m
        public Message createMessage(Session session) throws JMSException {
            return session.createTextMessage("hello world");
        }
    });
    Message msg = template.receive(destinationName);
    System.out.println(msg.toString());
}

From source file:org.vbossica.azurebox.servicebus.amqp.ClientConnectionIT.java

@Test
public void send_and_receive_with_destination() {
    template.send(destination, new MessageCreator() {
        @Override//  w ww .ja  v  a  2 s  .c o  m
        public Message createMessage(Session session) throws JMSException {
            return session.createTextMessage("hello world (2)");
        }
    });
    Message msg = template.receive(destination);
    System.out.println(msg.toString());
}

From source file:org.vbossica.azurebox.servicebus.amqp_1_0.ClientConnectionIT.java

@Test
public void send_and_receive() throws Exception {
    template.send(destinationName, new MessageCreator() {
        @Override/*from  ww  w  . j a v  a 2s. c om*/
        public Message createMessage(Session session) throws JMSException {
            return session.createTextMessage("hello world");
        }
    });
    TextMessage msg = (TextMessage) template.receive(destinationName);
    System.out.println(msg.getText());
}

From source file:org.vbossica.azurebox.servicebus.amqp_1_0.ClientConnectionIT.java

@Test
public void send_and_receive_with_destination() throws Exception {
    template.send(destination, new MessageCreator() {
        @Override//from ww w  . j  a  va2 s. com
        public Message createMessage(Session session) throws JMSException {
            return session.createTextMessage("hello world (2)");
        }
    });
    TextMessage msg = (TextMessage) template.receive(destination);
    System.out.println(msg.getText());
}

From source file:com.appdynamicspilot.jms.MessageProducer.java

public void sendTextMessageWithOrderId() {
    getJmsTemplate().send(new MessageCreator() {
        public Message createMessage(Session session) throws JMSException {
            Message msg = session.createTextMessage("You Sent a order message");
            msg.setStringProperty("testString", "test123");

            /*MapMessage msg = session.createMapMessage();
            msg.setString(COMMAND, CMD_MAIL);
            msg.setString(EMAIL_ID, emailId);
            msg.setString(ORDER_ID, orderId);
            msg.setIntProperty("testproperty", 21);
            */// www. j  av  a 2 s  .co  m
            return msg;
        }
    });
}

From source file:com.yosanai.java.jms.ProducerTest.java

@Test
public void checkLocal() {

    for (int index = 0; index < 10; index++) {
        final int currentCount = index;
        jmsTemplate.send(queue, new MessageCreator() {
            @Override/*  w w w  .  j av  a 2s .  com*/
            public Message createMessage(Session session) throws JMSException {
                return session.createTextMessage("A Message " + currentCount + " At " + new Date().toString());
            }
        });
        try {
            Thread.sleep(1000l);
        } catch (InterruptedException e) {
        }
    }
    jmsTemplate.send(queue, new MessageCreator() {
        @Override
        public Message createMessage(Session session) throws JMSException {
            return session.createTextMessage("done");
        }
    });
}

From source file:com.estafeta.flujos.JmsMessageSender.java

/**
 * Send text message to a specified destination
 * @param text//  w  w  w. ja v  a 2 s.  com
 */
public void send(final Destination dest, final String text) {

    this.jmsTemplate.send(dest, new MessageCreator() {
        @Override
        public Message createMessage(Session session) throws JMSException {
            Message message = session.createTextMessage(text);
            return message;
        }
    });
}

From source file:com.estafeta.flujos.JmsMessageSender.java

/**
 * send text to default destination/*ww w .j  av  a 2 s  .c  om*/
 * @param text
 */
public void send(final String text) {

    this.jmsTemplate.send(new MessageCreator() {
        @Override
        public Message createMessage(Session session) throws JMSException {
            Message message = session.createTextMessage(text);
            message.setJMSType("xml");
            //set ReplyTo header of Message, pretty much like the concept of email.
            //message.setJMSReplyTo(new ActiveMQQueue("Recv2Send"));
            return message;
        }
    });
}