I have a Spring Integration (SI) application that extracts email attachments which can be either XML files or JPG images and sends it to a legacy system using WebSphere MQ for further downstream processing. I am using the SI jms:outbound-channel-adapter for the MQ messaging. My SI application context has the following definitions:
<!-- Legacy Queue Connection Factory and Queue Name definitions -->
<bean id="connectionFactory" class="org.springframework.jms.connection.CachingC onnectionFactory">
<property name="targetConnectionFactory">
<bean class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="port" value="${legacyQMgrPort}"/>
<property name="hostName" value="${legacyQMgrHost}"/>
<property name="queueManager" value="${legacyQMgrName}"/>
<property name="channel" value="${legacyQMgrClientChannel}"/>
<property name="transportType" value="${transportTypeMQClient}"/>
</bean>
</property>
<property name="sessionCacheSize" value="10"/>
<property name="cacheProducers" value="false"/>
</bean>
<bean id="requestQueue" class="com.ibm.mq.jms.MQQueue" >
<property name="baseQueueName" value="${legacyRequestQName}"/>
<property name="TargetClient">
<util:constant static-field="com.ibm.mq.jms.JMSC.MQJMS_CLIENT_NONJMS_MQ" />
</property>
</bean>
<!-- Binary File to byte stream transformer for image files like .jpg, .gif etc -->
<int:channel id="bytesChannel"/>
<int-file:file-to-bytes-transformer input-channel="bytesChannel" output-channel="jmsOutChannel" delete-files="true"/>
<!-- Text File to String transformer for XML messages with UTF-16 encoding -->
<int:channel id="textChannel"/>
<int-file:file-to-string-transformer input-channel="textChannel" output-channel="jmsOutChannel" delete-files="true" charset="UTF-16"/>
<int:service-activator input-channel="jmsOutChannel"
output-channel="mqChannel"
ref="mqMessageHandler"/>
<bean id="mqMessageHandler" class="gov.dhs.cbp.tecs.tipoff.MQMessageHandler"/>
<int-jms:outbound-channel-adapter id="jmsOutboundAdapter" channel="mqChannel" connection-factory="connectionFactory" destination="requestQueue" extract-payload="true"/>
The XML files are transmitted correctly as JMS Text Messages over MQ. The issue seems to be with the image files which are transformed to a byte array first with the file-to-bytes transformer and then sent as the payload of a JMS message. For some reason the outbound-channel-adapter is treating the binary data as text when it should be a JMS bytes message. The following logs show the output from some tracing within Spring Integration components.
The JMSMessage Class: jms_text in the log output indicates that it is a text message when it should have been a jms_bytes message due to the binary payload.
Has anyone encountered this issue? If so can you please let me know how you resolved it.
12:30:08,890 INFO CachingConnectionFactory: Established shared JMS Connection: com.ibm.mq.jms.MQQueueConnection@1352367
12:30:08,968 DEBUG CachingConnectionFactory: Creating cached JMS Session for mode 1: com.ibm.mq.jms.MQQueueSession@109da93
12:30:08,984 DEBUG DynamicJmsTemplate: Executing callback on JMS Session: Cached JMS Session: com.ibm.mq.jms.MQQueueSession@109da93
12:30:09,062 DEBUG DynamicJmsTemplate: Sending created message:
JMSMessage class: jms_text
JMSType: jms_bytes
JMSDeliveryMode: 2
JMSExpiration: 0
JMSPriority: 4
JMSMessageID: null
JMSTimestamp: 0
JMSCorrelationID: null
JMSDestination: null
JMSReplyTo: null
JMSRedelivered: false
correlationId: SAMPLE_Venky_Image.jpg
fileName: SAMPLE_Venky_Image.jpg
fileType: BINARY
file_name: SAMPLE_Venky_Image.jpg
timestamp: 1330623008406
[B@58e2a1
12:30:09,187 DEBUG DirectChannel: postSend (sent=true) on channel 'mqChannel', message: [Payload=[B@58e2a1][Headers={timestamp=1330623008406, id=4ee6d8ae-8ca1-451c-93bc-68fc8d483513, jms_type=jms_bytes, fileType=BINARY, correlationId=SAMPLE_Venky_Image.jpg, fileName=SAMPLE_Venky_Image.jpg,


Reply With Quote
Such dependencies can be avoided in many (if not most) cases.