OPC UA with Apache Camel

Apache Camel 2.19.0 is close to is release and the OPC UA component called “camel-milo” will be part of it. This is my Eclipse Milo backed component which was previously hosted in my personal GitHub repository ctron/de.dentrassi.camel.milo. It now got accepted into Apache Camel and will be part of the 2.19.0 release. As there are already a release candidates available, I think it is a great time to give a short introduction.

In a nutshell OPC UA is an industrial IoT communication protocol for acquiring telemetry data and command and control of industrial grade automation systems. It is also known as IEC 62541.

The Camel Milo component offers both an OPC UA client (milo-client) and server (milo-server) endpoint.

Running an OPC UA server

The following Camel example is based on Camel Blueprint and provides some random data over OPC UA, acting as a server:

Example project layout
Example project layout

The blueprint configuration would be:

And adding the following Maven build configuration:

This allows you to simply run the OPC UA server with:

Afterwards you can connect with the OPC UA client of your choice and subscribe to the item test-item, receiving that random number.

Release candidate

As this is currently the release candidate of Camel 2.19.0, it is necessary to add the release candidate Maven repository to the pom.xml. I did omit
this in the example above, as this will no longer be necessary when Camel 2.19.0 is released:

It may also be that the URLs (marked above) will change as a new release candidate gets built. In this case it is necessary that you update the URLs to the appropriate
repository URL.

What’s next?

Once Camel 2.19.0 is released, I will also mark my old, personal GitHub repository as deprecated and point people towards this new component.

And of course I am happy to get some feedback and suggestions.

One Reply to “OPC UA with Apache Camel”

  1. Hi Jens,

    I tried the above while also using a milo-client endpoint to test communication but I never receive anything on the client. Am I doing something wrong?

    Routes below:

    hello ${random(0,100)}

    15:00:03.833 INFO {main} [o.e.m.opcua.sdk.server.NamespaceManager] : added namespace index=0, uri=http://opcfoundation.org/UA/
    15:00:03.843 INFO {main} [o.e.m.opcua.sdk.server.NamespaceManager] : registered and added namespace index=1, uri=urn:org:apache:camel:milo:server
    15:00:04.053 INFO {main} [o.e.milo.opcua.sdk.server.OpcUaServer] : Binding endpoint opc.tcp://srinivaska-laptop:12685 to [None/None]
    15:00:04.053 INFO {main} [o.e.milo.opcua.sdk.server.OpcUaServer] : Binding endpoint opc.tcp://srinivaska-laptop.cybage.com:12685 to [None/None]
    15:00:04.053 INFO {main} [o.e.milo.opcua.sdk.server.OpcUaServer] : Binding endpoint opc.tcp:// to [None/None]
    15:00:04.053 INFO {main} [o.e.milo.opcua.sdk.server.OpcUaServer] : Binding endpoint opc.tcp:// to [None/None]
    15:00:04.053 INFO {main} [o.e.milo.opcua.sdk.server.OpcUaServer] : Binding endpoint opc.tcp:// to [None/None]
    15:00:04.083 INFO {main} [o.e.milo.opcua.sdk.server.OpcUaServer] : eclipse milo opc-ua stack version: 0.1.0
    15:00:04.083 INFO {main} [o.e.milo.opcua.sdk.server.OpcUaServer] : eclipse milo opc-ua sdk version: 0.1.0
    15:00:04.093 INFO {main} [o.e.m.opcua.sdk.server.NamespaceManager] : registered and added namespace index=2, uri=urn:org:apache:camel
    15:00:04.693 INFO {ua-netty-event-loop-0} [o.e.m.o.s.server.tcp.UaTcpStackServer] : opc.tcp:// bound to [None/None]
    15:00:04.703 INFO {ua-netty-event-loop-0} [o.e.m.o.s.server.tcp.UaTcpStackServer] : opc.tcp:// bound to [None/None]
    15:00:04.703 INFO {ua-netty-event-loop-0} [o.e.m.o.s.server.tcp.UaTcpStackServer] : opc.tcp:// bound to [None/None]
    15:00:04.703 INFO {ua-netty-event-loop-0} [o.e.m.o.s.server.tcp.UaTcpStackServer] : opc.tcp://srinivaska-laptop.cybage.com:12685 bound to [None/None]
    15:00:04.703 INFO {ua-netty-event-loop-0} [o.e.m.o.s.server.tcp.UaTcpStackServer] : opc.tcp://srinivaska-laptop:12685 bound to [None/None]
    15:00:04.723 INFO {main} [o.a.c.c.milo.client.MiloClientComponent] : Cache miss – creating new connection instance: tcp://localhost:12685
    15:00:05.479 INFO {main} [o.apache.camel.spring.SpringCamelContext] : StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
    15:00:06.023 INFO {main} [o.apache.camel.spring.SpringCamelContext] : Route: route1 started and consuming from: timer://test
    15:00:06.023 INFO {main} [o.a.c.c.m.c.internal.SubscriptionManager] : Starting connect
    15:00:08.191 INFO {main} [o.apache.camel.spring.SpringCamelContext] : Route: route2 started and consuming from: milo-client://tcp://localhost:12685?node=RAW(nsu=urn:org:apache:camel;s=test-item)

Leave a Reply

Your email address will not be published. Required fields are marked *