Example usage for com.liferay.portal.kernel.messaging MessageBus sendMessage

List of usage examples for com.liferay.portal.kernel.messaging MessageBus sendMessage

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.messaging MessageBus sendMessage.

Prototype

public void sendMessage(String destinationName, Message message);

Source Link

Usage

From source file:com.liferay.mobile.camel.LiferayProducer.java

License:Open Source License

public void process(Exchange exchange) throws Exception {
    Object payload = exchange.getIn().getBody();

    if (_log.isDebugEnabled()) {
        _log.debug("LiferayProducer.process " + payload);
    }/*  w w w . j  a  va  2  s .co  m*/

    LiferayEndpoint endpoint = getEndpoint();
    MessageBus messageBus = endpoint.getMessageBus();
    String destinationName = endpoint.getDestinationName();

    Message message = new Message();
    message.setPayload(payload);

    String responseId = (String) exchange.getIn().getHeader("liferay-ResponseId");
    if (responseId != null) {
        message.setResponseId(responseId);
    }

    messageBus.sendMessage(destinationName, message);
}

From source file:se.vgregion.messagebus.MessageBusProducer.java

License:Open Source License

/**
 * Process the <code>Exchange</code>.
 *
 * @param exchange exchange//from w ww .ja  v a 2s .c  o m
 * @throws Exception Exception
 */
public void process(Exchange exchange) throws Exception {
    se.vgregion.messagebus.MessageBusEndpoint endpoint = (MessageBusEndpoint) getEndpoint();
    MessageBus messageBus = endpoint.getMessageBus();

    String destination = endpoint.getDestination();

    Message body = exchange.getIn().getBody(Message.class);
    body.setResponseId((String) exchange.getIn().getHeader("responseId"));

    messageBus.sendMessage(destination, body);
}