Camel Components

OPC UA Browser

Since Camel 3.15

Only producer is supported

The Milo Client component provides access to OPC UA servers using the Eclipse Miloâ„¢ implementation.

Java 11+: This component requires Java 11+ at runtime.

This component uses Eclipse Milo 1.0.5. When migrating from earlier versions, be aware that the Milo API has undergone significant changes in the 1.0.x series.

Maven users will need to add the following dependency to their pom.xml for this component:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-milo</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

URI format

The URI syntax of the endpoint is:

milo-browse:opc.tcp://[user:password@]host:port/path/to/service?node=RAW(nsu=urn:foo:bar;s=item-1)

Please refer to the Milo Client component for further details about the construction of the URI.

Configuring Options

Camel components are configured on two separate levels:

  • component level

  • endpoint level

Configuring Component Options

At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.

For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.

Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.

You can configure components using:

  • the Component DSL.

  • in a configuration file (application.properties, *.yaml files, etc).

  • directly in the Java code.

Configuring Endpoint Options

You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.

Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.

A good practice when configuring options is to use Property Placeholders.

Property placeholders provide a few benefits:

  • They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.

  • They allow externalizing the configuration from the code.

  • They help the code to become more flexible and reusable.

The following two sections list all the options, firstly for the component followed by the endpoint.

Component Options

The OPC UA Browser component supports the following options which are listed below.

Name Description Default Type

clientId (producer)

An ID that is part of the key of the shared connections: endpoints with the same endpoint URI, requestedPublishingInterval and clientId use the same connection to the server. Set a different value to give an endpoint a connection of its own.

String

configuration (producer)

The client configuration that holds the default options of the endpoints of this component. Each endpoint uses a copy of it, with the options that are set on the endpoint.

MiloClientConfiguration

discoveryEndpointSuffix (producer)

A suffix that the client appends to the endpoint URI to get the URI of the discovery endpoint, for example /discovery. Not used when discoveryEndpointUri is set.

String

discoveryEndpointUri (producer)

The URI of the discovery endpoint that the client gets the endpoint descriptions of the server from, instead of the endpoint URI. It takes precedence over discoveryEndpointSuffix.

String

lazyStartProducer (producer)

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

autowiredEnabled (advanced)

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

boolean

allowedSecurityPolicies (client)

A comma-separated list of the security policies that the client may use, as URIs or as names of org.eclipse.milo.opcua.stack.core.security.SecurityPolicy, for example Basic256Sha256. Of the endpoints of the server with an allowed policy, the client uses the one with the highest security level. If not set, every policy is allowed, None included.

String

applicationName (client)

The application name of the client, which it sends to the server in its application description.

Apache Camel adapter for Eclipse Milo

String

applicationUri (client)

The application URI of the client, which it sends to the server in its application description. With a client certificate, it should match the application URI in that certificate.

http://camel.apache.org/EclipseMilo/Client

String

channelLifetime (client)

The requested lifetime in milliseconds of the security token of the secure channel, after which the client renews it. If not set, the default of Eclipse Milo is used.

Long

keyAlias (client)

The alias of the private key and its certificate in the key store. It can be omitted when the key store holds a single entry.

String

keyPassword (client)

The password of the private key of keyAlias in the key store.

String

keyStorePassword (client)

The password of the key store of keyStoreUrl.

String

keyStoreType (client)

The type of the key store of keyStoreUrl, as a java.security.KeyStore type. The default is PKCS12.

String

keyStoreUrl (client)

The URL of the key store with the certificate and the private key of the client, for example file:/etc/opcua/client.p12. A security policy other than None needs it.

String

maxPendingPublishRequests (client)

The maximum number of publish requests that the client keeps pending at the server for its subscription. If not set, the default of Eclipse Milo is used.

Long

maxResponseMessageSize (client)

The maximum size in bytes of a response message that the client accepts from the server. If not set, the default of Eclipse Milo is used.

Long

miloClientConnectionManager (client)

Autowired To use a custom org.apache.camel.component.milo.client.MiloClientConnectionManager that creates and releases the connections to the OPC UA servers. The default one shares a connection between the endpoints with the same endpoint URI, clientId, requestedPublishingInterval and validation of the server certificate, and closes it when the last endpoint releases it.

MiloClientConnectionManager

overrideHost (client)

Whether to replace the host of the endpoint URL that the server reports with the host of the endpoint URI. Use it when the server reports a host name that the client cannot reach.

