// Path: camel-milo/src/main/java/org/apache/camel/component/milo/Messages.java
// public final class Messages {
// 	private Messages() {
// 	}
// 
// 	/**
// 	 * Fill a Message from a DataValue
// 	 *
// 	 * @param value
// 	 *            the value to feed from
// 	 * @param result
// 	 *            the result to feed to
// 	 */
// 	public static void fillFromDataValue(final DataValue value, final DefaultMessage result) {
// 		result.setBody(value);
// 		result.setFault(value.getStatusCode().isBad());
// 	}
// }
// 
// Path: camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConnection.java
// @FunctionalInterface
// public interface MonitorHandle {
// 	public void unregister();
// }


import java.util.Objects;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.component.milo.Messages;
import org.apache.camel.component.milo.client.MiloClientConnection.MonitorHandle;
import org.apache.camel.impl.DefaultConsumer;
import org.apache.camel.impl.DefaultMessage;
import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
		this.handle = this.connection.monitorValue(this.configuration, this::handleValueUpdate);
	}

	@Override
	protected void doStop() throws Exception {
		if (this.handle != null) {
			this.handle.unregister();
			this.handle = null;
		}

		super.doStop();
	}

	private void handleValueUpdate(final DataValue value) {
		final Exchange exchange = getEndpoint().createExchange();
		exchange.setIn(mapMessage(value));
		try {
			getAsyncProcessor().process(exchange);
		} catch (final Exception e) {
			LOG.debug("Failed to process message", e);
		}
	}

	private Message mapMessage(final DataValue value) {
		if (value == null) {
			return null;
		}

		final DefaultMessage result = new DefaultMessage();

// Path: camel-milo/src/main/java/org/apache/camel/component/milo/Messages.java
// public final class Messages {
// 	private Messages() {
// 	}
// 
// 	/**
// 	 * Fill a Message from a DataValue
// 	 *
// 	 * @param value
// 	 *            the value to feed from
// 	 * @param result
// 	 *            the result to feed to
// 	 */
// 	public static void fillFromDataValue(final DataValue value, final DefaultMessage result) {
// 		result.setBody(value);
// 		result.setFault(value.getStatusCode().isBad());
// 	}
// }
// 
// Path: camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConnection.java
// @FunctionalInterface
// public interface MonitorHandle {
// 	public void unregister();
// }


// Path: camel-milo/src/main/java/org/apache/camel/component/milo/client/MiloClientConsumer.java
import java.util.Objects;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.component.milo.Messages;
import org.apache.camel.component.milo.client.MiloClientConnection.MonitorHandle;
import org.apache.camel.impl.DefaultConsumer;
import org.apache.camel.impl.DefaultMessage;
import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

		this.handle = this.connection.monitorValue(this.configuration, this::handleValueUpdate);
	}

	@Override
	protected void doStop() throws Exception {
		if (this.handle != null) {
			this.handle.unregister();
			this.handle = null;
		}

		super.doStop();
	}

	private void handleValueUpdate(final DataValue value) {
		final Exchange exchange = getEndpoint().createExchange();
		exchange.setIn(mapMessage(value));
		try {
			getAsyncProcessor().process(exchange);
		} catch (final Exception e) {
			LOG.debug("Failed to process message", e);
		}
	}

	private Message mapMessage(final DataValue value) {
		if (value == null) {
			return null;
		}

		final DefaultMessage result = new DefaultMessage();

		Messages.fillFromDataValue(value, result);