Example TCP Rule Function to Connect to a Remote TCP Server
Here is a sample rule function to connect to a remote TCP server as a client:
Events.RemoteMsgResponseEvent rulefunction RuleFunctions.RemoteTCPSender { attribute { validity = ACTION; } scope { String host; int port; String message; } body { String tcpNickName = "TCP-" + host + "-" + port + "-" + uri + "-" + closure + "-" + System.nanoTime(); Events.RemoteMsgRequestEvent requestEvent = Events.RemoteMsgRequestEvent.RemoteMsgRequestEvent(null, message); TCP.connectToRemoteServer(tcpNickName, host, port); TCP.write(tcpNickName, requestEvent); TCP.endWrite(tcpNickName); Events.RemoteMsgResponseEvent responseEvent = TCP.readIntoPayloadFully(tcpNickName, "/Events/RemoteMsgResponseEvent"); TCP.disconnectFromRemoteServer(tcpNickName); return responseEvent; } }
Copyright © TIBCO Software Inc. All rights reserved.