false

boolean

overridePort (client)

Whether to replace the port of the endpoint URL that the server reports with the port of the endpoint URI. Use it when the server reports a port that the client cannot reach.

false

boolean

productUri (client)

The product URI of the client, which it sends to the server in its application description.

http://camel.apache.org/EclipseMilo

String

reconnectTimeout (client)

The delay in milliseconds before the client tries again to connect to the server after an attempt failed, and between two attempts to create the monitored items that the server refused. Neither attempt is made while the OPC UA client recovers a lost session on its own.

10000

long

requestedPublishingInterval (client)

The publishing interval in milliseconds that the client requests for the subscription of its connection, which carries the values of the monitored nodes. Endpoints with different values use different connections.

1_000.0

Double

requestTimeout (client)

The timeout in milliseconds of a request to the server. If not set, the default of Eclipse Milo is used.

Long

sessionName (client)

The name of the session that the client creates on the server. If not set, Eclipse Milo generates one.

String

sessionTimeout (client)

The requested timeout in milliseconds of the session, after which the server closes a session without activity. If not set, the default of Eclipse Milo is used.

Long

certificateValidator (security)

A custom validator for the certificate of the OPC UA server. When set, it is used instead of the trust list configured with trustListDirectory. Endpoints share a connection only when they use the same validator instance.

CertificateValidator

password (security)

The password for authentication. Use this instead of embedding credentials in the endpoint URI when the password contains special characters (such as ?, /, , &).

String

trustAllCertificates (security)

Whether to accept any certificate presented by the OPC UA server. This is insecure: the connection is encrypted, but the client does not authenticate the server it talks to. It only applies when neither certificateValidator nor trustListDirectory is configured.

false

boolean

trustListDirectory (security)

The directory holding the trust list used to validate the certificate of the OPC UA server, in the layout used by Eclipse Milo: trusted certificates in trusted/certs, CRLs of trusted certificates in trusted/crl, certificates of issuing CAs in issuer/certs and their CRLs in issuer/crl. The directories are created if they do not exist. Besides the chain of trust, the validity period, the revocation by a CRL of the trust list and the application URI of the server certificate are checked. A certificate issued by a CA is refused when the trust list holds no CRL of that CA; an empty CRL is enough. A server certificate that does not chain up to a trusted certificate is written to rejected/certs, from where it can be moved to trusted/certs once it has been checked.

String

username (security)

The username for authentication. Use this instead of embedding credentials in the endpoint URI when the username contains special characters (such as ?, /, , &).

String

Endpoint Options

The OPC UA Browser endpoint is configured using URI syntax:

milo-browse:endpointUri

With the following path and query parameters:

Path Parameters

Name Description Default Type

endpointUri (producer)

Required The endpoint URL of the OPC UA server, for example opc.tcp://localhost:4840/path. It can hold a user name and password in its user info part. The username and password options take precedence over them.

String

Query Parameters

Name Description Default Type

clientId (producer)

An ID that is part of the key of the shared connections: endpoints with the same endpoint URI, requestedPublishingInterval and clientId use the same connection to the server. Set a different value to give an endpoint a connection of its own.

String

depth (producer)

The number of levels that a recursive browse goes down, where the nodes to browse from are level 1. Only used when recursive is true. Default value notice: Maximum depth for browsing recursively (only if recursive = true).

3

int

direction (producer)

The direction of the references to follow: Forward, Inverse or Both. Default value notice: The direction to browse; see org.eclipse.milo.opcua.stack.core.types.enumerated.BrowseDirection.

Enum values:

  • Forward

  • Inverse

  • Both

Forward

BrowseDirection

discoveryEndpointSuffix (producer)

A suffix that the client appends to the endpoint URI to get the URI of the discovery endpoint, for example /discovery. Not used when discoveryEndpointUri is set.

String

discoveryEndpointUri (producer)

The URI of the discovery endpoint that the client gets the endpoint descriptions of the server from, instead of the endpoint URI. It takes precedence over discoveryEndpointSuffix.

String

filter (producer)

A regular expression that the node ID of a found node, in its parseable form such as ns=2;s=item, must match to be in the result and to be browsed further. If not set, all nodes are kept. Default value notice: Regular filter expression matching node ids.

None

String

includeSubTypes (producer)

