Communication between PHP and Java with ActiveMQ / Stomp

Background

I have two services that need to communicate with each other in a message queue. One of them is an outdated service written in PHP, and the other in Java. Sooner, later, the PHP service will be rewritten in Java. The current way to communicate with each other is to write to a shared database that another service is running. This is what I am trying to leave and replace with a message queue.

Problem

The connection I'm working with right now is the PHP service for the Java service. A relatively complex object (strings and integers and lists and maps of strings and integers) needs to be sent to him. Ideally, the solution will work in PHP and is ideal for Java, since it will be a legacy of this project.

Possible solutions

  • 1.
+3
source share
3 answers

The solution I came across is to embed messages from PHP / Stomp using conversion jms-json-object. These messages are specially created by JSON, so when they are uploaded to Java using readObject, they can be restored to a complete object using XStream . This reconstruction takes place inside ActiveMQ , and I just need to make sure that the necessary aliases and converters are needed . When we finally replace the PHP component of Java, sending a message will be just a matter of use writeObject.

+3
source

, . ActiveMQ , RabbitMQ Sun OpenMQ. " " PHP, "SendMessage" JSON. factory .. PHP- mq-. TextMessage JSON, Jackson.

-2

Source: https://habr.com/ru/post/1750699/


All Articles