[
https://issues.apache.org/jira/browse/CAMEL-22702?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18039346#comment-18039346
]
Claus Ibsen commented on CAMEL-22702:
-------------------------------------
So if you use tail=1 then it gets the last message and then wait for more
(without printing waiting ...)
{code:java}
$ camel cmd receive --uri=seda:cheese --output=json --tail=1
{"messages":[{"message":{"exchangeType":"org.apache.camel.support.DefaultExchange","messageType":"org.apache.camel.support.DefaultMessage","body":{"type":"java.lang.String","value":"Hello
Camel from
route1"}},"uid":13,"endpointUri":"seda:\/\/cheese","remoteEndpoint":false,"timestamp":0}]}
{"messages":[{"message":{"exchangeType":"org.apache.camel.support.DefaultExchange","messageType":"org.apache.camel.support.DefaultMessage","body":{"type":"java.lang.String","value":"Hello
Camel from
route1"}},"uid":14,"endpointUri":"seda:\/\/cheese","remoteEndpoint":false,"timestamp":0}]}
{"messages":[{"message":{"exchangeType":"org.apache.camel.support.DefaultExchange","messageType":"org.apache.camel.support.DefaultMessage","body":{"type":"java.lang.String","value":"Hello
Camel from
route1"}},"uid":15,"endpointUri":"seda:\/\/cheese","remoteEndpoint":false,"timestamp":0}]}
{code}
> Add structured output option for Camel JBang cmd receive
> --------------------------------------------------------
>
> Key: CAMEL-22702
> URL: https://issues.apache.org/jira/browse/CAMEL-22702
> Project: Camel
> Issue Type: Improvement
> Components: camel-jbang
> Reporter: Christoph Deppisch
> Assignee: Claus Ibsen
> Priority: Major
> Fix For: 4.17.0
>
>
> It would be good to produce structured output for the Camel JBang cmd receive
> command. I am thinking of something like
> {code:java}
> camel cmd receive my-route --endpoint kafka:inbox --output json{code}
> The output is a Json array of already received messages on this endpoint
> (according to the --tail option)
> The receive command is waiting for new messages to arrive and each message
> will be printed in a structured Json output like this:
> {noformat}
> [
> { "message": 1, "endpoint": "kafka://info", "body": "Hello Camel"},
> { "message": 2, "endpoint": "kafka://info", "body": "Hi Camel"}
> ]
> Waiting for new messages ...
> {
> "message": 3,
> "endpoint": "kafka://info",
> "body": "Howdy Camel"
> }{noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)