Example usage for javax.jms Session createObjectMessage

List of usage examples for javax.jms Session createObjectMessage

Introduction

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

Prototype


ObjectMessage createObjectMessage(Serializable object) throws JMSException;

Source Link

Document

Creates an initialized ObjectMessage object.

Usage

From source file:com.alliander.osgp.adapter.protocol.oslp.elster.infra.messaging.OsgpRequestMessageSender.java

public void send(final RequestMessage requestMessage, final String messageType) {
    LOGGER.info("Sending request message to OSGP.");

    this.osgpRequestsJmsTemplate.send(new MessageCreator() {

        @Override//  w w  w .  jav a  2 s .  c om
        public Message createMessage(final Session session) throws JMSException {
            final ObjectMessage objectMessage = session.createObjectMessage(requestMessage);
            objectMessage.setJMSType(messageType);
            objectMessage.setStringProperty(Constants.ORGANISATION_IDENTIFICATION,
                    requestMessage.getOrganisationIdentification());
            objectMessage.setStringProperty(Constants.DEVICE_IDENTIFICATION,
                    requestMessage.getDeviceIdentification());

            return objectMessage;
        }

    });
}

From source file:com.example.BookListener.java

/**
 * Scenario for "should generate tests triggered by a message": client side: if sends
 * a message to input.messageFrom then message will be sent to output.messageFrom
 * server side: will send a message to input, verify the message contents and await
 * upon receiving message on the output messageFrom
 *//*from  w ww  .  j  a  va  2s .co  m*/
@JmsListener(destination = "input")
public void returnBook(String messageAsString) throws Exception {
    final BookReturned bookReturned = this.objectMapper.readerFor(BookReturned.class)
            .readValue(messageAsString);
    log.info("Returning book [$bookReturned]");
    MessageCreator messageCreator = new MessageCreator() {
        @Override
        public Message createMessage(Session session) throws JMSException {
            Message message = session.createObjectMessage(bookReturned);
            message.setStringProperty("BOOK-NAME", bookReturned.bookName);
            return message;
        }
    };
    this.jmsTemplate.send("output", messageCreator);
}

From source file:org.osgp.adapter.protocol.dlms.infra.messaging.OsgpRequestMessageSender.java

public void send(final RequestMessage requestMessage, final String messageType) {
    LOGGER.info("Sending request message to OSGP.");

    this.osgpRequestsJmsTemplate.send(new MessageCreator() {

        @Override/*from w  ww . ja va  2s.  c  om*/
        public Message createMessage(final Session session) throws JMSException {
            final ObjectMessage objectMessage = session.createObjectMessage(requestMessage);
            objectMessage.setJMSCorrelationID(requestMessage.getCorrelationUid());
            objectMessage.setJMSType(messageType);
            objectMessage.setStringProperty(Constants.ORGANISATION_IDENTIFICATION,
                    requestMessage.getOrganisationIdentification());
            objectMessage.setStringProperty(Constants.DEVICE_IDENTIFICATION,
                    requestMessage.getDeviceIdentification());

            return objectMessage;
        }

    });
}

From source file:pl.edu.amu.lasuch.model.ProductConverter.java

@Override
public Message toMessage(Object o, Session sn) throws JMSException, MessageConversionException {
    Product product = (Product) o;// ww  w  .ja va  2s .  co m
    ObjectMessage message = sn.createObjectMessage(product);
    return message;
}

From source file:com.alliander.osgp.adapter.protocol.oslp.elster.infra.messaging.SigningServerRequestMessageSender.java

public void send(final RequestMessage requestMessage, final String messageType) {
    LOGGER.info("Sending request message to signing server, with reply-to-queue: {}.",
            this.replyToQueue.toString());

    this.signingServerRequestsJmsTemplate.send(new MessageCreator() {

        @Override//from w  w  w . j a va 2 s  .  co m
        public Message createMessage(final Session session) throws JMSException {
            final ObjectMessage objectMessage = session.createObjectMessage(requestMessage);
            objectMessage.setJMSType(messageType);
            objectMessage.setJMSReplyTo(SigningServerRequestMessageSender.this.replyToQueue);
            objectMessage.setJMSCorrelationID(requestMessage.getCorrelationUid());
            objectMessage.setStringProperty(Constants.ORGANISATION_IDENTIFICATION,
                    requestMessage.getOrganisationIdentification());
            objectMessage.setStringProperty(Constants.DEVICE_IDENTIFICATION,
                    requestMessage.getDeviceIdentification());

            return objectMessage;
        }

    });
}

