Here is how my application works:
The user starts off filling out a form and submits it. This action starts the first camelroute which performs some processing until returning a “please Hold, processing your request…” type of view to the user.
This view sends an AJAXRequest which triggers a second route to start.
The first route enriches an object with contextual data which I need the second route to know about.How do I accomplish this?
It is stored in the header in.header of the first route and it has a good number of reference fields which go a few levels deep which makes it less joyful to send them as parts of a Html form request
Is there a good way of sending the object between the routes?
In general, JMS is a good choice for sharing data between routes that are executed asynchronously. Your use case has the added requirement of needing to correlate the enriched message with a subsequent request (by a requestId, etc).
One option is to use JMS selectors to pull the appropriate enriched messages in your 2nd route.
Another option (instead of using JMS) is to use an in memory cache (camel-cache or camel-hazelcast) to store your enriched messages in memory, then retrieve/clear them in your 2nd route.
[todo: add examples]