telegram-bot-ruby icon indicating copy to clipboard operation
telegram-bot-ruby copied to clipboard

Interprocess communication - the right way

Open govorov opened this issue 7 years ago • 2 comments

Hi! I use telegram-bot-ruby in an application that consists of two main parts - telegram API workers and a rails app. They interact via RabbitMQ. There is no information in documentation about sending Bot::Client received messages via rabbit, so in my proof-of-concept I use standard ruby object marshalling. It seems to be a great overhead, and I'm pretty sure that I can use some internal method for extracting raw message data and creating message objects manually from that raw data on the other side . So the question is, what solution for sending messages between processes would you recommend? Thank you!

govorov avatar Jun 18 '17 00:06 govorov

@ivanovaleksey @atipugin help please :)

govorov avatar Jul 18 '17 00:07 govorov

Hi @govorov, sorry for being silent.

I'm pretty sure that I can use some internal method for extracting raw message data and creating message objects manually from that raw data on the other side.

You are right about that. If you have raw response from Telegram API you can use the same logic as Client#fetch_updates does. Create Update object and extract message from the update. For more information check Client#fetch_updates source code.

That being said I don't know details about your application. Are you going to send via RabbitMQ raw message (say it would JSON) from Telegram workers to Rails app? And then create a message object on the Rails side and work with it?

Just FYI: there can be another option. For example, on Telegram worker's side you can extract from the message useful information and send it via RabbitMQ. This way you can simplify logic on Rails-app side (but this would be present in worker), reduce traffic (if useful payload is small part of the whole message), and, for instance, push plain messages to one queue but inline queries to another one.

I am not sure about what solution would be the best and can't really recommend you to use (or not to use) any of this.

ivanovaleksey avatar Jul 18 '17 07:07 ivanovaleksey

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Feb 19 '23 15:02 github-actions[bot]