I am posting the information below in the Camel support forum as well to see if someone there is able to provide additional insight, I will let this support forum know if anything comes back.
I have been able to perform the task that was needed/required. The issue I am having now is when the file is transferred between ActiveMQ and the SFTP server; the file size is changing slightly, which is causing an issue. I believe this is due to the file not being transfer as a pure raw binary file. Camel is retrieving the file from ActiveMQ using JMS, after further reading JMS needs to be informed the data being retrieved is in binary format and set appropriately. I added jmsMessageType=Bytes in my from uri line to force Camel to read/retrieve the file as binary, My example Camel route 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&cacheLevelName=CACHE_CONSUMER&concurrentConsumers=4&maxConcurrentConsumers=10&maxMessagesPerTask=200&transacted=true&lazyCreateTransactionManager=false&acknowledgementModeName=CLIENT_ACKNOWLEDGE&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&autoCreate=true&binary=true&passiveMode=true&knownHostsFile=/dir/hosts&fileName=${exchangeProperty.sftpFileName}"/> </route> </camelContext> </beans> I attempted to use some conversion setting in the route; these are the lines that are commented out. If I uncomment the lines I receive errors similar to the following in the ActiveMQ log file. 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 ________________________________ From: Jean-Baptiste Onofré <[email protected]> Sent: Wednesday, February 25, 2026 1:18 AM To: [email protected] <[email protected]> Subject: Re: ActiveMQ Binary Message and SFTP Transfer CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe. Hi Jason, Maybe you should use a headerFilterStrategy to avoid conflicts between JMS and Camel headers. If you want to use JMS message content for a Camel endpoint (to) configuration/uri, you might need to use the Routing Slip EIP, for example. Are you using the camel-jms component? It seems this is more of a Camel question than an ActiveMQ one. Regards, JB On Tue, Feb 24, 2026 at 9:13 PM Jason Jackson <[email protected]> wrote: > I have an application that is sending a pure binary file to an ActiveMQ > queue. > > The message details of the binary file contains information related to the > file. One component in the message details is the following: > > filename=myfile.txt > > Using the embedded Camel functionality and capabilities of ActiveMQ I am > performing the following actions. > > This is valid and ActiveMQ loads without any issues > > <setVariable name="myFileName"> > <simple>${bodyAs(String)} > regex('(?s).*filename=([a-zA-Z0-9_\-\.]+).*')</simple> > </setVariable> > > > My uri is the following > > <to uri="sftp://username@ip > /dir?password=myPassword&autoCreate=true&binary=true&passiveMode=true&knownHostsFile=/myHostFile&fileName=${myFileName}"/> > > As soon as I add fileName=${myFileName} to the URI, ActiveMQ throws an > error and fails to load. An example of the error is: > > Exception encountered during context initialization - cancelling refresh > attempt: org.apache.camel.FailedToCreateRouteException: Failed to create > route: QUEUE1 at: >>> > To[sftp://username@ip/dir?password=xxxxxx&autoCreate=true&binary=true&passiveMode=true&knownHostsFile=/myHostFile&fileName=${myFileName}] > <<< in route: Route(QUEUE1)[From[jms:queue://QUEUE1... because: Failed to > resolve endpoint: > sftp://username@ip/dir?autoCreate=true&binary=true&fileName=myFileName&knownHostsFile=/myHostFile&passiveMode=true&password=xxxxxx > due to: Error binding property (fileName=${myFileName}) with name: fileName > on bean: > sftp://username@ip/dir?autoCreate=true&binary=true&fileName=myFileName&knownHostsFile=/myHostFile&passiveMode=true&password=xxxxxx > with value: ${myFileName} | org.apache.activemq.xbean.XBeanBrokerFactory$1 > | main > > If I do not attempt to set the filename and just send the file over it > connects via sftp and the file transfers without any issues, the issue is I > need to set the file name to what is in the message details. > > I have attempted to load the uri using the toD dynamic option and it fails > also. This error states it failed with an excepting and just provides a > print out of the uri I am attempting to connect to. > > I used the following link, > https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcamel.apache.org%2Fcomponents%2F4.14.x%2Fsftp-component.html%23_usage&data=05%7C02%7Cjason.jackson%40itechag.com%7Cc6297dc4303442e2b39a08de7435d6ea%7C07e5f1b9902a4d9f974c04601319bfec%7C0%7C0%7C639075971772832707%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=l8ssROO3PRpgj3mi4BjvQlb%2FuImdvLetnpjb1600t%2BY%3D&reserved=0<https://camel.apache.org/components/4.14.x/sftp-component.html#_usage>, > for the Camel commands/settings. > > Does anyone have a suggestion on what I may be doping wrong or if there is > an additional entry/setting that I need? > > Jason >
