Skip to content

zvikabo/Socket_Client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Socket_Client

This is an implementation of an RPC server that listens for messages on a RabbitMQ queue, processes them, and sends a response back to the caller. The messages that are received are expected to be in JSON format.

Here's a brief overview of the functionality provided by this code:

Read configuration parameters from a config file. Create a logger object for logging. Connect to a RabbitMQ server using the configuration parameters. Listen for messages on a RabbitMQ queue. When a message is received, parse it as JSON. Create a socket connection to a legacy application using configuration parameters. Send the message received from RabbitMQ to the legacy application. Receive the response from the legacy application. Send the response back to the caller using the RabbitMQ server. Close the socket connection. The code is structured as follows:

Import necessary modules such as json, amqpstorm, socket, time, initialization and daemon. Define the main_program function. Read the configuration parameters from a file using the initialization.cfgFile function. Create a logger object using the initialization.MyLogger function. Retrieve the RabbitMQ parameters and Wizard parameters from the configuration parameters. Define a function, convert2linenum, which converts the connid from Hex to Decimal and creates the line number using modulo with the number of line number that the Wizard port supports. Define a function, msg_protocol, which gets the action to invoke from the GVP message. Define a class, SocketClient, which creates a socket connection to the Wizard server and sends a message to it. In the main_program function, create a connection to the RabbitMQ server. Define a callback function that will be called when a message is received from RabbitMQ. In the callback function, parse the received message as JSON, get the action to invoke from the GVP message, and send the message to the Wizard server. Receive the response from the Wizard server, send it back to the caller using the RabbitMQ server, and close the socket connection. Some of the important variables and their descriptions are as follows:

v_cfg_file - path of the configuration file. cfg_params - dictionary containing the configuration parameters. v_primary_host - primary host name of the RabbitMQ server. v_backup_host - backup host name of the RabbitMQ server. v_vhost - virtual host name of the RabbitMQ server. v_username - username for the RabbitMQ server. v_password - password for the RabbitMQ server. v_rpc_queue - name of the queue to listen on for messages. v_max_retries - maximum number of retries to connect to RabbitMQ server. v_max_retries_per_server - maximum number of retries per server to connect to RabbitMQ server. v_message_ttl - time-to-live for the messages on the RabbitMQ server. v_wizard_host - host name of the Wizard server. v_wizard_port - port number of the Wizard server. v_number_of_ports - number of line numbers that the Wizard port supports. v_port_number_when_no_conn_id - port number to use when there is no connid. v_wizard_max_retries - maximum number of retries to connect to Wizard server. v_wizard_time_out_err_code - error code to use when there is a timeout error from the Wizard server. v_wizard_invalid_req_from_gvp_err_code - error code to use when there is an invalid request from GVP.

About

Socket_Client using RPC RabbitMQ

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages