Skip to Content
0

MII Custom Action to receive messages via TCP Socket

Oct 25, 2016 at 01:35 PM

100

avatar image

Hello Friends,

We have a requirement to establish a connection (exchange messages) between MII and an external system through TCP Socket connection. We can use SAP Pco to establish a TCP Scoket connection. But I am looking to create a MII custom action in order to send and receive messages in MII.I am comfortable to create a custom action to send (TCP Client) the messages, but I am thinking how can I do the same to receive (TCP Server)a message. Because we need to make sure that custom action is running always to receive the messages from external system. For example see the below java code snippet for TCP Server. I need to ensure below code keep running always. I am thinking how we can do this using custom actions. Let me know if you have any thoughts on this

**********Java code starts ************

String clientSentence;

String capitalizedSentence;

ServerSocket welcomeSocket = new ServerSocket(6789);

while(true)

{

Socket connectionSocket = welcomeSocket.accept();

BufferedReader inFromClient =

new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));

DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());

clientSentence = inFromClient.readLine();

System.out.println("Received: " + clientSentence);

}

Thanks

Shaji

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

christian libich
Oct 28, 2016 at 02:55 PM
0

You really shouldn't use a custom action for this type of scenario. Based on the architecture of MII it probably isn't possible and if it is isn't optimal or would cause undesirable issues. The correct way to deal with this is to use PCo. If the standard socket agent doesn't meet your needs then look into developing a custom PCo agent.

Regards,
Christian

Share
10 |10000 characters needed characters left characters exceeded
Shaji Chandran Nov 18, 2016 at 03:27 PM
0

Hi Christian,

Thanks for your response. Ok so I will use PCo Agent to receive the messages. But what about creating a custom action to send message over TCP Connection. I am planning to have properties such as hostname, port number, message, responseMessage for the custom action. I know that we can use new Pco Query Fixed Query Mode to send the message to external system over TCP Connection. But PCo query consumes more memory and resources so I am planning to have a custom action to send the message.

What is your opinion on this?

Thanks

Shaji

Share
10 |10000 characters needed characters left characters exceeded
christian libich
Nov 18, 2016 at 05:56 PM
0

It is an option. I have certainly done similar things in the past before the socket agent could support sending messages. In general I always seek solutions that leverage the infrastructure provided vs custom but sometimes you have to do something to meet the requirements. I don't know the volumes you are dealing with but memory and resources shouldn't be an issue PCo vs action. If they are then I think you may need a bigger box? :) More hardware may be cheaper than developing and supporting a custom solution.

Regards,
Christian

Share
10 |10000 characters needed characters left characters exceeded
Shaji Chandran Nov 29, 2016 at 01:39 PM
0

Hi Christian,

The challenge for me is that I need to send TCP message to around 20 different L3 systems which are running at plant. Each L3 system has got a different IP address and port. In order to achieve this using PCO query Fixed Mode, I need to configure 20 Pco Agent (Since each of them running on different IP address and port) and I have to make same number of (20) PCo Connections at MII side as well. If I write a custom action I can save all these amount of configuration and the resources PCo query takes to executes. That is why I am aiming a custom action to send TCP messages.

Thanks

Shaji

Share
10 |10000 characters needed characters left characters exceeded
christian libich
Dec 01, 2016 at 01:27 AM
0

I think one socket agent can support multiple connections and you can create/start and stop them via queries so you may be able to do it with only having to configure one Agent instance and one MII connection . I have done something similar in the past to support multiple devices dynamically.

New MII PCoQuery Fixed Query Mode

Regards,
Christian

Share
10 |10000 characters needed characters left characters exceeded