Chapter 220. OPC UA Client Component
Available as of Camel version 2.19
The Milo Client component provides access to OPC UA servers using the Eclipse Milo™ implementation.
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>
The OPC UA Client component supports 6 options which are listed below.
Name | Description | Default | Type |
---|---|---|---|
defaultConfiguration (common) | All default options for client | MiloClientConfiguration | |
applicationName (common) | Default application name | String | |
applicationUri (common) | Default application URI | String | |
productUri (common) | Default product URI | String | |
reconnectTimeout (common) | Default reconnect timeout | Long | |
resolveProperty Placeholders (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean |
220.1. URI format
The URI syntax of the endpoint is:
milo-client:tcp://[user:password@]host:port/path/to/service?node=RAW(nsu=urn:foo:bar;s=item-1)
If the server does not use a path, then it is possible to simply omit it:
milo-client:tcp://[user:password@]host:port?node=RAW(nsu=urn:foo:bar;s=item-1)
If no user credentials are provided the client will switch to anonymous mode.
220.2. URI options
All configuration options in the group client are applicable to the shared client instance. Endpoints will share client instances for each endpoint URI. So the first time a request for that endpoint URI is made, the options of the client group are applied. All further instances will be ignored.
If you need alternate options for the same endpoint URI it is possible though to set the clientId option which will by added internally to the endpoint URI in order to select a different shared connection instance. In other words, shared connections located by the combination of endpoint URI and client id.
The OPC UA Client endpoint is configured using URI syntax:
milo-client:endpointUri
with the following path and query parameters:
220.2.1. Path Parameters (1 parameters):
Name | Description | Default | Type |
---|---|---|---|
endpointUri | Required The OPC UA server endpoint | String |
220.2.2. Query Parameters (24 parameters):
Name | Description | Default | Type |
---|---|---|---|
clientId (common) | A virtual client id to force the creation of a new connection instance | String | |
defaultAwaitWrites (common) | Default await setting for writes | false | boolean |
node (common) | The node definition (see Node ID) | ExpandedNodeId | |
samplingInterval (common) | The sampling interval in milliseconds | Double | |
bridgeErrorHandler (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean |
exceptionHandler (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | ExceptionHandler | |
exchangePattern (consumer) | Sets the exchange pattern when the consumer creates an exchange. | ExchangePattern | |
synchronous (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean |
allowedSecurityPolicies (client) | A set of allowed security policy URIs. Default is to accept all and use the highest. | String | |
applicationName (client) | The application name | Apache Camel adapter for Eclipse Milo | String |
applicationUri (client) | The application URI | String | |
channelLifetime (client) | Channel lifetime in milliseconds | Long | |
keyAlias (client) | The name of the key in the keystore file | String | |
keyPassword (client) | The key password | String | |
keyStorePassword (client) | The keystore password | String | |
keyStoreType (client) | The key store type | String | |
keyStoreUrl (client) | The URL where the key should be loaded from | URL | |
maxPendingPublishRequests (client) | The maximum number of pending publish requests | Long | |
maxResponseMessageSize (client) | The maximum number of bytes a response message may have | Long | |
overrideHost (client) | Override the server reported endpoint host with the host from the endpoint URI. | false | boolean |
productUri (client) | The product URI | String | |
requestTimeout (client) | Request timeout in milliseconds | Long | |
sessionName (client) | Session name | String | |
sessionTimeout (client) | Session timeout in milliseconds | Long |
220.2.3. Node ID
In order to define a target node a namespace and node id is required. In previous versions this was possible by specifying nodeId
and either namespaceUri
or namespaceIndex
. However this only allowed for using string based node IDs. And while this configuration is still possible, the newer one is preferred.
The new approach is to specify a full namespace+node ID in the format ns=1;i=1
which also allows to use the other node ID formats (like numeric, GUID/UUID or opaque). If the node
parameter is used the older ones must not be used. The syntax of this node format is a set of key=value
pairs delimited by a semi-colon (;
).
Exactly one namespace and one node id key must be used. See the following table for possible keys:
Key | Type | Description |
---|---|---|
ns | namespace | Numeric namespace index |
nsu | namespace | Namespace URI |
s | node | String node ID |
i | node | Numeric node ID |
g | node | GUID/UUID node ID |
b | node | Base64 encoded string for opaque node ID |
As the values generated by the syntax cannot be transparently encoded into a URI parameter value, it is necessary to escape them. However Camel allows to wrap the actual value inside RAW(…)
, which makes escaping unnecessary. For example:
milo-client://user:password@localhost:12345?node=RAW(nsu=http://foo.bar;s=foo/bar)
220.2.4. Security policies
When setting the allowing security policies is it possible to use the well known OPC UA URIs (e.g. http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15
) or to use the Milo enum literals (e.g. None
). Specifying an unknown security policy URI or enum is an error.
The known security policy URIs and enum literals are can be seen here: SecurityPolicy.java
Note: In any case security policies are considered case sensitive.
220.3. See Also
- Configuring Camel
- Component
- Endpoint
- Getting Started