You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by marcello cappelli <kc...@gmail.com> on 2021/05/28 06:00:56 UTC

Methods in OPC-UA Apache-Camel Milo Client

A few months ago I started working on a project that requires the integration of OPC / UA to communicate with an automatic machine. Working with SpringBoot I looked for a library that was well integrated with this framework and in several posts and thesis I found Eclipse Milo, but in the version integrated with Apache Camel. Not knowing either Camel or Milo, I had to study both at least. Camel has a huge documentation, while the integration with Milo is limited to the parameterization and configuration of the Nodes to perform the reading and writing. That said it seems more than enough but in reality, since there are no specific examples, I had to search for posts several times to understand where I was wrong and clearly it took a lot of time. I find it normal to study and experiment but you know very well how urgent the deliveries we have as developers are and we don't always have free days to devote to research and testing. Now for example, I was able to run the reads and writes co
 rrectly while the function calls have a strange behavior, that is, every time I call the test function, the value that is returned to me is the parameter that I give in input, even if, enabling the TRACE on Camel and Milo I see that the function is called correctly and in the OutputArguments there is the result I expect but Camel keeps returning the InputArguments. It's certainly my mistake but I can't find anything to help me understand where I'm wrong. No example, no similar case, nothing at all, so I wondered if the choice I made is the right one and if someone can give me some advice because I don't know what else to try. 

Here the test simplified code I'm trying to do:
```
Variant[] params = new Variant[1];
params[0] = new Variant(13);

String  endpointUri = "milo-client:opc.tcp://milo.digitalpetri.com:62541/milo?node=RAW(ns=2;s=Methods)"&method=RAW(ns=2;s=Methods/sqrt(x))";
return producerTemplate.requestBody(endpointUri, params, "await", true, Variant.class);
```

The returned object is the same as I input, even if looking at the log I see that the function call is executed correctly:
```
 2021-mag-20 11:14:07.613 TRACE [milo-netty-event-loop-1] o.e.m.o.s.c.t.t.OpcTcpTransport - Write succeeded for request=PublishRequest, requestHandle=16
 2021-mag-20 11:14:07.598 DEBUG [milo-shared-thread-pool-1] o.a.c.c.m.c.i.SubscriptionManager - Call to node=ExpandedNodeId{ns=2, id=Methods, serverIndex=0}, method=ExpandedNodeId{ns=2, id=Methods/sqrt(x), serverIndex=0} = [Variant{value=13.0}]-> CallMethodResult{StatusCode=StatusCode{name=Good, value=0x00000000, quality=good}, InputArgumentResults=[StatusCode{name=Good, value=0x00000000, quality=good}], InputArgumentDiagnosticInfos=[], OutputArguments=[Variant{value=3.605551275463989}]}
```

This are my dependencies :
```
<dependency>
  <groupId>org.apache.camel.springboot</groupId>
  <artifactId>camel-spring-boot-starter</artifactId>
  <version>3.9.0</version>
</dependency>        
<dependency>
  <groupId>org.apache.camel.springboot</groupId>
  <artifactId>camel-milo-starter</artifactId>
  <version>3.9.0</version>
</dependency> 
```

Can someone help me? 
Many thanks

Re: Methods in OPC-UA Apache-Camel Milo Client

Posted by marcello cappelli <kc...@gmail.com>.
Sorry Claus,
do you have some news ?

Thanks
Marcello

On 2021/06/03 04:31:34, Claus Ibsen <cl...@gmail.com> wrote: 
> On Wed, Jun 2, 2021 at 10:57 PM marcello cappelli <kc...@gmail.com> wrote:
> >
> > Thank you so much for your support.
> > Unfortunately the result is the same.
> >
> > I don't understand where the answer gets lost.
> > By enabling the trace, I see that the method is executed and returns the result but Camel does not return it. I don't understand where I'm wrong
> >
> 
> Can you tell us where in the source code you see the method executed
> and the result coming back?
> And maybe can you look at the unit tests and see if you can add a new
> test for your use-case (or something close enough to trigger that
> method)
> so we can use that to track down and fix the bug.
> 
> > On 2021/06/02 04:21:39, Claus Ibsen <cl...@gmail.com> wrote:
> > > Try without the result type class parameter, and just get the object
> > > as output and see what it looks like
> > >
> > > On Tue, Jun 1, 2021 at 10:20 PM marcello cappelli <kc...@gmail.com> wrote:
> > > >
> > > > Hi,
> > > > I get the same behavior even so:
> > > >
> > > > String  endpointUri     = "milo-client:opc.tcp://milo.digitalpetri.com:62541/milo?node=RAW(ns=2;s=Methods)&method=RAW(ns=2;s=Methods/sqrt(x))&defaultAwaitWrites=true&overrideHost=true";
> > > >
> > > > Variant[] inputArguments  = new Variant[1];
> > > > inputArguments[0] = new Variant((double) 25);
> > > >
> > > > Variant[] outputArguments = isoProducerTemplate.requestBody(endpointUri, inputArguments, Variant[].class);
> > > >
> > > > The response should be a 1 element variant array with the result
> > > >
> > >
> > >
> > > --
> > > Claus Ibsen
> > > -----------------
> > > http://davsclaus.com @davsclaus
> > > Camel in Action 2: https://www.manning.com/ibsen2
> > >
> 
> 
> 
> -- 
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
> 