Whether to follow the references of all subtypes of the References reference type. If false, only references of the abstract References type itself are returned, which are usually none. A recursive browse always includes the subtypes.

true

boolean

maxNodeIdsPerRequest (producer)

The maximum number of nodes that one Browse request asks for, when a recursive browse goes down to the next level. Default value notice: Maximum number of node ids requested per browse call (applies to browsing sub-types only; only if recursive = true).

10

int

node (producer)

The node ID of the node to browse from, for example ns=2;s=folder. The CamelMiloNodeIds header replaces this option. The default is the Root folder, i=84. Default value notice: Root folder as per OPC-UA spec.

ns=0;id=84

String

nodeClasses (producer)

A comma-separated list of the node classes of the nodes to return, as names of org.eclipse.milo.opcua.stack.core.types.enumerated.NodeClass: Object, Variable, Method, ObjectType, VariableType, ReferenceType, DataType and View. Default value notice: Comma-separated node class list; see org.eclipse.milo.opcua.stack.core.types.enumerated.NodeClass.

Variable,Object,DataType

String

recursive (producer)

Whether to browse the nodes that are found again, down to the level of the depth option. A recursive browse always includes the subtypes of the reference type, whatever includeSubTypes says. Default value notice: Whether to recursively browse sub-types: true|false.

false

boolean

lazyStartProducer (producer (advanced))

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

allowedSecurityPolicies (client)

A comma-separated list of the security policies that the client may use, as URIs or as names of org.eclipse.milo.opcua.stack.core.security.SecurityPolicy, for example Basic256Sha256. Of the endpoints of the server with an allowed policy, the client uses the one with the highest security level. If not set, every policy is allowed, None included.

String

applicationName (client)

The application name of the client, which it sends to the server in its application description.

Apache Camel adapter for Eclipse Milo

String

applicationUri (client)

The application URI of the client, which it sends to the server in its application description. With a client certificate, it should match the application URI in that certificate.

http://camel.apache.org/EclipseMilo/Client

String

channelLifetime (client)

The requested lifetime in milliseconds of the security token of the secure channel, after which the client renews it. If not set, the default of Eclipse Milo is used.

Long

keyAlias (client)

The alias of the private key and its certificate in the key store. It can be omitted when the key store holds a single entry.

String

keyPassword (client)

The password of the private key of keyAlias in the key store.

String

keyStorePassword (client)

The password of the key store of keyStoreUrl.

String

keyStoreType (client)

The type of the key store of keyStoreUrl, as a java.security.KeyStore type. The default is PKCS12.

String

keyStoreUrl (client)

The URL of the key store with the certificate and the private key of the client, for example file:/etc/opcua/client.p12. A security policy other than None needs it.

String

maxPendingPublishRequests (client)

The maximum number of publish requests that the client keeps pending at the server for its subscription. If not set, the default of Eclipse Milo is used.

Long

maxResponseMessageSize (client)

The maximum size in bytes of a response message that the client accepts from the server. If not set, the default of Eclipse Milo is used.

Long

overrideHost (client)

Whether to replace the host of the endpoint URL that the server reports with the host of the endpoint URI. Use it when the server reports a host name that the client cannot reach.

false

boolean

overridePort (client)

Whether to replace the port of the endpoint URL that the server reports with the port of the endpoint URI. Use it when the server reports a port that the client cannot reach.

false

boolean

productUri (client)

The product URI of the client, which it sends to the server in its application description.

http://camel.apache.org/EclipseMilo

String

reconnectTimeout (client)

The delay in milliseconds before the client tries again to connect to the server after an attempt failed, and between two attempts to create the monitored items that the server refused. Neither attempt is made while the OPC UA client recovers a lost session on its own.

10000

long

requestedPublishingInterval (client)

The publishing interval in milliseconds that the client requests for the subscription of its connection, which carries the values of the monitored nodes. Endpoints with different values use different connections.

1_000.0

Double

requestTimeout (client)

The timeout in milliseconds of a request to the server. If not set, the default of Eclipse Milo is used.

Long

sessionName (client)

The name of the session that the client creates on the server. If not set, Eclipse Milo generates one.

String

sessionTimeout (client)

The requested timeout in milliseconds of the session, after which the server closes a session without activity. If not set, the default of Eclipse Milo is used.

Long

certificateValidator (security)

