Search code examples
javaapache-camelmilo

Write to Apache Camel OPC UA Server fails, but returns good StatusCode


I'm developing an Apache Camel route that should create a OPC UA Server with three variables. The route should also initialize these three values.

I tried doing this the way it's described in the official Apache Camel documentation. I can connect to the server with any OPC UA client and see the values.

This is the code for my route:

<route id="opcuaserver">
  <from uri="timer://runOnce?repeatCount=1&amp;delay=5000"/>
  <to uri="milo-server:velocity"/>
  <to uri="milo-server:laufmeter"/>
  <to uri="milo-server:lfm_reset"/>

  <!-- INITIALIZE OPCUA SERVER VARIABLES -->
  <setHeader headerName="serverUrl">
    <simple>opc.tcp://NBTC363:12685</simple>
  </setHeader>
  <setBody>
    <simple>
      ns=2;s=items-velocity?0
      ns=2;s=items-laufmeter?0
      ns=2;s=items-lfm_reset?0
    </simple>
  </setBody>
  <bean ref="OpcuaBean" method="doWriteOneOrMany"/>
  <log message="${body}"/>
  <to uri="mock:opcuaInitResult"/>
</route>

The information in the header and the body get processed by my bean into a connection to the server and a list of node ids and their desired values. This list is then used to finally write the desired values to the server. After the write process is finished, the bean writes the resulting StatusCodes in the camel log.

The result I expected is a successful write to the server, with a StatusCode message such as this:

[StatusCode{name=Good, value=0, quality=good}

But actually, the value on the server continues to be null with a datatype of null, resulting in this StatusCode:

[StatusCode{name=Good, value=0x00000000, quality=good}

I know that this indicates that I've done everything correctly on the client side, so I'm wondering if I did something wrong on the server-side. I followed the examples of the camel opc server component and can't find any options or parameters that look useful to me in this issue.


Solution

  • The issue was that I didn't use the camel-milo component correctly. Apparantly you can just do

    <to uri="milo-server:yourTag"/>
    

    To write to your OPC UA Server.