0

At work we have a java backend that talks to python on some mobile devices. The mobile devices have no GUI, it's just pure string manipulation. All contact is initiated by the python; the java is just for listening and answering.

As such the python will send messages like:

message_name(field1, field2, field 3)

As strings. The listener then picks it up, finds the associated class for message_name (which is defined in an XML file) and feeds it the fields. The class then feeds the listener a response which is just a csv like so:

response_field1, response_field2, response_field3

I'm not overly familiar with this kind of interface (or really any client-server interfaces), but I'm fairly sure it's not REST or SOAP. I'm not sure if it even has a name, or is simply a homegrown kind of thing. None of my coworkers have a name for it.

In response to comment by @moberemk the XML file looks something like this (for the above message/response):

<bean id="command_name" parent="base_request_class"
      class="the_class_that_takes_the_request"
      scope="prototype">
    <property name="readOnly" value="true"/>
    <property name="commandName"  value="message_name" />
    <property name="response" ref="name_of_response_bean" />
    <property name="args">
         <list>
             <value>field1</value>
             <value>field2</value>
             <value>field3</value>
         </list>
    </property>
</bean>


<bean id="name_of_response_bean" 
      class="base_response_class
      scope="prototype">
    <property name="fields">
         <list>
             <value>response_field1</value>
             <value>response_field2</value>
             <value>response_field3</value>
         </list>
    </property>
</bean>

The listener makes note of this XML file. It then, upon receiving a message, looks for a relevant bean with "commandName" = "message_name" for whatever "message_name" came through. It then feeds the fields in the list of fields (args) to the class (given by the bean property "class"). Then the listener, once the thread for the class that takes the request has finished, takes the return result of that class and sends it verbatim to the python device.

So, if the listener were a human the process would go something like:

<receives message>
<looks at message name>
"Oh, it's a $message_name type of message. I know where to find who can help"
<Looks up who handles that kind of message>
<sends him the message with note "Let me know what you get back!">
<Guy that handles that message does his message handling, tells the listener what he found>
<Listener returns that to the device>

With some python pseudocode...

def listener(self, cmd):
    parsed = []
    parsed = self.parse(cmd) #Array with ["name", "field1", "field2" ...]
    class = self.find_matching_class(parsed[0]) #looks through the XML for the name of the class that should handle this message. String type
    executor = getattr(sys.modules[__name__], class) #Gets an instance of the class related to the message
    response = executor.execute(response[1:])
    self.connection.sendall(response) #Sends the response created by the 'executor' class back to the device that asked for it

closed as primarily opinion-based by gnat, Telastyn, durron597, user40980, user22815 Jul 7 '15 at 2:19

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • This is a really esoteric interface; can you maybe flesh this out with some more concrete code examples? For instance, what do you mean by "associated class for message_name"? – moberemk Jul 1 '15 at 19:09
  • Are you asking for a name for your message_name(...) to XML stuff, or a name for the network infrastructure between your Python and Java code, or for something else? I doubt there is a name of the exact sort you're looking for since the former question is probably "using XML" and the latter is probably "TCP/IP". – Ixrec Jul 1 '15 at 19:21
  • @moberemk updated – user3246152 Jul 1 '15 at 19:22
  • @Ixrec I'm looking for a name for the message over TCP/IP --> Listener --> Handling class --> Listener --> TCP/IP back to the python – user3246152 Jul 1 '15 at 19:25
3

That interface is a RPC - Remote Procedure Call. "RPC" is not a protocol but a family of protocols - there are many standardized RPC protocols, and countless standardless ones - your's probably being one of them - so I don't think it has a specific well known name...

  • That's definitely it! Though, yes, afaik it's one of the countless standardless ones. – user3246152 Jul 1 '15 at 20:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.