activemq php java,使用ActiveMQ / Stomp在PHP和Java之间进行通信

本文探讨了如何通过消息队列替代PHP和Java服务之间的共享数据库通信。作者提出使用Stomp和JSON对象,通过ActiveMQ进行内部转换,确保在PHP中构造特殊JSON消息,然后在Java中利用XStream重构完整对象。当PHP服务最终被Java取代时,此方案简化了消息发送过程。
摘要由CSDN通过智能技术生成

Background

I have two services that need to communicate with each other over a message queue. One is a legacy service written in PHP and the other is in Java. Sooner than later, the PHP service will be rewritten in Java. The current way they communicate with each other is to write to a shared database, which the other service polls. This is what I'm trying to get away from and replace with a message queue.

Problem

The communication I'm working on right now is from the PHP service to the Java service. It needs to send a relatively complex object (strings and and integers and lists and maps of strings and integers). Ideally, the solution would be workable in PHP and ideal in Java, as that's going to be the legacy of this project.

Possible Solutions

1.

解决方案

The solution that I've come up with is to enqueue messages from PHP/Stomp using the jms-json-object transformation. The messages are specially crafted JSON such that when they are dequeued in Java using readObject, they can be reconstructed to a full object using XStream. This reconstruction happens internal to ActiveMQ and I just have to make sure that the necessary aliases and converters are in place. When we finally replace the PHP component with Java, sending a message will just be a matter of using writeObject.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值