如何从PHP连接Jms? [英] How to connect Jms from PHP ?

查看:125
本文介绍了如何从PHP连接Jms?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的网站上实现类似于Facebook的聊天功能.我使用了HTML,PHP,JQuery和Apache.我在使用JMS之前就做了一些事,但是我不知道如何使用PHP将消息发送到JMS服务器?

I am trying to implement my sites little chat function like facebook uses. I used Html, PHP, JQuery and Apache. I made before some exaples with JMS but I couldn't figure out how to send message to a JMS server with PHP?

对于JMS,我使用了Weblogic.

For JMS I used Weblogic.

推荐答案

您有一些选择.让我们按从最坏到最坏的顺序进行检查.

You have a few options. Let's go through them in order of worst to not-worst.

首先是 Quercus ,这是Java中的PHP实现. Quercus中运行的PHP代码可以实例化Java类并在它们上调用方法,就像它们是PHP对象一样.您将能够以与在Java中使用JMS相同的方式来使用JMS.我没有这个经验.

First is Quercus, a PHP implementation in Java. PHP code running in Quercus can instantiate Java classes and call methods on them, just like they were PHP objects. You'd be able to work with JMS in the same way you'd work with it in Java. I have no experience with this one.

第二个是 PHP/Java桥.开始工作要复杂一些,但实际上与Quercus的工作方式相同(在代码方面).您将可以直接使用任何旧的Java API.我对此有经验,但并不愉快.相应的Apache + PHP子级退出后,Java进程最终陷入僵尸状态.我们最终不得不每晚编写一个cron脚本来清理所有正在运行的Java进程,否则服务器最终将耗尽可用内存.

Second is the PHP/Java Bridge. It's a bit more complex to get working, but it effectively works the same way as Quercus, code-wise. You'd be able to work directly with any old Java API. I have experience with this one, and it wasn't pleasant. Java processes ended up hanging around in a zombie state after the corresponding Apache+PHP child exited. We eventually had to write a cron script to clean up all working Java processes nightly, otherwise the server would eventually run out of available memory.

第三者将考虑使用不同的JMS提供程序,例如 ActiveMQ .为什么?因为ActiveMQ支持许多消息传递API,包括 Stomp ,所以与语言无关的消息传递API恰好具有 PHP扩展. Weblogic可能会说Stomp,但我无法确定是否是这种情况.唯一的Google搜索结果是 Weblogic + ActiveMQ集成.

Third would be looking at different JMS providers, like ActiveMQ. Why? Because ActiveMQ supports many messaging APIs, including Stomp, a language-agnostic messaging API that happens to have a PHP extension. It's possible that Weblogic can speak Stomp, but I was unable to determine if this is the case. The only Google results were for Weblogic + ActiveMQ integration.

第四名将不会考虑JMS. JMS是Java解决方案. PHP不是Java.有很多消息队列系统可以很好地与PHP配合使用. ActiveMQ只是一个示例.我个人更喜欢齿轮工. Gearman最初设计为执行分片的远程过程调用,但对于简单的消息传递也同样有效,并且 a PHP扩展,以及大多数其他语言的绑定.

Fourth would be not thinking about JMS. JMS is a Java solution. PHP ain't Java. There are plenty of message queue systems out there that work well with PHP. ActiveMQ is only one example. I personally prefer Gearman. Gearman was originally designed to perform sharded remote procedure calls, but it works equally as well for simple message passing, and has a PHP extension as well as bindings for most other languages under the sun.

这篇关于如何从PHP连接Jms?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