/** * Prepare the message to be sent. The message will be sent after the caller has written the payload to * the OutputStream of the message and called the stream's close method. In the JMS case the * JMSOutputStream will then call back the sendExchange method of this class. {@inheritDoc} */ public void prepare(final Message message) throws IOException { boolean isTextPayload = JMSConstants.TEXT_MESSAGE_TYPE.equals(jmsConfig.getMessageType()); MessageStreamUtil.prepareStream(message, isTextPayload, this); }
private String getMessageType(final Message outMessage, final javax.jms.Message request) { String msgType; if (JMSMessageUtils.isMtomEnabled(outMessage) && !jmsConfig.getMessageType().equals(JMSConstants.TEXT_MESSAGE_TYPE)) { //get chance to set messageType from JMSConfiguration with MTOM enabled msgType = jmsConfig.getMessageType(); } else { msgType = JMSMessageUtils.getMessageType(request); } if (JMSConstants.TEXT_MESSAGE_TYPE.equals(msgType) && JMSMessageUtils.isMtomEnabled(outMessage)) { org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("INVALID_MESSAGE_TYPE", LOG); throw new ConfigurationException(msg); } return msgType; }
private void assertIsNotTextMessageAndMtom(final Message outMessage) { boolean isTextPayload = JMSConstants.TEXT_MESSAGE_TYPE.equals(jmsConfig.getMessageType()); if (isTextPayload && MessageUtils.getContextualBoolean(outMessage, org.apache.cxf.message.Message.MTOM_ENABLED) && outMessage.getAttachments() != null && outMessage.getAttachments().size() > 0) { org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("INVALID_MESSAGE_TYPE", LOG); throw new ConfigurationException(msg); } }
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; }