List of usage examples for javax.jms MapMessage getIntProperty
int getIntProperty(String name) throws JMSException;
From source file:eu.domibus.submission.transformer.impl.JMSMessageTransformer.java
/** * Transforms {@link javax.jms.MapMessage} to {@link eu.domibus.submission.Submission} * * @param messageIn the message ({@link javax.jms.MapMessage}) to be tranformed * @return the result of the transformation as {@link eu.domibus.submission.Submission} *//*from w w w . java 2 s.c o m*/ @Override public Submission transformToSubmission(final MapMessage messageIn) { final Submission target = new Submission(); try { target.setAction(messageIn.getStringProperty(JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_ACTION)); target.setService(messageIn.getStringProperty(JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_SERVICE)); target.setServiceType( messageIn.getStringProperty(JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_SERVICE_TYPE)); target.setConversationId( messageIn.getStringProperty(JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_CONVERSATION_ID)); final String fromPartyID = messageIn .getStringProperty(JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_FROM_PARTY_ID); final String fromPartyType = messageIn .getStringProperty(JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_FROM_PARTY_TYPE); target.addFromParty(fromPartyID, fromPartyType); target.setFromRole( messageIn.getStringProperty(JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_FROM_ROLE)); final String toPartyID = messageIn .getStringProperty(JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_TO_PARTY_ID); final String toPartyType = messageIn .getStringProperty(JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_TO_PARTY_TYPE); target.addToParty(toPartyID, toPartyType); target.setToRole(messageIn.getStringProperty(JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_TO_ROLE)); target.addMessageProperty(JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_PROPERTY_ORIGINAL_SENDER, messageIn.getStringProperty( JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_PROPERTY_ORIGINAL_SENDER)); target.addMessageProperty(JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_PROPERTY_FINAL_RECIPIENT, messageIn.getStringProperty( JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_PROPERTY_FINAL_RECIPIENT)); target.setRefToMessageId( messageIn.getStringProperty(JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_REF_TO_MESSAGE_ID)); target.setAgreementRef( messageIn.getStringProperty(JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_AGREEMENT_REF)); final int numPayloads = messageIn .getIntProperty(JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_TOTAL_NUMBER_OF_PAYLOADS); for (int i = 1; i <= numPayloads; i++) { final String propPayload = String.valueOf(MessageFormat .format(JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_PAYLOAD_NAME_FORMAT, i)); final String bodyloadFileName = JMSMessageTransformer.BODYLOAD_FILE_NAME_FORMAT; final String contentId; final String mimeType; String description = null; final byte[] payloadData; payloadData = messageIn.getBytes(propPayload); final String payMimeTypeProp = String.valueOf(MessageFormat .format(JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_PAYLOAD_MIME_TYPE_FORMAT, i)); mimeType = messageIn.getStringProperty(payMimeTypeProp); final String payDescrip = String.valueOf(MessageFormat .format(JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_PAYLOAD_DESCRIPTION_FORMAT, i)); if (messageIn.getStringProperty(payDescrip) != null) { description = messageIn.getStringProperty(payDescrip); } final String payContID = String.valueOf(MessageFormat .format(JMSMessageTransformer.SUBMISSION_JMS_MAPMESSAGE_PAYLOAD_MIME_CONTENT_ID_FORMAT, i)); contentId = messageIn.getStringProperty(payContID); final Properties partProperties = new Properties(); if (mimeType != null && !mimeType.trim().equals("")) { partProperties.setProperty(Property.MIME_TYPE, mimeType); } target.addPayload(contentId, payloadData, partProperties, i == 1, description, null); } } catch (final JMSException ex) { JMSMessageTransformer.LOG.error("Error while getting properties from MapMessage", ex); throw new RuntimeException(ex); } return target; }