Skip to content

tutorial debugging a flow

Raymond Meester edited this page Jun 12, 2023 · 14 revisions

In this tutorial you learn how to debug a flow. We start with the flow we created with the Quick Start.

Step 1: Clone another flow

  • On the flows page click the 'clone' icon to clone the 'TestFlow'.

CloneFlow

Step 2: Configure the flow

  • The cloned flow is completely configured, but the name of the flow is still empty. Give it the name: "DebugFlow".

We also change the 'SINK' step to force an error:

  • Set the path to "C:\messages\out2". (this directory must not exist).
  • Set the options "Directory Must Exist" to "true" and "Auto Create" to "false".

SetToEndpoint

  • Save the flow.

Step 3: Test the flow

  • On the flows page stop the TestFlow if it's still running.
  • Put a new file test.txt into the C:\messages\in directory.
  • Now start the DebugFlow flow.

image

You'll notice that an alert appears. When hovering the alert you get more information on the alert. This box shows the total number of alerts of this day and show the last three alerts on mouse hover.

FlowAlert

  • Now you can check your logs (either in the terminal or in the log file):
2020-04-24 19:04:27.763 ERROR 5508 --- [ #7 - Multicast] o.a.connector.routes.DefaultRoute        : Failed delivery for (MessageId: ID-win81-1587738992721-0-5 on ExchangeId: ID-win81-1587738992721-0-5). Exhausted after delivery attempt: 1 caught: org.apache.camel.component.file.GenericFileOperationFailedException: Cannot store file: C:\messages\out2\sample.txt. Handled by DeadLetterChannel: [file://C:%5Cmessages%5Cerror]

Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                                        Elapsed (ms)
[2                 ] [2                 ] [from[file://C:%5Cmessages%5Cin]                                               ] [        24]
[2                 ] [setHeader6        ] [setHeader[AssimblyFlowID]                                                     ] [         0]
[2                 ] [setHeader7        ] [setHeader[AssimblyHeaderId]                                                   ] [         0]
[2                 ] [setHeader8        ] [setHeader[AssimblyFrom]                                                       ] [         0]
[2                 ] [to7               ] [log:RouteName.Tutorial1?level=INFO&showAll=true&multiline=true&style=Fixed    ] [         0]
[2                 ] [headerProcessor2  ] [Processor@0x65139872                                                          ] [         0]
[2                 ] [multicast2        ] [multicast                                                                     ] [         0]
[2                 ] [to8               ] [direct:flow=2endpoint=2                                                       ] [         0]
[2-2               ] [setHeader9        ] [setHeader[AssimblyHeaderId]                                                   ] [         0]
[2-2               ] [setHeader10       ] [setHeader[AssimblyTo]                                                         ] [         0]
[2-2               ] [headerProcessor2-2] [Processor@0x65139872                                                          ] [         0]
[2-2               ] [convertProcessor2-] [Processor@0x88625d                                                            ] [         0]
[2-2               ] [choice2           ] [choice[when[{header(ReplyTo) contains :}],when[{header(ReplyTo) is not null}],] [         0]
[2-2               ] [to11              ] [file://C:\messages\out2?directoryMustExist=true&autoCreate=false              ] [         0]

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------

org.apache.camel.component.file.GenericFileOperationFailedException: Cannot store file: C:\messages\out2\sample.txt
	at org.apache.camel.component.file.FileOperations.storeFile(FileOperations.java:389)
	at org.apache.camel.component.file.GenericFileProducer.writeFile(GenericFileProducer.java:318)
	at org.apache.camel.component.file.GenericFileProducer.processExchange(GenericFileProducer.java:172)
	at org.apache.camel.component.file.GenericFileProducer.process(GenericFileProducer.java:78)
	at org.apache.camel.support.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:67)
	at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:166)
	at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$RedeliveryTask.doRun(RedeliveryErrorHandler.java:702)
	at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$RedeliveryTask.run(RedeliveryErrorHandler.java:616)
	at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:148)
	at org.apache.camel.impl.engine.DefaultReactiveExecutor.schedule(DefaultReactiveExecutor.java:55)
	at org.apache.camel.processor.MulticastProcessor.lambda$schedule$1(MulticastProcessor.java:284)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.nio.file.NoSuchFileException: C:\messages\in\sample.txt -> C:\messages\out2\sample.txt
	at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
	at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
	at sun.nio.fs.WindowsFileCopy.copy(WindowsFileCopy.java:205)
	at sun.nio.fs.WindowsFileSystemProvider.copy(WindowsFileSystemProvider.java:278)
	at java.nio.file.Files.copy(Files.java:1274)
	at org.apache.camel.component.file.FileOperations.writeFileByFile(FileOperations.java:432)
	at org.apache.camel.component.file.FileOperations.storeFile(FileOperations.java:337)
	... 15 common frames omitted

Tip: The last lines of the log file can also be seen from Administration --> Log viewer

Step 4: Forcing error on startup

In the last step of this tutorial we will force an error on startup.

  • Stop the 'DebugFlow' flow and start the 'TestFlow'
  • Now start the 'DebugFlow' flow again.

You'll notice that the 'DebugFlow' flow doesn't start (at least on Windows, some other operatings systems allow this). This is because the other flow already listens to the same directory and this is not allowed. Click on the flow name to see a detailed error message.

FlowStartError

Now you completed this tutorial. You can continue to the next tutorial with an example of a request/reply flow.

Clone this wiki locally