From source file:com.alliander.osgp.signing.server.infra.messaging.SigningServerResponseMessageSender.java

private void sendMessage(final ResponseMessage responseMessage, final String messageType,
        final Destination replyToQueue) {
    this.responsesJmsTemplate.send(replyToQueue, new MessageCreator() {
        @Override//from  w w w  .  j  a  va2 s . c  o  m
        public Message createMessage(final Session session) throws JMSException {
            final ObjectMessage objectMessage = session.createObjectMessage(responseMessage);
            objectMessage.setJMSCorrelationID(responseMessage.getCorrelationUid());
            objectMessage.setJMSType(messageType);
            objectMessage.setStringProperty(Constants.ORGANISATION_IDENTIFICATION,
                    responseMessage.getOrganisationIdentification());
            objectMessage.setStringProperty(Constants.DEVICE_IDENTIFICATION,
                    responseMessage.getDeviceIdentification());
            if (responseMessage.getOsgpException() != null) {
                objectMessage.setStringProperty(Constants.DESCRIPTION,
                        responseMessage.getOsgpException().getMessage());
            }
            return objectMessage;
        }
    });
}

From source file:org.toobsframework.jms.doitref.JmsDoItRefSender.java

public void sendMessage(final DoItRefBean doItRefBean) {
    jmsTemplate.send(new MessageCreator() {
        public Message createMessage(Session session) throws JMSException {

            Message objMessage = null;//ww  w  .j a v  a 2s  . c o m
            try {
                objMessage = session.createObjectMessage(doItRefBean);
            } catch (Exception e) {
                log.error("JMS Mail exception " + e.getMessage(), e);
                throw new JMSException(e.getMessage());
            }
            return objMessage;
        }
    });

}

From source file:com.alliander.osgp.adapter.ws.admin.infra.jms.AdminRequestMessageSender.java

/**
 * Method for sending a request message to the admin requests queue
 *
 * @param requestMessage//from w w w. j av  a 2s . co m
 *            The CommonRequestMessage request message to send.
 */
private void sendMessage(final AdminRequestMessage requestMessage) {
    LOGGER.info("Sending request message to admin requests queue");

    this.adminRequestsJmsTemplate.send(new MessageCreator() {

        @Override
        public Message createMessage(final Session session) throws JMSException {
            final ObjectMessage objectMessage = session.createObjectMessage(requestMessage.getRequest());
            objectMessage.setJMSCorrelationID(requestMessage.getCorrelationUid());
            objectMessage.setJMSType(requestMessage.getMessageType().toString());
            objectMessage.setStringProperty(Constants.ORGANISATION_IDENTIFICATION,
                    requestMessage.getOrganisationIdentification());
            objectMessage.setStringProperty(Constants.DEVICE_IDENTIFICATION,
                    requestMessage.getDeviceIdentification());
            return objectMessage;
        }

    });
}

From source file:com.alliander.osgp.adapter.ws.microgrids.infra.jms.MicrogridsRequestMessageSender.java

/**
 * Method for sending a request message to the microgrids requests queue
 *
 * @param requestMessage/*from   w  w w  . ja va2 s.  c o  m*/
 *            The MicrogridsRequestMessage request message to send.
 */
private void sendMessage(final MicrogridsRequestMessage requestMessage) {
    LOGGER.info("Sending message to the microgrids requests queue");

    this.microgridsRequestsJmsTemplate.send(new MessageCreator() {

        @Override
        public Message createMessage(final Session session) throws JMSException {
            final ObjectMessage objectMessage = session.createObjectMessage(requestMessage.getRequest());
            objectMessage.setJMSCorrelationID(requestMessage.getCorrelationUid());
            objectMessage.setJMSType(requestMessage.getMessageType().toString());
            objectMessage.setStringProperty(Constants.ORGANISATION_IDENTIFICATION,
                    requestMessage.getOrganisationIdentification());
            objectMessage.setStringProperty(Constants.DEVICE_IDENTIFICATION,
                    requestMessage.getDeviceIdentification());
            return objectMessage;
        }
    });
}

From source file:ru.org.linux.search.SearchQueueSender.java

public void updateComment(final List<Integer> msgids) {
    jmsTemplate.send(queue, new MessageCreator() {
        @Override//from w ww.  j av a 2 s . c  o m
        public Message createMessage(Session session) throws JMSException {
            return session.createObjectMessage(new UpdateComments(msgids));
        }
    });
}