How correlate and check if a message is already correlated using java code?

How to correlate and check if a message is already correlated programmatically (java code) using flowable version 6.5.0?