Re: Methods in OPC-UA Apache-Camel Milo Client

Posted by marcello cappelli <kc...@gmail.com>.
Hi,
First of all the test code, next the logging messages :
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
package com.someco.hmi;

import org.apache.camel.ProducerTemplate;
import org.apache.camel.spring.SpringCamelContext;
import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
import org.eclipse.milo.opcua.stack.core.types.builtin.Variant;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;

@SpringBootTest
@CamelSpringBootTest
class SomecoHmiApplicationTests {
    
    @Autowired
    private ApplicationContext context;
    
	@Test
    public void test() throws Exception {

        System.out.println("START CAMEL-MILO TEST");
        
        SpringCamelContext camelContext = context.getBean(SpringCamelContext.class); 
        
        if( camelContext != null )
        {
            ProducerTemplate producerTemplate  = camelContext.createProducerTemplate();
            
            if( producerTemplate != null )
            {
                String    endpointUri     = "milo-client:opc.tcp://milo.digitalpetri.com:62541/milo?node=RAW(ns=2;s=Methods)&method=RAW(ns=2;s=Methods/sqrt(x))&defaultAwaitWrites=true&overrideHost=true";
                Variant[] inputArguments  = new Variant[1];

                inputArguments[0] = new Variant((double) 25);     

                Variant[] outputArguments = (Variant[]) producerTemplate.requestBody(endpointUri, inputArguments);

                if(outputArguments != null)
                    System.out.println("RESULT: " + outputArguments[0].getValue());
                else
                    System.out.println("ERROR: outputArguments is null");
            }
            else
                System.out.println("ERROR: ProducerTemplateunavailable");              
        }
        else
            System.out.println("ERROR: SpringCamelContext unavailable");
    }
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////

This is the part where you see the call with the right result and what I am getting :

