Example usage for javax.jms MapMessage setString

List of usage examples for javax.jms MapMessage setString

Introduction

In this page you can find the example usage for javax.jms MapMessage setString.

Prototype


void setString(String name, String value) throws JMSException;

Source Link

Document

Sets a String value with the specified name into the Map.

Usage

From source file:com.apress.prospringintegration.transform.IntegrationTransformer.java

public static void main(String[] args) {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            "classpath:integration-transformer.xml");

    JmsTemplate jmsTemplate = context.getBean("jmsTemplate", JmsTemplate.class);

    jmsTemplate.send(new MessageCreator() {

        @Override//  ww  w.j a  v  a2s.  com
        public javax.jms.Message createMessage(Session session) throws JMSException {
            MapMessage message = session.createMapMessage();
            message.setString("firstName", "John");
            message.setString("lastName", "Smith");
            message.setString("address", "100 State Street");
            message.setString("city", "Los Angeles");
            message.setString("state", "CA");
            message.setString("zip", "90064");
            System.out.println("Sending message: " + message);
            return message;
        }
    });

    PollableChannel output = (PollableChannel) context.getBean("output");
    Message<?> reply = output.receive();
    System.out.println("received: " + reply.getPayload());
}

From source file:service.emailer.Emailer.java

/**
 * Send email with parameters to emailQueue
 * @param area// ww w  .j  a  v  a2s.c  o  m
 * @param email
 */
