/*
(non-Javadoc)

@see
org.springframework.jms.core.MessageCreator#createMessage(javax.jms
.Session)
356046
@Override
    public Message createMessage(Session session) throws JMSException {
        Message message = session.createTextMessage(requestMessage);
        if (correlationId != null)
            message.setJMSCorrelationID(correlationId);
        if (replyQueue != null) {
            message.setJMSReplyTo(replyQueue);
        }
        if (delaySeconds >0) {
            ApplicationContext.getJmsProvider().setMessageDelay(null, message, delaySeconds);
        }
        return message;
    }
698557
def create(self, message, mid=None, age=60, force=True):
        
        with self.session_lock:
            if not hasattr(message, "id"):
                message.__setattr__("id", "event-%s" % (uuid.uuid4().hex,))
            if self.session_list.get(message.id, None) is not None:
                if force is False:
                    raise SessionError("Message id: %s duplicate!" %
                                       message.id)
                else:
                    message = Message(message.to_dict(), generate_id=True)

            session = {
                "status": Status.CREATED,
                "message": message,
                "age": age,
                "mid": mid,
                "created_at": time(),
                "is_published": Event(),
                "is_resolved": Event()
            }
            self.session_list.update({
                message.id: session
            })

            return session
242471
@Override
    public MapMessage createMapMessage() throws JMSRuntimeException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createMapMessage");

        MapMessage mapMessage = null;

        try {
            mapMessage = jmsSession.createMapMessage();
        } catch (JMSException jmse) {
            throw (JMSRuntimeException) JmsErrorUtils.getJMS2Exception(jmse, JMSRuntimeException.class);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createMapMessage", new Object[] { mapMessage });
        }

        return mapMessage;

    }
1370264
@Override
    public JMSContext createContext(String userName, String password, int sessionMode) throws JMSRuntimeException, JMSSecurityRuntimeException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createContext", new Object[] { userName, password, sessionMode });

        JmsConnectionImpl jmsConnection = null;
        JMSContext jmsContext = null;
        try {

            //CTS test failure was reported when the session mode was passed as -1,  so adding the validation
            switch (sessionMode)
            {
                case JMSContext.AUTO_ACKNOWLEDGE:
                case JMSContext.CLIENT_ACKNOWLEDGE:
                case JMSContext.DUPS_OK_ACKNOWLEDGE:
                case JMSContext.SESSION_TRANSACTED: {
                    break;
                }
                default:
                    throw (JMSRuntimeException) JmsErrorUtils.newThrowable(JMSRuntimeException.class,
                                                                           "INVALID_ACKNOWLEDGE_MODE_CWSIA0514",
                                                                           new Object[] { sessionMode },
                                                                           tc
                                    );
            }

            // Create JMSConnection to pass into JMSContext
            jmsConnection = (JmsConnectionImpl) createConnection(userName, password);
            jmsContext = new JmsJMSContextImpl(jmsConnection, sessionMode, true);
        } catch (JMSSecurityException jmsse) {
            throw (JMSSecurityRuntimeException) JmsErrorUtils.getJMS2Exception(jmsse, JMSSecurityRuntimeException.class);
        } catch (JMSException jmse) {
            throw (JMSRuntimeException) JmsErrorUtils.getJMS2Exception(jmse, JMSRuntimeException.class);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createContext", jmsContext);
        }
        return jmsContext;

    }
791458
final MimeMessage populateMimeMessage(@Nonnull final Email email, @Nonnull Session session)
			throws MessagingException, UnsupportedEncodingException {
		checkArgumentNotEmpty(email, "email is missing");
		checkArgumentNotEmpty(session, "session is needed, it cannot be attached later");
		
		final MimeMessage message = new MimeMessage(session) {
			@Override
			protected void updateMessageID() throws MessagingException {
				if (valueNullOrEmpty(email.getId())) {
					super.updateMessageID();
				} else {
					setHeader("Message-ID", email.getId());
				}
			}
			
			@Override
			public String toString() {
				try {
					return "MimeMessage<id:" + super.getMessageID() + ", subject:" + super.getSubject() + ">";
				} catch (MessagingException e) {
					throw new AssertionError("should not reach here");
				}
			}
		};
		
		// set basic email properties
		MimeMessageHelper.setSubject(email, message);
		MimeMessageHelper.setFrom(email, message);
		MimeMessageHelper.setReplyTo(email, message);
		MimeMessageHelper.setRecipients(email, message);
		
		populateMimeMessageMultipartStructure(message, email);
		
		MimeMessageHelper.setHeaders(email, message);
		message.setSentDate(new Date());

		if (!valueNullOrEmpty(email.getDkimSigningDomain())) {
			return signMessageWithDKIM(message, email);
		}
		
		return message;
	}
89531
protected void initMessageObject() {

        try {
            if (CmsStringUtil.isEmpty(getParamAction()) || CmsDialog.DIALOG_INITIAL.equals(getParamAction())) {
                // create a new message info object
                m_msgInfo = new CmsMessageInfo();
            } else {
                // this is not the initial call, get the message info object from session
                m_msgInfo = (CmsMessageInfo)getDialogObject();
            }
        } catch (Exception e) {
            // create a new message info object
            m_msgInfo = new CmsMessageInfo();
        }
        m_msgInfo.setFrom(getCms().getRequestContext().getCurrentUser().getFullName());
        m_msgInfo.setTo(getToNames());
    }
195334
protected Session createSession(Connection connection) throws JMSException {
        if (connection instanceof QueueConnection) {
            return ((QueueConnection) connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        }
        return connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    }
138933
public static JavacMessages instance(Context context) {
        JavacMessages instance = context.get(messagesKey);
        if (instance == null)
            instance = new JavacMessages(context);
        return instance;
    }
1184394
public static UserSystemMessage create (Name sender, String message, String bundle)
    {
        return new UserSystemMessage(sender, message, bundle, INFO);
    }
806485
@Override
    public TextMessage createTextMessage() throws JMSRuntimeException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createTextMessage");

        TextMessage textMessage = null;

        try {
            textMessage = jmsSession.createTextMessage();
        } catch (JMSException jmse) {
            throw (JMSRuntimeException) JmsErrorUtils.getJMS2Exception(jmse, JMSRuntimeException.class);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createTextMessage", new Object[] { textMessage });
        }

        return textMessage;

    }
118798
private MessagingEngine createMessageEngine(JsMEConfig me) throws Exception {

        String thisMethodName = CLASS_NAME + ".createMessageEngine(JsMEConfig)";

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.entry(tc, thisMethodName, "replace ME name here");
        }

        JsMessagingEngine engineImpl = null;

        bus = new JsBusImpl(me, this, (me.getSIBus().getName()));// getBusProxy(me);
        engineImpl = new JsMessagingEngineImpl(this, bus, me);

        MessagingEngine engine = new MessagingEngine(me, engineImpl);
        _messagingEngines.put(defaultMEUUID, engine);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.exit(tc, thisMethodName, engine.toString());
        }

        return engine;
    }
20315
public JsJmsStreamMessage createJmsStreamMessage() throws MessageCreateFailedException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createJmsStreamMessage");
    JsJmsStreamMessage msg = null;
    try {
      msg = new JsJmsStreamMessageImpl(MfpConstants.CONSTRUCTOR_NO_OP);
    }
    catch (MessageDecodeFailedException e) {
      /* No need to FFDC this as JsMsgObject will already have done so */
      // No FFDC code needed
      throw new MessageCreateFailedException(e);
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createJmsStreamMessage");
    return msg;
  }
