I am receiving data within ActiveMQ on QUEUE_1, the data that arrives on the 
queue is in a raw binary format.  The data is being retrieved from ActiveMQ 
using a Camel route and transmitted to an alternate location using SFTP.  If 
the data is modified in any way the destination location will reject the data.  
When the Data is retrieved from ActiveMQ and sent via SFTP there is a slight 
files size difference and data does not appear to be in the exact format.

After my initial testing I discovered I was possibly missing one setting on the 
from uri line, I added jmsMessageType=Bytes to force JMS to know the file is in 
binary format.

My example Camel rout I am using is below.

<beans
   xmlns="http://www.springframework.org/schema/beans";
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xsi:schemaLocation="http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd 
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd";>

   <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"; 
streamCache="true">
      <route id="QUEUE_1">
         <from 
uri="jms:queue://QUEUE_1?jmsMessageType=Bytes&amp;cacheLevelName=CACHE_CONSUMER&amp;concurrentConsumers=4&amp;maxConcurrentConsumers=10&amp;maxMessagesPerTask=200&amp;transacted=true&amp;lazyCreateTransactionManager=false&amp;acknowledgementModeName=CLIENT_ACKNOWLEDGE&amp;connectionFactory=#broker1"/>
         <setProperty name="sftpFileName">
            <simple>${header.JMSCorrelationID}</simple>
         </setProperty>
<!--
         <convertBodyTo type="java.io.InputStream"/>
         <convertBodyTo type="byte[]"/>
         <convertBodyTo type="java.lang.Byte[]"/>
-->
         <to 
uri="sftp://user@ip/dir?password=myPassword&amp;autoCreate=true&amp;binary=true&amp;passiveMode=true&amp;knownHostsFile=/dir/hosts&amp;fileName=${exchangeProperty.sftpFileName}"/>
      </route>
   </camelContext>
</beans>


I am not sure if any additional transformations or settings are required in or 
to retrieve the file from ActiveMQ and send it via SFTP in pure raw binary 
format.

I attempted to set/use the lines that are commented out but receive additional 
errors in my log file, those errors are below.


Caused by: org.apache.camel.InvalidPayloadException: No body available of type: 
java.io.InputStream but has type: java.lang.Byte[] on: Message[ID:broker_1]. 
Caused by: No type converter available to convert from type: java.lang.Byte[] 
to the required type: java.io.InputStream. Exchange[]. Caused by: 
[org.apache.camel.NoTypeConversionAvailableException - No type converter 
available to convert from type: java.lang.Byte[] to the required type: 
java.io.InputStream]

Caused by: org.apache.camel.NoTypeConversionAvailableException: No type 
converter available to convert from type: java.lang.Byte[] to the required 
type: java.io.InputStream

Execution of JMS message listener failed. Caused by: 
[org.apache.camel.component.file.GenericFileOperationFailedException - Cannot 
store file: dir/file.name] | 
org.apache.camel.component.jms.EndpointMessageListener | Camel (camel) thread 
#2 - JmsConsumer[QUEUE_1]

Caused by: org.apache.camel.InvalidPayloadException: No body available of type: 
java.io.InputStream but has type: java.lang.Byte[] on: Message[ID:broker_1]. 
Caused by: No type converter available to convert from type: java.lang.Byte[] 
to the required type: java.io.InputStream. Exchange[]. Caused by: 
[org.apache.camel.NoTypeConversionAvailableException - No type converter 
available to convert from type: java.lang.Byte[] to the required type: 
java.io.InputStream]

Caused by: org.apache.camel.NoTypeConversionAvailableException: No type 
converter available to convert from type: java.lang.Byte[] to the required 
type: java.io.InputStream


Does the example route above appear correct or should some additional 
settings/conversions be added



Jason

Reply via email to