public static void sendEmail(String area, List<String> email) {
    try {
        //JMS QUEUE SEND
        final ConnectionFactory connectionFactory = lookup(ConnectionFactory.class, JNDI_CONNECTION_FACTORY);
        final Queue queue = lookup(Queue.class, JNDI_QUEUE);

        Connection connection = connectionFactory.createConnection();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        MessageProducer producer = session.createProducer(queue);
        MapMessage message = session.createMapMessage();
        message.setString("type", "warnFile");
        message.setString("area", area);
        ObjectMapper mapper = new ObjectMapper();
        String json = mapper.writeValueAsString(email);
        message.setString("emailReceivers", json);
        producer.send(message);
    } catch (JMSException ex) {
        Logger.getLogger(Emailer.class.getName()).log(Level.SEVERE, null, ex);
    } catch (JsonProcessingException ex) {
        Logger.getLogger(Emailer.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.santika.hendi.activeMQ.MessageProducerBean.java

public void sendMessage(final MessageObject messageObj) {
    jmsTemplate.send(destination, new MessageCreator() {
        public Message createMessage(Session session) throws JMSException {
            MapMessage message = session.createMapMessage();
            message.setString("mailId", messageObj.getMailId());
            message.setString("message", messageObj.getMessage());
            return message;
        }//ww w . j  a v a2  s  . c  o m
    }); //send method close here
}

From source file:edu.psu.citeseerx.myciteseer.messaging.SubmissionSender.java

public Message createMessage(Session session) throws JMSException {
    MapMessage msg = session.createMapMessage();
    msg.setString("JID", JID);
    msg.setString("URL", URL);
    msg.setString("DESC", DESC);
    return msg;/*from   w  w  w.  j a va  2 s  .  c  o  m*/
}

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

/**
 * Send message to for email to user by given orderid
 *///from w  w w .ja  va  2  s. c  om
public void sendMessageWithOrderId(final String orderId, final String emailId) {
    getJmsTemplate().send(new MessageCreator() {
        public Message createMessage(Session session) throws JMSException {
            MapMessage msg = session.createMapMessage();
            msg.setString(COMMAND, CMD_MAIL);
            msg.setString(EMAIL_ID, emailId);
            msg.setString(ORDER_ID, orderId);
            msg.setIntProperty("testproperty", 21);
            return msg;
        }
    });
}

From source file:com.xyxy.platform.examples.showcase.demos.jms.advanced.AdvancedNotifyMessageProducer.java

/**
 * jmsTemplatesend/MessageCreator()??Map?Message?.
 *//*w  w w.  ja  va2  s .  c o m*/
private void sendMessage(final User user, Destination destination) {
    jmsTemplate.send(destination, new MessageCreator() {
        @Override
        public Message createMessage(Session session) throws JMSException {

            MapMessage message = session.createMapMessage();
            message.setString("userName", user.getName());
            message.setString("email", user.getEmail());

            message.setStringProperty("objectType", "user");

            return message;
        }
    });
}

From source file:com.it.j2ee.modules.jms.advanced.AdvancedNotifyMessageProducer.java

/**
 * jmsTemplatesend/MessageCreator()??Map?Message?.
 *///  w  w w  .  j a  va  2  s .  c  o  m
private void sendMessage(final User user, Destination destination) {
    jmsTemplate.send(destination, new MessageCreator() {

        public Message createMessage(Session session) throws JMSException {

            MapMessage message = session.createMapMessage();
            message.setString("userName", user.getName());
            message.setString("email", user.getEmail());

            message.setStringProperty("objectType", "user");

            return message;
        }
    });
}

From source file:Retailer.java

public void run() {
    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(user, password, url);
    try {/*from   w  w  w  .j  a va2 s  . com*/
        Connection connection = connectionFactory.createConnection();

        // The Retailer's session is non-trasacted.
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination vendorOrderQueue = session.createQueue("VendorOrderQueue");
        TemporaryQueue retailerConfirmQueue = session.createTemporaryQueue();

        MessageProducer producer = session.createProducer(vendorOrderQueue);
        MessageConsumer replyConsumer = session.createConsumer(retailerConfirmQueue);

        connection.start();

        for (int i = 0; i < 5; i++) {
            MapMessage message = session.createMapMessage();
            message.setString("Item", "Computer(s)");
            int quantity = (int) (Math.random() * 4) + 1;
            message.setInt("Quantity", quantity);
            message.setJMSReplyTo(retailerConfirmQueue);
            producer.send(message);
            System.out.println("Retailer: Ordered " + quantity + " computers.");

            MapMessage reply = (MapMessage) replyConsumer.receive();
            if (reply.getBoolean("OrderAccepted")) {
                System.out.println("Retailer: Order Filled");
            } else {
                System.out.println("Retailer: Order Not Filled");
            }
        }

        // Send a non-MapMessage to signal the end
        producer.send(session.createMessage());

        replyConsumer.close();
        connection.close();

    } catch (JMSException e) {
        e.printStackTrace();
    }
}

From source file:org.atmars.service.impls.Jmail.java

public String sendEmail(String email, String nickname, Date date) throws UnsupportedEncodingException {

    String plain = email + nickname + date.getTime();
    BasicPasswordEncryptor passwordEncryptor = new BasicPasswordEncryptor();
    String encrypted = passwordEncryptor.encryptPassword(plain);
    String urlEncodedString = java.net.URLEncoder.encode(encrypted, "UTF-8");
    final String to = email;
    final String subject = "AtMars Microblog New User Register Comfirmation Email";
    final String content = "<div style='width:713px; background-color:#A1E0E9; padding-top:30px; padding-bottom:30px; margin: 0 auto;'><img src='"
            + serverURL + logo_img + "' width='160' /><img src='" + serverURL + poster_img
            + "' width='100%' /><div style='background-color:#FFFFFF; border-radius:3px; box-shadow:0 1px 3px rgba(0,0,0,0.25); border:1px solid #CCC; padding:20px 20px 20px 20px; margin-left:30px; margin-right:30px; margin-top:30px;'><p><b>Welcome to AtMars MicroBlog</b></p><p>Thank you for registering AtMars MicroBlog.</p><p>To comfirm the email address you provided during registration. please click the following link in 24 hours:</p><p><a href='"
            + serverURL + "checkEmail?email=" + email + "&ticket=" + urlEncodedString + "'>" + serverURL
            + "checkEmail?email=" + email + "&ticket=" + urlEncodedString
            + "</a></p><p>If this link does not work, copy and paste the link into your browser.</p></div></div>";

    jmsTemplate.send(destination, new MessageCreator() {

        @Override//from  w w  w. j av  a  2s . co m
        public Message createMessage(Session session) throws JMSException {
            MapMessage message = session.createMapMessage();

            message.setString("To", to);
            message.setString("Subject", subject);
            message.setString("Content", content);

            return message;
        }

    });
    return encrypted;
}

From source file:org.openmrs.module.emrapi.event.PatientViewedEventListenerTest.java

private MapMessage createMessage(Patient patient, User user) throws Exception {
    MapMessage message = new ActiveMQMapMessage();
    message.setString(EmrApiConstants.EVENT_KEY_PATIENT_UUID, patient.getUuid());
    message.setString(EmrApiConstants.EVENT_KEY_USER_UUID, user.getUuid());

    return message;
}