2

I am using blueprint to develop a camel restlet project to deploy on Fuse. It is a very simple HTTP POST with simple text body. I set the exchange pattern to Inonly.

However, I was expecting the connection to be terminated after the actual post, but I am receiving a 200 OK with the body filled with whatever the final body is in the processing at end.

Is this how it is meant to work? Do I therefore need to manually clear the body?

Also, what happens if the processing is a long running process? I would want to terminate straight after the data have been posted, rather than wait until the complete processing inside the context.

My blueprint looks like this:

 <camelContext xmlns="http://camel.apache.org/schema/blueprint">
  <route id="timerToLog">
    <from uri="restlet:http://localhost:7070/arena?restletMethod=POST&amp;exchangePattern=inOnly"/>
    <process ref="marcformatreader"/>
    <log message="${body}" loggingLevel="INFO"/>
    <process ref="marcformatwriter"/>
    <log message="${body}" loggingLevel="INFO"/>
    <to pattern="InOnly" uri="file:C:/Camel/output?fileName=output.mrc"/>
  </route>
</camelContext>
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Souciance Eqdam Rashti
  • 3,143
  • 3
  • 15
  • 31

1 Answers1

1

One solution would be to use WireTap pattern and return response immediately like this (note! I didn't execute that code so mind the possible typos).

<camelContext xmlns="http://camel.apache.org/schema/blueprint">
    <route id="timerToLog">
        <from uri="restlet:http://localhost:7070/arena?restletMethod=POST&amp;exchangePattern=inOnly"/>
        <wireTap uri="direct:tap" copy="true"></wireTap>
        <transform>
            <constant>OK</constant>
        </transform>
    </route>

    <route id="wireTapToLog">
        <from uri="direct:tap"/>
        <process ref="marcformatreader"/>
        <log message="${body}" loggingLevel="INFO"/>
        <process ref="marcformatwriter"/>
        <log message="${body}" loggingLevel="INFO"/>
        <to pattern="InOnly" uri="file:C:/Camel/output?fileName=output.mrc"/>
    </route>

</camelContext>

With WireTap Camel will continue processing the exchange in another thread so the POST method will return immediately just text "OK".

Souciance Eqdam Rashti
  • 3,143
  • 3
  • 15
  • 31
jnupponen
  • 715
  • 1
  • 5
  • 16
  • Aha, sounds interesting, I will give it a shot and test it and get back with result. Hopefully in the future there is simple parameter you can set to enable this. – Souciance Eqdam Rashti Sep 19 '15 at 10:21
  • Your code was almost correct. I had to add the attribute copy="true" as well. I will edit your post just to clarify. – Souciance Eqdam Rashti Sep 19 '15 at 11:21
  • The only strange thing is that you don't actually see this reflected the graphical layout with the nodes. You see it in the xml file but the nodes don't reflect and I guessing this is because you cannot have multiple sources in a single route file. – Souciance Eqdam Rashti Sep 19 '15 at 11:23