首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

11.6 使用拦截器插件扩张代理功能

2013-12-21 
11.6 使用拦截器插件扩展代理功能pluginsconnectionDotFilePlugin fileActiveMQConnections.dot/d

11.6 使用拦截器插件扩展代理功能

<plugins>

<connectionDotFilePlugin file="ActiveMQConnections.dot"/>

<destinationDotFilePlugin file="ActiveMQDestinations.dot"/>

</plugins>

</broker>

?

The next plug-in we’ll look at was developed by one of ActiveMQ’s many users to

enhance the logging available for the ActiveMQ broker.

下一节我们将看到为增强ActiveMQ代理的日志功能而开发的插件.

?

11.6.2 Enhanced logging

11.6.2 日志功能增强插件

?

The logging interceptor (loggingInterceptor), if configured, allows you to log messages

that are sent or acknowledged on an ActiveMQ broker, in addition to the normal

logging done by ActiveMQ. This plug-in can be useful for tracing problems or auditing

messages. A few properties for the logging interceptor can be configured, as shown in

table 11.4.

?

日志插件(loggingInterceptor),如果配置启用的话,除了可以允许使用ActiveMQ常规的日志外,还允许你记录发送到

ActiveMQ代理的消息,或者由ActiveMQ代理确认的消息.此插件可用于追踪问题或审计有用消息.日志连接器插件的

属性如表11.4所示:

?

Table 11.4 Properties for the logging interceptor

表11.4 日志拦截器插件属性

?

Property name Default value Description

logAll false Log all the events

logMessageEvents false Log events associated with messages

logConnectionEvents true Log events associated with connections

logConsumerEvents false Log events associated with producers

logProducerEvents false The maximum size of the message journal data files before a new one is used

logInternalEvents false Detailed information of workings of the broker

?

11.6.3 Central timestamp messages with the timestamp interceptor plug-in

11.6.3 中央时间戳消息和时间戳拦截器插件

?

The timestamp plug-in (timestampingBrokerPlugin), if configured, updates the timestamp

on messages as they arrive at the broker. This can be useful when there’s a difference

(however small) between the system clocks on a computer sending messages

to an ActiveMQ broker and the computer the broker resides on.?

?

时间戳插件(timestampingBrokerPlugin),如果启用,会在消息到达代理时更新消息时间戳.

当代理所在机器的系统时间和发送消息的机器的时间不同(尽管差别很小)时,这个插件会很有用.

?

When messages are ?sent with the ?timeToLive property set, ?it’s important that

the ?system clocks ?between the ?sending machine ?and the ?broker are ?in sync;

otherwise ?messages ?may ?get ?expired erroneously. ?A ?few ?properties ?for the

timestamp plug-in can be configured, as shown in table 11.5.

?

当发送一个设置了timeToLive属性的消息时,发送消息的机器和代理所在机器的系统时间的同步非常重要.

否则,消息过期判断会产生异常.时间戳插件的可配置属性如表11.5所示:

?

Table 11.5 Properties for the message timestamp plug-in

表11.5 消息时间戳插件属性

?

Property name Default value Description

zeroExpirationOverride 0 When not zero, will override the expiration date for

messages that currently don’t have an expiration set

配置为非0时,配置的值会被设置成为当前没有配置过期时间的消息的过期时间

?

ttlCeiling 0 When not zero, will limit the expiration time

配置为非0时,会限制过期时间

?

futureOnly false If true, won’t update the timestamp of messages to past values

如果设置为true,将不会更新消息时间戳为一个过去的值

?

It’s recommend that the timestampingBrokerPlugin be enabled on the ActiveMQ broker

if you’re using the timeToLive property on messages.

?

如果使用了消息的timeToLive属性,推荐启用ActiveMQ代理的timestampingBrokerPlugin插件.

?

The next interceptor plug-in is used for generating messages about management

statistics for the ActiveMQ broker.

?

下一个拦截器插件用于为ActiveMQ代理生成管理统计数据的消息.

?

11.6.4 Statistics

11.6.4 统计插件

?

The statisticsBrokerPlugin will send MapMessages containing information about the

statistics of the running of the ActiveMQ broker. There are two types of message: one

for destinations and one that gives an overview of the broker itself.

?

statisticsBrokerPlugin插件会发送Map格式的包含ActiveMQ代理的运行时信息的消息.

有两种格式的消息:一种是消息目的地相关的,另一种消息包含了代理本身概况.

?

To retrieve the statistics of the running broker with the statisticsBrokerPlugin

enabled, send an empty message to the destination (queue or topic—it doesn’t matter)

called ActiveMQ.Statistics.Broker. The JMSReplyTo header names the destination

where the statistics message is sent.

?

启用statisticsBrokerPlugin插件后,为了获取运行中的代理的统计信息,需要发送一个空消息到

一个命名为ActiveMQ.Statistics.Broker的消息目的地(队列或主题都可以,这个不重要).消息

头中的JMSReplyTo字段表明统计消息将要发往的目的地.

?

Similarly, to retrieve information about a destination, send an empty message to

the name of the destination, prepended with ActiveMQ.Statistics.Destination. For example,

to retrieve statistics for the destination Topic.Foo, send a message to the destination

ActiveMQ.Statistics.DestinationTopic.Foo.

?

类似地,为了获取消息目的地相关的统计信息,需要发送一个空消息到已ActiveMQ.Statistics.Destination作为

前缀的消息目的地.例如,为了获取消息目的地Topic.Foo的统计信息,需要发送一个空消息到以

ActiveMQ.Statistics.DestinationTopic.Foo命名的目的地中.

?

You enable an ActiveMQ broker plug-in by including it in the broker configuration

file, as shown:

可以使用如下代码中的配置方式启用ActiveMQ代理插件:

?

Listing 11.4 Configuring plugins for the broker

代码清单11.4 为代理配置插件

?

<broker useJmx="false" persistent="false">

<plugins>

<loggingBrokerPlugin logAll="true" logConnectionEvents="false"/>

<timeStampingBrokerPlugin

zeroExpirationOverride="1000"

ttlCeiling="60000" futureOnly="true"/>

<statisticsBrokerPlugin/>

</plugins>

</broker>

?

Broker interceptors are a useful addition for extending the functionality of ActiveMQ.

But you can provide more features and flexibility by embedding Apache Camel, the

powerful integration framework, in the ActiveMQ broker. We’ll look at Apache Camel

integration next.

?

代理拦截器是有用的扩展,可以扩充ActiveMQ代理的功能.但是,你可以使用嵌入的功能强大的集成插件

Apache Camel为ActiveMQ代理提供更多的功能和灵活性.下面我们将看到如何集成Apache Camel到

ActiveMQ代理中.

热点排行