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);
}
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;
}
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;
}
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();
}
}
Aggregations