A custom validator for the certificate of the OPC UA server. When set, it is used instead of the trust list configured with trustListDirectory. Endpoints share a connection only when they use the same validator instance.

CertificateValidator

password (security)

The password for authentication. Use this instead of embedding credentials in the endpoint URI when the password contains special characters (such as ?, /, , &).

String

trustAllCertificates (security)

Whether to accept any certificate presented by the OPC UA server. This is insecure: the connection is encrypted, but the client does not authenticate the server it talks to. It only applies when neither certificateValidator nor trustListDirectory is configured.

false

boolean

trustListDirectory (security)

The directory holding the trust list used to validate the certificate of the OPC UA server, in the layout used by Eclipse Milo: trusted certificates in trusted/certs, CRLs of trusted certificates in trusted/crl, certificates of issuing CAs in issuer/certs and their CRLs in issuer/crl. The directories are created if they do not exist. Besides the chain of trust, the validity period, the revocation by a CRL of the trust list and the application URI of the server certificate are checked. A certificate issued by a CA is refused when the trust list holds no CRL of that CA; an empty CRL is enough. A server certificate that does not chain up to a trusted certificate is written to rejected/certs, from where it can be moved to trusted/certs once it has been checked.

String

username (security)

The username for authentication. Use this instead of embedding credentials in the endpoint URI when the username contains special characters (such as ?, /, , &).

String

Message Headers

The OPC UA Browser component supports the following message header(s), which is/are listed below:

Name Description Default Type

CamelMiloNodeIds (producer)

Constant: HEADER_NODE_IDS

A List of node IDs. The milo-client producer reads the values of these nodes instead of writing the body. The milo-browse producer browses from these nodes instead of the node option, and sets the header to the List of the node IDs that it found.

List

Message Body

The message body at each side of the OPC UA Browser component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.

Side Body Description

Producer input

any

The body is not read: the nodes to browse are the node IDs of the CamelMiloNodeIds header, or else the node option.

Producer output

map

A Map of the browsed ExpandedNodeId to its Milo BrowseResult; the node IDs found are also in the CamelMiloNodeIds header, as a List of Strings for the milo-client producer.

The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.

Client

The browse component shares the same base options like the Camel Milo Client component, e.g. concerning topics like discovery, security policies, the validation of the server certificate, the construction of node ids, etc.

Please refer to the documentation of the Camel Milo Client component for further details.

Browsing

The main use of this component is to be able to determine the nodes values to be retrieved or to be written by first browsing the node tree of the OPC-UA server, e.g. to avoid hard-coding a significant number of node ids within the configuration of Camel routes. The component is designed to work in conjunction with the Camel Milo Client component as illustrated in the following example:

Java-only: browsing OPC UA nodes and enriching with client values
from("direct:start")

    // Browse sub tree
    .setHeader("CamelMiloNodeIds", constant(Arrays.asList("ns=1;s=folder-id")))
    .enrich("milo-browse:opc.tcp://localhost:4334", (oldExchange, newExchange) -> newExchange)

    // Filter specific ids
    .filter(...)

        // Retrieve the values for the nodes of interest
        .enrich("milo-client:opc.tcp://localhost:4334", (oldExchange, newExchange) -> newExchange)

In YAML, the browse result can go straight to the client. The browse producer sets the CamelMiloNodeIds header to the node IDs it found, and that is the header the milo-client producer reads. defaultAwaitWrites makes the client wait for the values, so the next step has them in the body. This route reads the values of the items of the OPC UA Server example:

- route:
    from:
      uri: direct:start
      steps:
        - setHeader:
            name: CamelMiloNodeIds
            expression:
              groovy:
                expression: "['nsu=urn:org:apache:camel;s=items']"
        - to:
            uri: milo-browse:opc.tcp://localhost:12685
            parameters:
              username: camel
              password: secret
              allowedSecurityPolicies: None
        - to:
            uri: milo-client:opc.tcp://localhost:12685
            parameters:
              username: camel
              password: secret
              allowedSecurityPolicies: None
              defaultAwaitWrites: true
        - log:
            message: "Values: ${body}"

Recursion

Dependent to the OPC-UA server there it might be required to browse a hierarchy of nodes. Be aware that this is potentially a very expensive operation.

Milo 1.0.5 Migration Notes

With Milo 1.0.5, the browse API remains largely compatible, but shares the same security-related changes as the client and server components. Please refer to the Milo Client documentation for details on security configuration changes.