WebSphere Liberty ActiveMQ [英] WebSphere Liberty ActiveMQ

查看:101
本文介绍了WebSphere Liberty ActiveMQ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是使用来自ActiveMQ的WebSphere Liberty Appserver(完整Java EE标准)使用Messages。不幸的是,我不知道如何配置WebSphere Liberty。我正在使用的ActiveMQ Server开箱即用,并且我添加了一个名为myQueue的队列。

My goal is to consume Messages with the WebSphere Liberty Appserver (Full Java EE Standard) from an ActiveMQ. Unlucky I can't figure out how to configurate the WebSphere Liberty. The ActiveMQ Server im using is out of the box and I have added a Queue named myQueue.

在我的Java EE应用程序中,我希望有一个消息驱动的Bean,它可以被踢出如果消息在队列中。我试图从 wasDev JMS示例中窃取配置其他人对此示例。但是很不幸,该配置对我来说不起作用。我研究了活动的mq资源适配器设置,并在server.xml中尝试了它们。

In my Java EE application I want to have a Message Driven Beans which gets kicked if a message is in the queue. I tried to "steal" the configuration from the wasDev JMS Example like someone else did on this example. But unlucky the config is not working out for me. I studied the active mq resource adapter settings and tried the used them in my server.xml.

首先,我从ActiveMQ下载了Resource Adapter rar,并将其包含在服务器和server.xml,如下所示:

First of all I downloaded the Resource Adapter rar from ActiveMQ and included it into the server and the server.xml like this:

<resourceAdapter id="activemq"  location="/opt/ibm/wlp/usr/servers/defaultServer/resources/activemq-rar-5.13.1.rar">
    <properties.activemq ServerUrl="tcp://192.168.200.6:61616" />
</resourceAdapter>

这应该激活资源适配器并告诉他服务器的位置。接下来,我编写了仅输出MessageID的消息驱动Bean。

This should active the resource adapter and tell him where the server is located. Next I wrote my Message Driven Bean which only outputs the MessageID.

@MessageDriven(name = "PythonDaemonMessageEJB")

public class PythonDaemonMessageBean implements MessageListener {
    public PythonDaemonMessageBean() {
    }

    @Override
    public void onMessage(Message var1) {
        try {
            System.out.println(var1.getJMSMessageID());
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }
}

我希望onMessage是称为asoon的消息正在排队。接下来,我做了一个ejb-jar.xml条目:

I want the onMessage to be called asoon a message is in the queue. Next I made an ejb-jar.xml entry:

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
      http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
     version="3.1">
    <enterprise-beans>
    <session>
        <ejb-name>TestEJB</ejb-name>
        <ejb-class>ch.TestBean</ejb-class>
        <session-type>Stateless</session-type>
        <transaction-type>Container</transaction-type>
    </session>
    <message-driven>
        <ejb-name>PythonDaemonMessageEJB</ejb-name>
        <ejb-class>ch.PythonDaemonMessageBean</ejb-class>
        <messaging-type>javax.jms.MessageListener</messaging-type>
        <transaction-type>Container</transaction-type>
        <message-destination-type>javax.jms.Queue</message-destination-type>
        <activation-config>
            <activation-config-property>
                <activation-config-property-name>destination</activation-config-property-name>
                <activation-config-property-value>myQueue</activation-config-property-value>
            </activation-config-property>
            <activation-config-property>
                <activation-config-property-name>destinationType</activation-config-property-name>
                <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
            </activation-config-property>
        </activation-config>
    </message-driven>
</enterprise-beans>

最后一步i有效我的server.xml中的bean

Last step i "active" the bean in my server.xml

<jmsActivationSpec id="cert-manager-ear/cert-manager-ejb/PythonDaemonMessageEJB" />

就是这样-以我的理解,现在应该没事了。这是完整的server.xml,其中包含我也尝试过的其他内容。如果您有解决方案,请说明我做错了什么。

In that's it - in my understanding things should be fine now. Here is the full server.xml containing other things I tried out too. If you have a solution please explane me what I did wrong.

    <server description="new server">

    <!-- Enable features -->
    <featureManager>
        <feature>javaee-7.0</feature>
    <feature>localConnector-1.0</feature>
    </featureManager>

    <httpEndpoint id="defaultHttpEndpoint"
                  httpPort="9080"
                  httpsPort="9443" />

    <!-- Automatically expand WAR files and EAR files -->
    <applicationManager autoExpand="true"/>

    <resourceAdapter id="activemq"  location="/opt/ibm/wlp/usr/servers/defaultServer/resources/activemq-rar-5.13.1.rar">
        <properties.activemq ServerUrl="tcp://192.168.200.6:61616" />
    </resourceAdapter>

    <jmsActivationSpec id="cert-manager-ear/cert-manager-ejb/PythonDaemonMessageEJB" />
    #       <properties.activemq />  #destinationRef="jndi/MDBQ" destinationType="javax.jms.Queue" />
    #   </jmsActivationSpec>

    #   <jmsQueueConnectionFactory jndiName="jndi_JMS_BASE_QCF">
    #       <properties.activemq />
    #   </jmsQueueConnectionFactory>

    #   <jmsQueue> jndiName="jndi_INPUT_Q">
    #       <properties.activemq PhysicalName="QUEUE1" />
    #   </jmsQueue>

    #   <jmsQueue id="jndi/MDBREPLYQ" jndiName="jndi/MDBREPLYQ">
    #       <properties.activemq PhysicalName="MDBREPLYQ" />
    #   </jmsQueue>

    #   <jmsQueue id="jndi/MDBQ" jndiName="jndi/MDBQ">
    #       <properties.activemq PhysicalName="myQueue" />
    #   </jmsQueue>
    </server>

我正在使用WebSphere Liberty V8.5.5.8和ActiveMQ 5.13.1

I'm using the WebSphere Liberty V8.5.5.8 and ActiveMQ 5.13.1

日志文件显示:

The message endpoint for the message driven bean PythonDaemonMessageEJB can not be activated because the target myQueue is not available. 

我的Python脚本可以毫无问题地读写目标。 ActiveMQ日志文件没有说什么,所以我认为问题不在ActiveMQ方面。无法达到。

My Python scripts can read and write to the target without problems. The ActiveMQ Log files doesn't say anything so I think the problem is not on the ActiveMQ side. It does not get reached.

推荐答案

服务器配置需要一些更新才能生效。

A couple of updates are needed to your server configuration for this to work.

首先,您需要一个jmsQueue元素,其ID与激活配置属性中指定的目标匹配。例如,

First, you need a jmsQueue element with an id that matches the destination specified in the activation config properties. For example,

   <jmsQueue id="myQueue" jndiName="jndi/MDBQ">
       <properties.activemq PhysicalName="myQueue" />
   </jmsQueue>

第二,jmsActivationSpec元素需要嵌套的properties.activemq(即使您不想覆盖任何属性,并希望所有默认值)来标识jmsActivationSpec对应于您的配置的id为activemq的resourceAdapter(与其他也可以添加到配置中的resourceAdapter相对)。例如,

Second, the jmsActivationSpec element needs a nested properties.activemq (even if you don't want to override any properties and want all the defaults) to identify that the jmsActivationSpec corresponds to your configured resourceAdapter with id activemq (versus any other resourceAdapter that could also be added to the configuration). For example,

<jmsActivationSpec id="cert-manager-ear/cert-manager-ejb/PythonDaemonMessageEJB" />
   <properties.activemq />
</jmsActivationSpec>

这篇关于WebSphere Liberty ActiveMQ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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