NameNotFoundException:通过 logstash 连接到远程队列



我在 JBoss EAP 7.1 上有一个部署的队列(在standalone.xml中定义(,由 ActiveMQ Artemis 管理(模块名称 xmlns="urn:jboss:domain:messaging-activemq:2.0"(,同时我想使用 logstash 中的 JMS 插件(使用 JNDI(连接到该队列,以使用由我的 JBoss 服务器上部署的应用程序发送的消息, 但是当我尝试时,我得到了连接工厂的NameNotFoundException(logstash conf 文件中的属性jndi_name(。

我试图找到默认的连接工厂 JNDI 条目,但即便如此,它也没有用。

所以我想知道连接工厂是由消息代理创建的还是默认情况下为客户端存在的?因为如果我没记错的话,连接工厂是连接到代理和队列的唯一方法,如果我错了,请纠正,但它们必须默认存在于客户端中。

我希望你能帮助我,这是我的日志存储会议文件:

input {
jms {
# Logstash Configuration Settings. 
include_header => false
include_properties => false
include_body => true
use_jms_timestamp => false
destination => "AuditTrailMDB"
pub_sub => false
# JNDI Settings
jndi_name => 'queueConnectionFactory'
jndi_context => { 
'java.naming.factory.initial' => 'org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory'
'java.naming.security.principal' => 'admin'
'java.naming.provider.url' => 'tcp://localhost:5445?type=QUEUE_CF'
'java.naming.security.credentials' => 'admin'
}
# Jar files to be imported
require_jars=> ['/home/Alternant/logstash/dependencies/jboss-client.jar', 
'/home/Alternant/logstash/dependencies/artemis-ra.jar',
'/home/Alternant/logstash/dependencies/ironjacamar-core-impl.jar',
'/home/Alternant/logstash/dependencies/ironjacamar-core-api.jar',
'/home/Alternant/logstash/dependencies/ironjacamar-common-api.jar']
}
}output{
stdout{}
}

这是我在standalone.xml中的队列定义:

<subsystem xmlns="urn:jboss:domain:messaging-activemq:2.0">
<server name="default">
<security-setting name="#">
<role consume="true" create-non-durable-queue="true" delete-non-durable-queue="true" name="guest" send="true"/>
</security-setting>
<address-setting dead-letter-address="jms.queue.DLQ" expiry-address="jms.queue.ExpiryQueue" max-size-bytes="10485760" message-counter-history-day-limit="10" name="#" page-size-bytes="2097152"/>
<http-connector endpoint="http-acceptor" name="http-connector" socket-binding="http"/>
<http-connector endpoint="http-acceptor-throughput" name="http-connector-throughput" socket-binding="http">
<param name="batch-delay" value="50"/>
</http-connector>
<in-vm-connector name="in-vm" server-id="0">
<param name="buffer-pooling" value="false"/>
</in-vm-connector>
<remote-connector name="netty" socket-binding="remote-messaging"/>
<http-acceptor http-listener="default" name="http-acceptor"/>
<http-acceptor http-listener="default" name="http-acceptor-throughput">
<param name="batch-delay" value="50"/>
<param name="direct-deliver" value="false"/>
</http-acceptor>
<in-vm-acceptor name="in-vm" server-id="0">
<param name="buffer-pooling" value="false"/>
</in-vm-acceptor>
<remote-acceptor name="netty" socket-binding="messaging"/>
<jms-queue entries="java:/jms/queue/ExpiryQueue" name="ExpiryQueue"/>
<jms-queue entries="java:/jms/queue/DLQ" name="DLQ"/>
<jms-queue entries="queue/clientPending" name="clientPending"/>
<jms-queue name="AuditTrailMDB" entries="queue/AuditTrailMDB"/>
<connection-factory connectors="in-vm" entries="java:/ConnectionFactory" name="InVmConnectionFactory"/>
<pooled-connection-factory connectors="netty" entries="java:jboss/exported/jms/RemoteConnectionFactory" name="RemoteConnectionFactory" user="admin" password="admin"/>
<pooled-connection-factory connectors="in-vm" entries="java:/JmsXA java:jboss/DefaultJMSConnectionFactory" name="activemq-ra" transaction="xa"/>
<connection-factory connectors="in-vm" entries="/ApplicationsQueueConnectionFactory" name="ApplicationsQueueConnectionFactory"/>
</server>
</subsystem>
...
<socket-binding name="messaging" port="5445"/>
...

.log:

[WARN ][logstash.inputs.jms      ][main] JMS Consumer Died {:exception=>"Java::JavaxNaming::NameNotFoundException", :exception_message=>"queueConnectionFactory", :backtrace=>["org.apache.activemq.artemis.jndi.ReadOnlyContext.lookup(org/apache/activemq/artemis/jndi/ReadOnlyContext.java:236)", "javax.naming.InitialContext.lookup(javax/naming/InitialContext.java:417)", "java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:498)", "org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(org/jruby/javasupport/JavaMethod.java:455)", "org.jruby.javasupport.JavaMethod.invokeDirect(org/jruby/javasupport/JavaMethod.java:316)", "home.Alternant.logstash.vendor.bundle.jruby.$2_dot_5_dot_0.gems.jruby_minus_jms_minus_1_dot_3_dot_0_minus_java.lib.jms.connection.initialize

JBoss EAP 和 Logstash 的配置都存在一些问题。


让我们从 JBoss EAP 开始...

首先,您将RemoteConnectionFactory的默认配置更改为:

<pooled-connection-factory connectors="netty" entries="java:jboss/exported/jms/RemoteConnectionFactory" name="RemoteConnectionFactory" user="admin" password="admin"/>

这是不正确的。远程客户端不能使用pooled-connection-factory,只有与应用服务器位于同一JVM中的客户端才能使用(例如需要发送消息的MDB(。您应该改用默认配置:

<connection-factory name="RemoteConnectionFactory" entries="java:jboss/exported/jms/RemoteConnectionFactory" connectors="http-connector"/>

其次,您的AuditTrailMDB队列将不可用于远程客户端。这是它的配置:

<jms-queue name="AuditTrailMDB" entries="queue/AuditTrailMDB"/>

它需要在java:jboss/exported/命名空间中有一个新的 JNDI 条目,以便可供远程客户端使用(例如,像RemoteConnectionFactory一样(。因此,您应该使用它:

<jms-queue name="AuditTrailMDB" entries="queue/AuditTrailMDB java:jboss/exported/AuditTrailMDB"/>

现在对于洛格斯塔什...

首先,您使用了错误的 JNDI 属性。您正在使用的属性用于 ActiveMQ Artemis JNDI 实现。以下是您当前的配置:

jndi_context => { 
'java.naming.factory.initial' => 'org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory'
'java.naming.security.principal' => 'admin'
'java.naming.provider.url' => 'tcp://localhost:5445?type=QUEUE_CF'
'java.naming.security.credentials' => 'admin'
}

这是不正确的。当ActiveMQ Artemis嵌入到JBoss EAP中时,EAP本身会处理所有的JNDI查找。因此,您应该改用此配置:

jndi_context => { 
'java.naming.factory.initial' => 'org.wildfly.naming.client.WildFlyInitialContextFactory'
'java.naming.security.principal' => 'admin'
'java.naming.provider.url' => 'http-remoting://127.0.0.1:8080'
'java.naming.security.credentials' => 'admin'
}

当然,这假设您已将正确的admin用户添加到 EAP。

其次,您的连接工厂 JNDI 名称不正确。您当前正在使用以下内容:

jndi_name => 'queueConnectionFactory'

您应该改用它:

jndi_name => 'jms/RemoteConnectionFactory'

第三,你使用的罐子不正确。以下是您当前的配置:

require_jars=> ['/home/Alternant/logstash/dependencies/jboss-client.jar', 
'/home/Alternant/logstash/dependencies/artemis-ra.jar',
'/home/Alternant/logstash/dependencies/ironjacamar-core-impl.jar',
'/home/Alternant/logstash/dependencies/ironjacamar-core-api.jar',
'/home/Alternant/logstash/dependencies/ironjacamar-common-api.jar']

您根本不需要其中的大多数。您可以使用此处提供的wildfly-client-all"uber"jar 来简化配置。然后,您的配置将如下所示:

require_jars=> ['/home/Alternant/logstash/dependencies/wildfly-client-all-7.1.0.GA-redhat-11.jar']

相关内容

  • 没有找到相关文章

最新更新