Search in sources :

Example 1 with JMSSender

use of org.apache.cxf.transport.jms.util.JMSSender in project cxf by apache.

the class BackChannelConduit method send.

private void send(final Message outMessage, final Object replyObj, ResourceCloser closer) throws JMSException {
    Connection connection;
    if (persistentConnection == null) {
        connection = closer.register(JMSFactory.createConnection(jmsConfig));
    } else {
        connection = this.persistentConnection;
    }
    Session session = closer.register(connection.createSession(false, Session.AUTO_ACKNOWLEDGE));
    JMSMessageHeadersType outProps = (JMSMessageHeadersType) outMessage.get(JMS_SERVER_RESPONSE_HEADERS);
    JMSMessageHeadersType inProps = (JMSMessageHeadersType) inMessage.get(JMS_SERVER_REQUEST_HEADERS);
    initResponseMessageProperties(outProps, inProps);
    // setup the reply message
    final javax.jms.Message request = (javax.jms.Message) inMessage.get(JMS_REQUEST_MESSAGE);
    if (isTimedOut(request)) {
        return;
    }
    Destination replyTo = getReplyToDestination(session, inMessage);
    if (replyTo == null) {
        throw new RuntimeException("No replyTo destination set");
    }
    final String msgType = getMessageType(outMessage, request);
    String correlationId = determineCorrelationID(request);
    javax.jms.Message reply = JMSMessageUtils.asJMSMessage(jmsConfig, outMessage, replyObj, msgType, session, correlationId, JMS_SERVER_RESPONSE_HEADERS);
    JMSSender sender = JMSFactory.createJmsSender(jmsConfig, outProps);
    LOG.log(Level.FINE, "server sending reply: ", reply);
    sender.sendMessage(session, replyTo, reply);
}
Also used : Destination(javax.jms.Destination) TextMessage(javax.jms.TextMessage) Message(org.apache.cxf.message.Message) Connection(javax.jms.Connection) JMSSender(org.apache.cxf.transport.jms.util.JMSSender) Session(javax.jms.Session)

Example 2 with JMSSender

use of org.apache.cxf.transport.jms.util.JMSSender in project cxf by apache.

the class JMSConduit method sendMessage.

private String sendMessage(final Object request, final Message outMessage, Destination replyToDestination, String correlationId, ResourceCloser closer, Session session) throws JMSException {
    JMSMessageHeadersType headers = getOrCreateJmsHeaders(outMessage);
    javax.jms.Message message = JMSMessageUtils.asJMSMessage(jmsConfig, outMessage, request, jmsConfig.getMessageType(), session, correlationId, JMSConstants.JMS_CLIENT_REQUEST_HEADERS);
    if (replyToDestination == null && headers.isSetJMSReplyTo()) {
        String replyTo = headers.getJMSReplyTo();
        replyToDestination = jmsConfig.getReplyDestination(session, replyTo);
    }
    if (replyToDestination != null) {
        message.setJMSReplyTo(replyToDestination);
    }
    JMSSender sender = JMSFactory.createJmsSender(jmsConfig, headers);
    Destination targetDest = jmsConfig.getTargetDestination(session);
    sender.sendMessage(session, targetDest, message);
    String jmsMessageID = message.getJMSMessageID();
    LOG.log(Level.FINE, "client sending request message " + jmsMessageID + " to " + targetDest);
    headers.setJMSMessageID(jmsMessageID);
    return jmsMessageID;
}
Also used : Destination(javax.jms.Destination) JMSSender(org.apache.cxf.transport.jms.util.JMSSender)

Example 3 with JMSSender

use of org.apache.cxf.transport.jms.util.JMSSender in project cxf by apache.

the class JMSFactory method createJmsSender.

/**
 * Create JmsSender from configuration information. Most settings are taken from jmsConfig. The QoS
 * settings in messageProperties override the settings from jmsConfig
 *
 * @param jmsConfig configuration information
 * @param messageProperties context headers override config settings
 * @return
 */
public static JMSSender createJmsSender(JMSConfiguration jmsConfig, JMSMessageHeadersType messageProperties) {
    JMSSender sender = new JMSSender();
    long timeToLive = (messageProperties != null && messageProperties.isSetTimeToLive()) ? messageProperties.getTimeToLive() : jmsConfig.getTimeToLive();
    sender.setTimeToLive(timeToLive);
    int priority = (messageProperties != null && messageProperties.isSetJMSPriority()) ? messageProperties.getJMSPriority() : jmsConfig.getPriority();
    sender.setPriority(priority);
    int deliveryMode = (messageProperties != null && messageProperties.isSetJMSDeliveryMode()) ? messageProperties.getJMSDeliveryMode() : jmsConfig.getDeliveryMode();
    sender.setDeliveryMode(deliveryMode);
    sender.setExplicitQosEnabled(jmsConfig.isExplicitQosEnabled());
    return sender;
}
Also used : JMSSender(org.apache.cxf.transport.jms.util.JMSSender)

Example 4 with JMSSender

use of org.apache.cxf.transport.jms.util.JMSSender in project cxf by apache.

the class SOAPJMSTestSuiteTest method twoWayTestWithCreateMessage.

public void twoWayTestWithCreateMessage(final TestCaseType testcase) throws Exception {
    String address = testcase.getAddress();
    EndpointInfo endpointInfo = new EndpointInfo();
    endpointInfo.setAddress(JMSTestUtil.getFullAddress(address, broker.getBrokerURL()));
    JMSConfiguration jmsConfig = JMSConfigFactory.createFromEndpointInfo(staticBus, endpointInfo, null);
    ResourceCloser closer = new ResourceCloser();
    try {
        Connection connection = closer.register(JMSFactory.createConnection(jmsConfig));
        connection.start();
        Session session = closer.register(connection.createSession(false, Session.AUTO_ACKNOWLEDGE));
        Destination targetDest = jmsConfig.getTargetDestination(session);
        Destination replyToDestination = jmsConfig.getReplyToDestination(session, null);
        JMSSender sender = JMSFactory.createJmsSender(jmsConfig, null);
        Message jmsMessage = JMSTestUtil.buildJMSMessageFromTestCase(testcase, session, replyToDestination);
        sender.sendMessage(session, targetDest, jmsMessage);
        Message replyMessage = JMSUtil.receive(session, replyToDestination, jmsMessage.getJMSMessageID(), 10000, true);
        checkReplyMessage(replyMessage, testcase);
    } catch (JMSException e) {
        throw JMSUtil.convertJmsException(e);
    } finally {
        closer.close();
    }
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Destination(javax.jms.Destination) JMSConfiguration(org.apache.cxf.transport.jms.JMSConfiguration) Message(javax.jms.Message) Connection(javax.jms.Connection) ResourceCloser(org.apache.cxf.transport.jms.util.ResourceCloser) JMSSender(org.apache.cxf.transport.jms.util.JMSSender) JMSException(javax.jms.JMSException) Session(javax.jms.Session)

Aggregations

JMSSender (org.apache.cxf.transport.jms.util.JMSSender)4 Destination (javax.jms.Destination)3 Connection (javax.jms.Connection)2 Session (javax.jms.Session)2 JMSException (javax.jms.JMSException)1 Message (javax.jms.Message)1 TextMessage (javax.jms.TextMessage)1 Message (org.apache.cxf.message.Message)1 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)1 JMSConfiguration (org.apache.cxf.transport.jms.JMSConfiguration)1 ResourceCloser (org.apache.cxf.transport.jms.util.ResourceCloser)1