[ 
https://issues.apache.org/jira/browse/CAMEL-20540?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17824950#comment-17824950
 ] 

Raymond commented on CAMEL-20540:
---------------------------------

I do still think it's a good idea to add RouteExchangeIn and RouteExchangeOut 
(or maybe ExchangeRouteStarted and ExchangeRouteCompleted to be more aligned 
with other Camel events). 

Exploring the combination of EventNotifier with MessageHistory could also be a 
powerful combination. With some enhancement, it would be a power tool for data 
offloading.

One possibility is to offer more levels and return types for message history. 
Currently, only the node level is offered. Say there are multiple levels:

1. Node
2. Step
3. Route
4. Group

The default could still be node:


{code:java}
List<MessageHistory> messages = exchange.getHistory();{code}
But another parameter can specify the level:


{code:java}
List<MessageHistory> messages = exchange.getHistory(Level.Route);{code}

Step would give in/out of steps, route the in/out of routes and group in/out of 
group (group of routes).

Besides list, it would be also nice to dump the messagehistory as xml or json


{code:java}
List<MessageHistory> messages = exchange.dumpHistory("json");

// or

List<MessageHistory> messages = exchange.dumpHistory("xml",Level.Route);{code}

If the eventnotifier gets notified about, for example "ExchangeCompleted", it 
can get the history on different levels and in different formats. To really 
democratize this functionality, then besides using the Java API, the Camel DSL 
could be supported. Some examples:


{code:java}
//example 1
from("events:exchangecompleted?type=body&level=step&format=json")
  .to("elasticsearch://elasticsearch?operation=Index&indexName=camel");

//example 2
from("events:exchangefailed?type=messagehistory&level=route&format=json") 
    .setHeader(KafkaConstants.KEY, constant("Camel")) // Key of the message
    .to("kafka:test?brokers=localhost:9092");{code}








 

> Add RouteExchangeIn and RouteExchangeOut events
> -----------------------------------------------
>
>                 Key: CAMEL-20540
>                 URL: https://issues.apache.org/jira/browse/CAMEL-20540
>             Project: Camel
>          Issue Type: Wish
>    Affects Versions: 4.4.0
>            Reporter: Raymond
>            Priority: Minor
>
> In my Camel based platform I currently use Camel 3. There, users can add a 
> route or kamelet per task.
> Example:
> {code:java}
> <route routeid="1">
>   <from uri="activemq:SomeQueue"/>
>     //some task
>     <to uri="direct-vm:2"/>
> </route>
> <route routeid="2">
>   <from uri="direct-vm:2"/>
>     //some task
>   <to uri="direct-vm:3"/>
> </route>
> <route routeid="3">
>   <from uri="direct-vm:3"/>
>     //some task
>     <to uri="sftp:myserver"/>
> </route>    {code}
> I use the Event Notifier to get events to show the message that goes into 
> each route. For this the event *ExchangeCreated* is used 
> ([https://www.javadoc.io/doc/org.apache.camel/camel-api/latest/org/apache/camel/spi/CamelEvent.html)].
> For each route I get a copy of the message Exchange with the breadcrumbid. 
> This works because the routes are connected either through:
> 1. direct-vm
> 2. vm
> 3. activemq
> Now I like to migrate to Camel 4. The issue is that direct-vm and vm aren't 
> available anymore since Camel 4.0:
> [https://camel.apache.org/manual/camel-4-migration-guide.html]
> The problem is that a direct endpoint has only 1 ExchangeCreated event over 
> multiple routes.
> I wish to have a RouteExchangeIn and RouteExchangeOut CamelEvent, so that I 
> can still offer this functionality. The nice thing is that this then would 
> work for all endpoints.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to