 2021-giu-03 09:55:35.886 DEBUG [milo-shared-thread-pool-0] o.a.c.c.m.c.i.SubscriptionManager - Call to node=ExpandedNodeId{ns=2, id=Methods, serverIndex=0}, method=ExpandedNodeId{ns=2, id=Methods/sqrt(x), serverIndex=0} = [Variant{value=25.0}]-> CallMethodResult{StatusCode=StatusCode{name=Good, value=0x00000000, quality=good}, InputArgumentResults=[StatusCode{name=Good, value=0x00000000, quality=good}], InputArgumentDiagnosticInfos=[], OutputArguments=[Variant{value=5.0}]}
 2021-giu-03 09:55:35.900 TRACE [milo-shared-scheduled-executor-0] o.a.c.i.e.DefaultUnitOfWork - UnitOfWork done for ExchangeId: AEF410B0B195C6B-0000000000000001 with Exchange[AEF410B0B195C6B-0000000000000001]
 2021-giu-03 09:55:35.900 TRACE [milo-shared-scheduled-executor-0] o.a.c.i.e.DefaultReactiveExecutor - Schedule [first=false, main=false, sync=false]: org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager$$Lambda$1825/0x0000000801db8c40@22097b90
 2021-giu-03 09:55:35.900 TRACE [milo-shared-scheduled-executor-0] o.a.c.i.e.DefaultReactiveExecutor - Worker #2 running: org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager$$Lambda$1825/0x0000000801db8c40@22097b90
 2021-giu-03 09:55:35.900 TRACE [milo-shared-scheduled-executor-0] o.a.c.i.e.DefaultAsyncProcessorAwaitManager - Asynchronous callback received for exchangeId: AEF410B0B195C6B-0000000000000001
 2021-giu-03 09:55:35.900 TRACE [main] o.a.c.i.e.DefaultAsyncProcessorAwaitManager - Asynchronous callback received, will continue routing exchangeId: AEF410B0B195C6B-0000000000000001 -> Exchange[AEF410B0B195C6B-0000000000000001]
 2021-giu-03 09:55:35.900 TRACE [main] o.a.c.s.c.ServicePool - Released service: Producer[milo-client://opc.tcp://milo.digitalpetri.com:62541/milo?defaultAwaitWrites=true&method=RAW(ns=2;s=Methods/sqrt(x))&node=RAW(ns=2;s=Methods)&overrideHost=true]
 RESULT: 25.0

//////////////////////////////////////////////////////////////////////////////////////////////////////////////

This is the full log:

 2021-giu-03 09:55:33.053 DEBUG [milo-netty-event-loop-0] o.e.m.o.s.c.ChannelFsm - [0] channelInactive() local=/10.211.55.5:55802, remote=milo.digitalpetri.com/134.209.49.44:62541
 2021-giu-03 09:55:33.053 DEBUG [milo-shared-thread-pool-0] o.e.m.o.s.c.ChannelFsm - [0] S(Disconnecting)         x E(DisconnectSuccess)     = S'(NotConnected)        
 2021-giu-03 09:55:33.065 INFO  [main] o.e.m.o.s.c.OpcUaClient - Eclipse Milo OPC UA Stack version: 0.3.7
 2021-giu-03 09:55:33.065 INFO  [main] o.e.m.o.s.c.OpcUaClient - Eclipse Milo OPC UA Client SDK version: 0.3.7
 2021-giu-03 09:55:33.127 DEBUG [main] o.e.m.o.s.c.OpcUaClient - Added ServiceFaultListener: org.eclipse.milo.opcua.sdk.client.session.SessionFsmFactory$SessionFaultListener@39f9c6f5
 2021-giu-03 09:55:33.160 DEBUG [main] o.e.m.o.s.c.OpcUaClient - Added SessionActivityListener: org.eclipse.milo.opcua.sdk.client.subscriptions.OpcUaSubscriptionManager$1@5ac1ba35
 2021-giu-03 09:55:33.401 DEBUG [milo-shared-thread-pool-0] o.e.m.o.s.c.ChannelFsm - [1] S(NotConnected)          x E(Connect)               = S'(Connecting)          
 2021-giu-03 09:55:33.589 DEBUG [milo-netty-event-loop-1] o.e.m.o.s.c.t.u.UascClientAcknowledgeHandler - Sent Hello message on channel=[id: 0xf680c22c, L:/10.211.55.5:55803 - R:milo.digitalpetri.com/134.209.49.44:62541].
 2021-giu-03 09:55:33.762 DEBUG [milo-netty-event-loop-1] o.e.m.o.s.c.t.u.UascClientAcknowledgeHandler - Received Acknowledge message on channel=[id: 0xf680c22c, L:/10.211.55.5:55803 - R:milo.digitalpetri.com/134.209.49.44:62541].
 2021-giu-03 09:55:33.777 DEBUG [milo-netty-event-loop-1] o.e.m.o.s.c.t.u.UascClientMessageHandler - OpenSecureChannel timeout scheduled for +60000ms
 2021-giu-03 09:55:33.777 DEBUG [milo-shared-thread-pool-2] o.e.m.o.s.c.t.u.UascClientMessageHandler - Sent OpenSecureChannelRequest (Issue, id=0, currentToken=-1, previousToken=-1).
 2021-giu-03 09:55:33.954 DEBUG [milo-netty-event-loop-1] o.e.m.o.s.c.t.u.UascClientMessageHandler - OpenSecureChannel timeout canceled
 2021-giu-03 09:55:33.954 DEBUG [milo-shared-thread-pool-2] o.e.m.o.s.c.t.u.UascClientMessageHandler - Received OpenSecureChannelResponse.
 2021-giu-03 09:55:33.954 DEBUG [milo-shared-thread-pool-2] o.e.m.o.s.c.t.u.UascClientMessageHandler - SecureChannel id=3162, currentTokenId=6572, previousTokenId=-1, lifetime=3600000ms, createdAt=DateTime{utcTime=132671805340000000, javaDate=Thu Jun 03 09:55:34 CEST 2021}
 2021-giu-03 09:55:33.954 DEBUG [milo-netty-event-loop-1] o.e.m.o.s.c.t.u.UascClientMessageHandler - 0 message(s) queued before handshake completed; sending now.
 2021-giu-03 09:55:33.954 DEBUG [milo-shared-thread-pool-0] o.e.m.o.s.c.ChannelFsm - [1] S(Connecting)            x E(ConnectSuccess)        = S'(Connected)           
 2021-giu-03 09:55:33.954 DEBUG [milo-shared-thread-pool-2] o.e.m.o.s.c.SessionFsm - [2] S(Inactive)              x E(OpenSession)           = S'(Creating)            
 2021-giu-03 09:55:33.954 DEBUG [milo-shared-thread-pool-2] o.e.m.o.s.c.SessionFsm - [2] Sending CreateSessionRequest...
 2021-giu-03 09:55:34.161 DEBUG [milo-shared-thread-pool-2] o.e.m.o.s.c.SessionFsm - [2] CreateSession succeeded: NodeId{ns=1, id=Session:7b74a8c5-b138-4bca-8be9-83f44e2c62c2}
 2021-giu-03 09:55:34.161 DEBUG [milo-shared-thread-pool-0] o.e.m.o.s.c.SessionFsm - [2] S(Creating)              x E(CreateSessionSuccess)  = S'(Activating)          
 2021-giu-03 09:55:34.161 DEBUG [milo-shared-thread-pool-0] o.e.m.o.s.c.SessionFsm - [2] Sending ActivateSessionRequest...
 2021-giu-03 09:55:34.354 DEBUG [milo-shared-thread-pool-0] o.e.m.o.s.c.SessionFsm - [2] Session activated: OpcUaSession{sessionId=NodeId{ns=1, id=Session:7b74a8c5-b138-4bca-8be9-83f44e2c62c2}, sessionName=UaSession:Apache Camel adapter for Eclipse Milo:1622706934354}
 2021-giu-03 09:55:34.354 DEBUG [milo-shared-thread-pool-2] o.e.m.o.s.c.SessionFsm - [2] S(Activating)            x E(ActivateSessionSuccess) = S'(Transferring)        
 2021-giu-03 09:55:34.354 DEBUG [milo-shared-thread-pool-2] o.e.m.o.s.c.SessionFsm - [2] TransferSubscriptions succeeded
 2021-giu-03 09:55:34.354 DEBUG [milo-shared-thread-pool-0] o.e.m.o.s.c.SessionFsm - [2] S(Transferring)          x E(TransferSubscriptionsSuccess) = S'(Initializing)        
 2021-giu-03 09:55:34.354 DEBUG [milo-shared-thread-pool-0] o.e.m.o.s.c.OpcUaClient - SessionInitializer: DataTypeDictionary
 2021-giu-03 09:55:34.368 DEBUG [milo-shared-thread-pool-0] o.e.m.o.s.c.OpcUaClient - SessionInitializer: NamespaceTable
 2021-giu-03 09:55:34.540 DEBUG [milo-shared-thread-pool-2] o.e.m.o.s.c.DataTypeDictionaryReader - Browse finished with 2 references
 2021-giu-03 09:55:34.540 DEBUG [milo-shared-thread-pool-2] o.e.m.o.s.c.DataTypeDictionaryReader - Reading DataTypeDictionary nodeId=NodeId{ns=2, id=urn:eclipse:milo:opcua:server:demo}
 2021-giu-03 09:55:34.727 DEBUG [ForkJoinPool.commonPool-worker-3] o.e.m.o.s.c.DataTypeDictionaryReader - Dictionary XML: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<opc:TypeDictionary xmlns:opc="http://opcfoundation.org/BinarySchema/" TargetNamespace="urn:eclipse:milo:opcua:server:demo" DefaultByteOrder="LittleEndian">
    <opc:Import Namespace="http://opcfoundation.org/BinarySchema/"/>
    <opc:EnumeratedType LengthInBits="32" Name="CustomEnumType">
        <opc:EnumeratedValue Name="Field0" Value="0"/>
        <opc:EnumeratedValue Name="Field1" Value="1"/>
        <opc:EnumeratedValue Name="Field2" Value="2"/>
    </opc:EnumeratedType>
    <opc:StructuredType Name="CustomUnionType">
        <opc:Field Name="SwitchField" TypeName="opc:UInt32"/>
        <opc:Field Name="foo" TypeName="opc:UInt32" SwitchField="SwitchField" SwitchValue="1"/>
        <opc:Field Name="bar" TypeName="opc:String" SwitchField="SwitchField" SwitchValue="2"/>
    </opc:StructuredType>
    <opc:StructuredType Name="CustomStructType">
        <opc:Field Name="foo" TypeName="opc:String"/>
        <opc:Field Name="bar" TypeName="opc:UInt32"/>
        <opc:Field Name="baz" TypeName="opc:Boolean"/>
    </opc:StructuredType>
</opc:TypeDictionary>
 2021-giu-03 09:55:34.946 DEBUG [ForkJoinPool.commonPool-worker-3] o.e.m.o.b.GenericBsdParser - EnumeratedType: CustomEnumType
 2021-giu-03 09:55:34.946 DEBUG [ForkJoinPool.commonPool-worker-3] o.e.m.o.b.GenericBsdParser - StructuredType: CustomUnionType
 2021-giu-03 09:55:34.962 DEBUG [ForkJoinPool.commonPool-worker-3] o.e.m.o.b.GenericBsdParser - StructuredType: CustomStructType
 2021-giu-03 09:55:34.962 DEBUG [ForkJoinPool.commonPool-worker-3] o.e.m.o.s.c.DataTypeDictionaryReader - enumCodecs.size()=1
 2021-giu-03 09:55:34.962 DEBUG [ForkJoinPool.commonPool-worker-3] o.e.m.o.s.c.DataTypeDictionaryReader - structCodecs.size()=2
 2021-giu-03 09:55:35.138 DEBUG [milo-shared-thread-pool-0] o.e.m.o.s.c.DataTypeDictionaryReader - Browse finished with 2 references
 2021-giu-03 09:55:35.325 DEBUG [milo-shared-thread-pool-0] o.e.m.o.s.c.DataTypeDictionaryReader - Browse finished with 1 references
 2021-giu-03 09:55:35.325 DEBUG [milo-shared-thread-pool-0] o.e.m.o.s.c.DataTypeDictionaryReader - Browse finished with 1 references
 2021-giu-03 09:55:35.508 DEBUG [milo-shared-thread-pool-2] o.e.m.o.s.c.DataTypeDictionaryReader - Browse finished with 1 references
 2021-giu-03 09:55:35.508 DEBUG [milo-shared-thread-pool-2] o.e.m.o.s.c.DataTypeDictionaryReader - Browse finished with 1 references
 2021-giu-03 09:55:35.508 DEBUG [milo-shared-thread-pool-2] o.e.m.o.s.c.DataTypeDictionaryReader - Registered codec description=CustomUnionType dataTypeId=NodeId{ns=2, id=DataType.CustomUnionType} encodingId=NodeId{ns=2, id=DataType.CustomUnionType.BinaryEncoding}
 2021-giu-03 09:55:35.508 DEBUG [milo-shared-thread-pool-2] o.e.m.o.s.c.DataTypeDictionaryReader - Registered codec description=CustomStructType dataTypeId=NodeId{ns=2, id=DataType.CustomStructType} encodingId=NodeId{ns=2, id=DataType.CustomStructType.BinaryEncoding}
 2021-giu-03 09:55:35.508 DEBUG [milo-shared-thread-pool-2] o.e.m.o.s.c.SessionFsm - [2] Initialization succeeded: OpcUaSession{sessionId=NodeId{ns=1, id=Session:7b74a8c5-b138-4bca-8be9-83f44e2c62c2}, sessionName=UaSession:Apache Camel adapter for Eclipse Milo:1622706934354}
 2021-giu-03 09:55:35.508 DEBUG [milo-shared-thread-pool-0] o.e.m.o.s.c.SessionFsm - [2] S(Initializing)          x E(InitializeSuccess)     = S'(Active)              
 2021-giu-03 09:55:35.710 DEBUG [milo-shared-thread-pool-2] o.e.m.o.s.c.s.OpcUaSubscriptionManager - getTimeoutHint() maxKeepAlive=10000.0 maxPendingPublishes=2 timeoutHint=30000.0
 2021-giu-03 09:55:35.710 DEBUG [milo-shared-thread-pool-2] o.e.m.o.s.c.s.OpcUaSubscriptionManager - Sending PublishRequest, requestHandle=13, acknowledgements=[]
 2021-giu-03 09:55:35.710 DEBUG [milo-shared-thread-pool-2] o.e.m.o.s.c.s.OpcUaSubscriptionManager - getTimeoutHint() maxKeepAlive=10000.0 maxPendingPublishes=2 timeoutHint=30000.0
 2021-giu-03 09:55:35.710 DEBUG [milo-shared-thread-pool-2] o.e.m.o.s.c.s.OpcUaSubscriptionManager - Sending PublishRequest, requestHandle=14, acknowledgements=[]
 2021-giu-03 09:55:35.710 DEBUG [main] o.a.c.c.m.c.i.SubscriptionManager - Connect call done
 2021-giu-03 09:55:35.710 DEBUG [main] o.a.c.c.m.c.i.SubscriptionManager - Setting subscriptions: 0
 2021-giu-03 09:55:35.710 DEBUG [main] o.a.c.c.m.c.i.SubscriptionManager - Update state : null -> org.apache.camel.component.milo.client.internal.SubscriptionManager$Connected@355ea7fc
 2021-giu-03 09:55:35.710 TRACE [main] o.a.c.c.m.c.i.SubscriptionManager - Expanded Node Id: ExpandedNodeId{ns=2, id=Methods, serverIndex=0}
 2021-giu-03 09:55:35.710 TRACE [main] o.a.c.c.m.c.i.SubscriptionManager - Using provided index: 2
 2021-giu-03 09:55:35.710 DEBUG [main] o.a.c.c.m.c.i.SubscriptionManager - Node   - expanded: ExpandedNodeId{ns=2, id=Methods, serverIndex=0}, full: NodeId{ns=2, id=Methods}
 2021-giu-03 09:55:35.710 TRACE [main] o.a.c.c.m.c.i.SubscriptionManager - Expanded Node Id: ExpandedNodeId{ns=2, id=Methods/sqrt(x), serverIndex=0}
 2021-giu-03 09:55:35.710 TRACE [main] o.a.c.c.m.c.i.SubscriptionManager - Using provided index: 2
 2021-giu-03 09:55:35.710 DEBUG [main] o.a.c.c.m.c.i.SubscriptionManager - Method - expanded: ExpandedNodeId{ns=2, id=Methods/sqrt(x), serverIndex=0}, full: NodeId{ns=2, id=Methods/sqrt(x)}
 2021-giu-03 09:55:35.710 TRACE [main] o.a.c.i.e.SharedCamelInternalProcessor - Exchange processed and is continued routed asynchronously for exchangeId: AEF410B0B195C6B-0000000000000001 -> Exchange[AEF410B0B195C6B-0000000000000001]
 2021-giu-03 09:55:35.710 TRACE [main] o.a.c.i.e.DefaultAsyncProcessorAwaitManager - Waiting for asynchronous callback before continuing for exchangeId: AEF410B0B195C6B-0000000000000001 -> Exchange[AEF410B0B195C6B-0000000000000001]
 2021-giu-03 09:55:35.886 DEBUG [milo-shared-thread-pool-0] o.a.c.c.m.c.i.SubscriptionManager - Call to node=ExpandedNodeId{ns=2, id=Methods, serverIndex=0}, method=ExpandedNodeId{ns=2, id=Methods/sqrt(x), serverIndex=0} = [Variant{value=25.0}]-> CallMethodResult{StatusCode=StatusCode{name=Good, value=0x00000000, quality=good}, InputArgumentResults=[StatusCode{name=Good, value=0x00000000, quality=good}], InputArgumentDiagnosticInfos=[], OutputArguments=[Variant{value=5.0}]}
 2021-giu-03 09:55:35.900 TRACE [milo-shared-scheduled-executor-0] o.a.c.i.e.DefaultUnitOfWork - UnitOfWork done for ExchangeId: AEF410B0B195C6B-0000000000000001 with Exchange[AEF410B0B195C6B-0000000000000001]
 2021-giu-03 09:55:35.900 TRACE [milo-shared-scheduled-executor-0] o.a.c.i.e.DefaultReactiveExecutor - Schedule [first=false, main=false, sync=false]: org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager$$Lambda$1825/0x0000000801db8c40@22097b90
 2021-giu-03 09:55:35.900 TRACE [milo-shared-scheduled-executor-0] o.a.c.i.e.DefaultReactiveExecutor - Worker #2 running: org.apache.camel.impl.engine.DefaultAsyncProcessorAwaitManager$$Lambda$1825/0x0000000801db8c40@22097b90
 2021-giu-03 09:55:35.900 TRACE [milo-shared-scheduled-executor-0] o.a.c.i.e.DefaultAsyncProcessorAwaitManager - Asynchronous callback received for exchangeId: AEF410B0B195C6B-0000000000000001
 2021-giu-03 09:55:35.900 TRACE [main] o.a.c.i.e.DefaultAsyncProcessorAwaitManager - Asynchronous callback received, will continue routing exchangeId: AEF410B0B195C6B-0000000000000001 -> Exchange[AEF410B0B195C6B-0000000000000001]
 2021-giu-03 09:55:35.900 TRACE [main] o.a.c.s.c.ServicePool - Released service: Producer[milo-client://opc.tcp://milo.digitalpetri.com:62541/milo?defaultAwaitWrites=true&method=RAW(ns=2;s=Methods/sqrt(x))&node=RAW(ns=2;s=Methods)&overrideHost=true]
 RESULT: 25.0
2021-giu-03 09:55:35.916 DEBUG [main] o.a.c.s.SpringCamelContext - onApplicationEvent: org.springframework.test.context.event.AfterTestExecutionEvent[source=[DefaultTestContext@47a86fbb testClass = SomecoHmiApplicationTests, testInstance = com.someco.hmi.SomecoHmiApplicationTests@1ff4496, testMethod = test@SomecoHmiApplicationTests, testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@f478a81 testClass = SomecoHmiApplicationTests, locations = '{}', classes = '{class com.someco.hmi.SomecoHmiApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@475c9c31, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@5276d6ee, org.springframework.bo
 ot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@14bdbc74, org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@37313c65, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@21be3395, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@10b48321], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.populatedRequestContextHolder' -> true, 'org.springframework.te
 st.context.web.ServletTestExecutionListener.resetRequestContextHolder' -> true, 'org.springframework.test.context.event.ApplicationEventsTestExecutionListener.recordApplicationEvents' -> false]]]
 2021-giu-03 09:55:35.916 DEBUG [main] o.a.c.s.SpringCamelContext - onApplicationEvent: org.springframework.test.context.event.AfterTestMethodEvent[source=[DefaultTestContext@47a86fbb testClass = SomecoHmiApplicationTests, testInstance = com.someco.hmi.SomecoHmiApplicationTests@1ff4496, testMethod = test@SomecoHmiApplicationTests, testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@f478a81 testClass = SomecoHmiApplicationTests, locations = '{}', classes = '{class com.someco.hmi.SomecoHmiApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@475c9c31, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@5276d6ee, org.springframework.boot
 .test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@14bdbc74, org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@37313c65, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@21be3395, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@10b48321], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.populatedRequestContextHolder' -> true, 'org.springframework.test
 .context.web.ServletTestExecutionListener.resetRequestContextHolder' -> true, 'org.springframework.test.context.event.ApplicationEventsTestExecutionListener.recordApplicationEvents' -> false]]]

On 2021/06/03 04:31:34, Claus Ibsen <cl...@gmail.com> wrote: 
> On Wed, Jun 2, 2021 at 10:57 PM marcello cappelli <kc...@gmail.com> wrote:
> >
> > Thank you so much for your support.
> > Unfortunately the result is the same.
> >
> > I don't understand where the answer gets lost.
> > By enabling the trace, I see that the method is executed and returns the result but Camel does not return it. I don't understand where I'm wrong
> >
> 
> Can you tell us where in the source code you see the method executed
> and the result coming back?
> And maybe can you look at the unit tests and see if you can add a new
> test for your use-case (or something close enough to trigger that
> method)
> so we can use that to track down and fix the bug.
> 
> > On 2021/06/02 04:21:39, Claus Ibsen <cl...@gmail.com> wrote:
> > > Try without the result type class parameter, and just get the object
> > > as output and see what it looks like
> > >
> > > On Tue, Jun 1, 2021 at 10:20 PM marcello cappelli <kc...@gmail.com> wrote:
> > > >
> > > > Hi,
> > > > I get the same behavior even so:
> > > >
> > > > String  endpointUri     = "milo-client:opc.tcp://milo.digitalpetri.com:62541/milo?node=RAW(ns=2;s=Methods)&method=RAW(ns=2;s=Methods/sqrt(x))&defaultAwaitWrites=true&overrideHost=true";
> > > >
> > > > Variant[] inputArguments  = new Variant[1];
> > > > inputArguments[0] = new Variant((double) 25);
> > > >
> > > > Variant[] outputArguments = isoProducerTemplate.requestBody(endpointUri, inputArguments, Variant[].class);
> > > >
> > > > The response should be a 1 element variant array with the result
> > > >
> > >
> > >
> > > --
> > > Claus Ibsen
> > > -----------------
> > > http://davsclaus.com @davsclaus
> > > Camel in Action 2: https://www.manning.com/ibsen2
> > >
> 
> 
> 
> -- 
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
> 

Re: Methods in OPC-UA Apache-Camel Milo Client

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jun 2, 2021 at 10:57 PM marcello cappelli <kc...@gmail.com> wrote:
>
> Thank you so much for your support.
> Unfortunately the result is the same.
>
> I don't understand where the answer gets lost.
> By enabling the trace, I see that the method is executed and returns the result but Camel does not return it. I don't understand where I'm wrong
>

Can you tell us where in the source code you see the method executed
and the result coming back?
And maybe can you look at the unit tests and see if you can add a new
test for your use-case (or something close enough to trigger that
method)
so we can use that to track down and fix the bug.

> On 2021/06/02 04:21:39, Claus Ibsen <cl...@gmail.com> wrote:
> > Try without the result type class parameter, and just get the object
> > as output and see what it looks like
> >
> > On Tue, Jun 1, 2021 at 10:20 PM marcello cappelli <kc...@gmail.com> wrote:
> > >
> > > Hi,
> > > I get the same behavior even so:
> > >
> > > String  endpointUri     = "milo-client:opc.tcp://milo.digitalpetri.com:62541/milo?node=RAW(ns=2;s=Methods)&method=RAW(ns=2;s=Methods/sqrt(x))&defaultAwaitWrites=true&overrideHost=true";
> > >
> > > Variant[] inputArguments  = new Variant[1];
> > > inputArguments[0] = new Variant((double) 25);
> > >
> > > Variant[] outputArguments = isoProducerTemplate.requestBody(endpointUri, inputArguments, Variant[].class);
> > >
> > > The response should be a 1 element variant array with the result
> > >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > http://davsclaus.com @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
> >



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Methods in OPC-UA Apache-Camel Milo Client

Posted by marcello cappelli <kc...@gmail.com>.
Thank you so much for your support.
Unfortunately the result is the same.

I don't understand where the answer gets lost.
By enabling the trace, I see that the method is executed and returns the result but Camel does not return it. I don't understand where I'm wrong

On 2021/06/02 04:21:39, Claus Ibsen <cl...@gmail.com> wrote: 
> Try without the result type class parameter, and just get the object
> as output and see what it looks like
> 
> On Tue, Jun 1, 2021 at 10:20 PM marcello cappelli <kc...@gmail.com> wrote:
> >
> > Hi,
> > I get the same behavior even so:
> >
> > String  endpointUri     = "milo-client:opc.tcp://milo.digitalpetri.com:62541/milo?node=RAW(ns=2;s=Methods)&method=RAW(ns=2;s=Methods/sqrt(x))&defaultAwaitWrites=true&overrideHost=true";
> >
> > Variant[] inputArguments  = new Variant[1];
> > inputArguments[0] = new Variant((double) 25);
> >
> > Variant[] outputArguments = isoProducerTemplate.requestBody(endpointUri, inputArguments, Variant[].class);
> >
> > The response should be a 1 element variant array with the result
> >
> 
> 
> -- 
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
> 

Re: Methods in OPC-UA Apache-Camel Milo Client

Posted by Claus Ibsen <cl...@gmail.com>.
Try without the result type class parameter, and just get the object
as output and see what it looks like

On Tue, Jun 1, 2021 at 10:20 PM marcello cappelli <kc...@gmail.com> wrote:
>
> Hi,
> I get the same behavior even so:
>
> String  endpointUri     = "milo-client:opc.tcp://milo.digitalpetri.com:62541/milo?node=RAW(ns=2;s=Methods)&method=RAW(ns=2;s=Methods/sqrt(x))&defaultAwaitWrites=true&overrideHost=true";
>
> Variant[] inputArguments  = new Variant[1];
> inputArguments[0] = new Variant((double) 25);
>
> Variant[] outputArguments = isoProducerTemplate.requestBody(endpointUri, inputArguments, Variant[].class);
>
> The response should be a 1 element variant array with the result
>


-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Methods in OPC-UA Apache-Camel Milo Client

Posted by marcello cappelli <kc...@gmail.com>.
Hi,
I get the same behavior even so:

String  endpointUri     = "milo-client:opc.tcp://milo.digitalpetri.com:62541/milo?node=RAW(ns=2;s=Methods)&method=RAW(ns=2;s=Methods/sqrt(x))&defaultAwaitWrites=true&overrideHost=true";
            
Variant[] inputArguments  = new Variant[1];                        
inputArguments[0] = new Variant((double) 25);     
            
Variant[] outputArguments = isoProducerTemplate.requestBody(endpointUri, inputArguments, Variant[].class);

The response should be a 1 element variant array with the result


Re: Methods in OPC-UA Apache-Camel Milo Client

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

What exact method on producer template are you using? The requestBody
does not have a method that takes 5 parameters.

On Sun, May 30, 2021 at 10:47 AM marcello cappelli <kc...@gmail.com> wrote:
>
> A few months ago I started working on a project that requires the integration of OPC / UA to communicate with an automatic machine. Working with SpringBoot I looked for a library that was well integrated with this framework and in several posts and thesis I found Eclipse Milo, but in the version integrated with Apache Camel. Not knowing either Camel or Milo, I had to study both at least. Camel has a huge documentation, while the integration with Milo is limited to the parameterization and configuration of the Nodes to perform the reading and writing. That said it seems more than enough but in reality, since there are no specific examples, I had to search for posts several times to understand where I was wrong and clearly it took a lot of time. I find it normal to study and experiment but you know very well how urgent the deliveries we have as developers are and we don't always have free days to devote to research and testing. Now for example, I was able to run the reads and writes co
>  rrectly while the function calls have a strange behavior, that is, every time I call the test function, the value that is returned to me is the parameter that I give in input, even if, enabling the TRACE on Camel and Milo I see that the function is called correctly and in the OutputArguments there is the result I expect but Camel keeps returning the InputArguments. It's certainly my mistake but I can't find anything to help me understand where I'm wrong. No example, no similar case, nothing at all, so I wondered if the choice I made is the right one and if someone can give me some advice because I don't know what else to try.
>
> Here the test simplified code I'm trying to do:
> ```
> Variant[] params = new Variant[1];
> params[0] = new Variant(13);
>
> String  endpointUri = "milo-client:opc.tcp://milo.digitalpetri.com:62541/milo?node=RAW(ns=2;s=Methods)"&method=RAW(ns=2;s=Methods/sqrt(x))";
> return producerTemplate.requestBody(endpointUri, params, "await", true, Variant.class);
> ```
>
> The returned object is the same as I input, even if looking at the log I see that the function call is executed correctly:
> ```
>  2021-mag-20 11:14:07.613 TRACE [milo-netty-event-loop-1] o.e.m.o.s.c.t.t.OpcTcpTransport - Write succeeded for request=PublishRequest, requestHandle=16
>  2021-mag-20 11:14:07.598 DEBUG [milo-shared-thread-pool-1] o.a.c.c.m.c.i.SubscriptionManager - Call to node=ExpandedNodeId{ns=2, id=Methods, serverIndex=0}, method=ExpandedNodeId{ns=2, id=Methods/sqrt(x), serverIndex=0} = [Variant{value=13.0}]-> CallMethodResult{StatusCode=StatusCode{name=Good, value=0x00000000, quality=good}, InputArgumentResults=[StatusCode{name=Good, value=0x00000000, quality=good}], InputArgumentDiagnosticInfos=[], OutputArguments=[Variant{value=3.605551275463989}]}
> ```
>
> This are my dependencies :
> ```
> <dependency>
>   <groupId>org.apache.camel.springboot</groupId>
>   <artifactId>camel-spring-boot-starter</artifactId>
>   <version>3.9.0</version>
> </dependency>
> <dependency>
>   <groupId>org.apache.camel.springboot</groupId>
>   <artifactId>camel-milo-starter</artifactId>
>   <version>3.9.0</version>
> </dependency>
> ```
>
> Can someone help me?
> Many thanks



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2