On 2022/09/07 07:42:52 Simo Hakanen wrote:
> Hello list
>
> We use camel to route messages over sjms (activemq) between processes,
> where the remote end runs a route that does some processing and returns a
> large json-response.
> After experimenting with streamcaching on that remote end, we noticed that
> if the stream is spooled to disk, the route fails with timeout.
> The error is FileNotFoundException on the spooled file happening when the
> JMS response is being created. From the logs it looks like the file is
> deleted as part of the onComplete of the route before the response to
> JMS-part starts.
>
> Is this something uncommon?
> Is there some other way to do this than InOut-exchanges?
> I have a unit-test that shows the behavior if that helps.
>
> --
> Simo Hakanen
>

These are the simple routes that replicate the problem:

static final String SJMS_ENTRY = "";

from(DIRECT_ENTRY)
.routeId("LOCAL_ROUTE")
.streamCaching()
.marshal().json(JsonLibrary.Jackson)
.to(ExchangePattern.InOut,
"sjms:queue:entry?connectionFactory=#mq&requestTimeout=1000&exchangePattern=InOut")
.unmarshal().json(JsonLibrary.Jackson, String[].class)
.log(LoggingLevel.INFO, "${headers}/${body}")
.to(MOCK_RESULT)
;

from("sjms:queue:entry?connectionFactory=#mq&requestTimeout=1000&exchangePattern=InOut")
.routeId("REMOTE_ROUTE")
.streamCaching()
.unmarshal().json(JsonLibrary.Jackson)
.log(LoggingLevel.INFO, "${headers}/${body}")
.process(createLargeArrayProcessor())
.marshal(new JacksonDataFormat())
;

Streamcaching is configured as
context().getStreamCachingStrategy().setEnabled(true);
context().getStreamCachingStrategy().setSpoolThreshold(1024);


When I run these in a test I get this logged

2022-09-23 08:45:27,495 DEBUG [ActiveMQ Session Task-1]
o.a.c.c.s.c.EndpointMessageListener [EndpointMessageListener.java :
173] Received Message has JMSCorrelationID
[Camel-53F631BCD5B42AC-0000000000000002]
2022-09-23 08:45:27,499 INFO [ActiveMQ Session Task-1] o.a.c.Tracing
[DefaultTracer.java : 244] *--> [REMOTE_ROUTE]
[from[sjms:queue:entry?connectionF] Exchange[Id:
53F631BCD5B42AC-0000000000000003, BodyType: byte[], Body: "Hello,
World"]
2022-09-23 08:45:27,499 INFO [ActiveMQ Session Task-1] o.a.c.Tracing
[DefaultTracer.java : 244]      [REMOTE_ROUTE]
[unmarshal[org.apache.camel.model.] Exchange[Id:
53F631BCD5B42AC-0000000000000003, BodyType: byte[], Body: "Hello,
World"]
2022-09-23 08:45:27,522 INFO [ActiveMQ Session Task-1] o.a.c.Tracing
[DefaultTracer.java : 244]      [REMOTE_ROUTE] [log
          ] Exchange[Id: 53F631BCD5B42AC-0000000000000003, BodyType:
String, Body: Hello, World]
2022-09-23 08:45:27,522 INFO [ActiveMQ Session Task-1] REMOTE_ROUTE
[CamelLogger.java : 166] {CamelMessageTimestamp=1663911927488,
Content-Type=application/json,
JMSCorrelationID=Camel-53F631BCD5B42AC-0000000000000002,
JMSCorrelationIDAsBytes=Camel-53F631BCD5B42AC-0000000000000002,
JMSDeliveryMode=2, JMSDestination=queue://entry,
JMSExpiration=1663911928488,
JMSMessageID=ID:scarlett-41651-1663911926862-6:3:1:1:1, JMSPriority=4,
JMSRedelivered=false,
JMSReplyTo=temp-queue://ID:scarlett-41651-1663911926862-6:2:1,
JMSTimestamp=1663911927488, JMSType=null, JMSXGroupID=null,
JMSXUserID=null}/Hello, World
2022-09-23 08:45:27,522 INFO [ActiveMQ Session Task-1] o.a.c.Tracing
[DefaultTracer.java : 244]      [REMOTE_ROUTE] [Processor@0x655f7ea
          ] Exchange[Id: 53F631BCD5B42AC-0000000000000003, BodyType:
String, Body: Hello, World]
2022-09-23 08:45:27,523 INFO [ActiveMQ Session Task-1] o.a.c.Tracing
[DefaultTracer.java : 244]      [REMOTE_ROUTE]
[marshal[org.apache.camel.model.Da] Exchange[Id:
53F631BCD5B42AC-0000000000000003, BodyType: String[], Body:
[Ljava.lang.String;@fedf70a]
2022-09-23 08:45:27,524 DEBUG [ActiveMQ Session Task-1]
o.a.c.i.e.DefaultStreamCachingStrategy
[DefaultStreamCachingStrategy.java : 196] Should spool cache 7998 ->
true
2022-09-23 08:45:27,531 INFO [ActiveMQ Session Task-1] o.a.c.Tracing
[DefaultTracer.java : 244] *<-- [REMOTE_ROUTE]
[from[sjms://queue:entry?connectio] Exchange[Id:
53F631BCD5B42AC-0000000000000003, BodyType: String[], Body:
[Ljava.lang.String;@fedf70a]
2022-09-23 08:45:27,531 DEBUG [ActiveMQ Session Task-1]
o.a.c.u.FileUtil [FileUtil.java : 502] Retrying attempt 0 to delete
file: 
/tmp/camel/camel-tmp-53F631BCD5B42AC-0000000000000000/cos3418540655559905979.tmp
2022-09-23 08:45:27,532 DEBUG [ActiveMQ Session Task-1]
o.a.c.u.FileUtil [FileUtil.java : 516] Tried 1 to delete file:
/tmp/camel/camel-tmp-53F631BCD5B42AC-0000000000000000/cos3418540655559905979.tmp
with result: true
2022-09-23 08:45:27,534 WARN [ActiveMQ Session Task-1]
o.a.c.c.s.c.SimpleMessageListenerContainer
[SimpleMessageListenerContainer.java : 148] Execution of JMS message
listener failed. This exception is ignored.
org.apache.camel.TypeConversionException: Error during type conversion
from type: org.apache.camel.converter.stream.FileInputStreamCache to
the required type: byte[] with value
org.apache.camel.converter.stream.FileInputStreamCache@2e515f6d due to
java.nio.file.NoSuchFileException:
/tmp/camel/camel-tmp-53F631BCD5B42AC-0000000000000000/cos3418540655559905979.tmp

Is this a bug or incorrect use of the library?

Reply via email to