156865
@Override
    public void createMessages(VarTensor[] inMsgs, VarTensor[] outMsgs) {
        Identity<MVecArray<VarTensor>> modIn = new Identity<MVecArray<VarTensor>>(new MVecArray<VarTensor>(inMsgs));
        MutableModule<MVecArray<VarTensor>> modOut = getCreateMessagesModule(modIn, null);
        modOut.setOutput(new MVecArray<VarTensor>(outMsgs));
        modOut.forward();
    }
168675
@Override
    public Message newMessage(final String message, final Object... params) {
        return getParameterized().set(message, params);
    }
90235
public Message createMessage(BaseMessageHeader messageHeader, MessageRecordDesc messageDataDesc)
    {
        BaseMessage message = null;
        String strMessageClassName = this.getField(MessageLog.MESSAGE_CLASS_NAME).toString();
        message = BaseMessage.createMessage(strMessageClassName, messageHeader, null);
        if (messageDataDesc != null)
            message.addMessageDataDesc(messageDataDesc);
        if (messageHeader instanceof TrxMessageHeader)
        {
            if (message == null)
                message = BaseMessage.createMessage((TrxMessageHeader)messageHeader);
            if (message == null)
                message = new TreeMessage((TrxMessageHeader)messageHeader, null);
        }
        String strXMLData = this.getField(MessageLog.XML_MESSAGE_DATA).getString();
        message.setXML(strXMLData);
        return message;
    }
72774
void newMessage(final byte[] message, final Session session) {
        callback.recive(serializer.deserialize(message), session);
    }
943706
final JsJmsMessage createInboundJmsMessage(JsMsgObject jmo, int messageType) {

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())SibTr.entry(tc, "createInboundJmsMessage " + messageType );

    JsJmsMessage jmsMessage = null;

    switch (messageType) {

      case JmsBodyType.BYTES_INT:
        jmsMessage = new JsJmsBytesMessageImpl(jmo);
        break;

      case JmsBodyType.MAP_INT:
        jmsMessage = new JsJmsMapMessageImpl(jmo);
        break;

      case JmsBodyType.OBJECT_INT:
        jmsMessage = new JsJmsObjectMessageImpl(jmo);
        break;

      case JmsBodyType.STREAM_INT:
        jmsMessage = new JsJmsStreamMessageImpl(jmo);
        break;

      case JmsBodyType.TEXT_INT:
        jmsMessage = new JsJmsTextMessageImpl(jmo);
        break;

      default:
        jmsMessage = new JsJmsMessageImpl(jmo);
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())SibTr.exit(tc, "createInboundJmsMessage");
    return jmsMessage;
  }