JBoss hornetq SVN: r8958 - in trunk: tests/src/org/hornetq/tests/integration/client and 1 other directory.
by do-not-reply@jboss.org
Author: timfox
Date: 2010-03-24 11:46:47 -0400 (Wed, 24 Mar 2010)
New Revision: 8958
Modified:
trunk/src/config/common/hornetq-version.properties
trunk/tests/src/org/hornetq/tests/integration/client/ProducerFlowControlTest.java
Log:
updated version
Modified: trunk/src/config/common/hornetq-version.properties
===================================================================
--- trunk/src/config/common/hornetq-version.properties 2010-03-24 14:56:20 UTC (rev 8957)
+++ trunk/src/config/common/hornetq-version.properties 2010-03-24 15:46:47 UTC (rev 8958)
@@ -1,8 +1,8 @@
-hornetq.version.versionName=Hornet Queen
+hornetq.version.versionName=Horny Hornet
hornetq.version.majorVersion=2
-hornetq.version.minorVersion=0
+hornetq.version.minorVersion=1
hornetq.version.microVersion=0
-hornetq.version.incrementingVersion=113
-hornetq.version.versionSuffix=GA
-hornetq.version.versionTag=GA
+hornetq.version.incrementingVersion=114
+hornetq.version.versionSuffix=CR1
+hornetq.version.versionTag=CR1
hornetq.netty.version=(a)NETTY.VERSION@
Modified: trunk/tests/src/org/hornetq/tests/integration/client/ProducerFlowControlTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/client/ProducerFlowControlTest.java 2010-03-24 14:56:20 UTC (rev 8957)
+++ trunk/tests/src/org/hornetq/tests/integration/client/ProducerFlowControlTest.java 2010-03-24 15:46:47 UTC (rev 8958)
@@ -21,11 +21,13 @@
import junit.framework.Assert;
import org.hornetq.api.core.SimpleString;
+import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.client.ClientConsumer;
import org.hornetq.api.core.client.ClientMessage;
import org.hornetq.api.core.client.ClientProducer;
import org.hornetq.api.core.client.ClientSession;
import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.HornetQClient;
import org.hornetq.api.core.client.MessageHandler;
import org.hornetq.core.client.impl.ClientProducerCreditManagerImpl;
import org.hornetq.core.client.impl.ClientProducerCredits;
@@ -36,6 +38,7 @@
import org.hornetq.core.settings.HierarchicalRepository;
import org.hornetq.core.settings.impl.AddressFullMessagePolicy;
import org.hornetq.core.settings.impl.AddressSettings;
+import org.hornetq.integration.transports.netty.NettyConnectorFactory;
import org.hornetq.tests.util.RandomUtil;
import org.hornetq.tests.util.ServiceTestBase;
import org.hornetq.tests.util.UnitTestCase;
@@ -658,6 +661,76 @@
server.stop();
}
+ public void testBlockingIssue() throws Exception
+ {
+ // HornetQServer server = createServer(true, true);
+ //
+ // AddressSettings addressSettings = new AddressSettings();
+ // addressSettings.setMaxSizeBytes(300000);
+ // addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK);
+ //
+ // HierarchicalRepository<AddressSettings> repos = server.getAddressSettingsRepository();
+ // repos.addMatch("bar".toString(), addressSettings);
+ //
+ // server.start();
+
+ // ClientSessionFactory sf = createFactory(true);
+
+ TransportConfiguration tc = new TransportConfiguration(NettyConnectorFactory.class.getName());
+
+ ClientSessionFactory sf = HornetQClient.createClientSessionFactory(tc);
+
+// ClientSession sess = sf.createSession();
+//
+// sess.createQueue("bar", "bar");
+
+ int count = 0;
+ while (true)
+ {
+ log.info("*** ITERATION " + count++ + "\n\n\n\n");
+ ClientSession session = sf.createTransactedSession();
+
+ ClientProducer producer = session.createProducer("bar");
+
+ for (int i = 0; i < 1000; i++)
+ {
+
+ ClientMessage message = session.createMessage(true);
+
+ message.getBodyBuffer().writeString("Hello");
+
+ producer.send(message);
+
+ // log.info("sent " + i);
+
+ }
+
+ session.commit();
+
+ session.close();
+
+ session = sf.createSession();
+
+ session.start();
+
+ ClientConsumer consumer = session.createConsumer("bar");
+
+ for (int i = 0; i < 1000; i++)
+ {
+
+ ClientMessage msgReceived = consumer.receive();
+
+ msgReceived.acknowledge();
+
+ // log.info("read " + i);
+
+ }
+
+ session.close();
+
+ }
+ }
+
public void testProducerCreditsCaching5() throws Exception
{
HornetQServer server = createServer(false, isNetty());
14 years, 2 months
JBoss hornetq SVN: r8957 - branches/HnetQ_323_cn/docs/user-manual/zh.
by do-not-reply@jboss.org
Author: gaohoward
Date: 2010-03-24 10:56:20 -0400 (Wed, 24 Mar 2010)
New Revision: 8957
Modified:
branches/HnetQ_323_cn/docs/user-manual/zh/using-core.xml
Log:
chapter 8
Modified: branches/HnetQ_323_cn/docs/user-manual/zh/using-core.xml
===================================================================
--- branches/HnetQ_323_cn/docs/user-manual/zh/using-core.xml 2010-03-24 14:51:31 UTC (rev 8956)
+++ branches/HnetQ_323_cn/docs/user-manual/zh/using-core.xml 2010-03-24 14:56:20 UTC (rev 8957)
@@ -17,161 +17,122 @@
<!-- permitted by applicable law. -->
<!-- ============================================================================= -->
<chapter id="using-core">
- <title>Using Core</title>
- <para>HornetQ core is a completely JMS-agnostic messaging system with its own non-JMS API. We
- call this the <emphasis>core API</emphasis>.</para>
- <para>If you don't want to use JMS you can use the core API directly. The core API provides all
- the functionality of JMS but without much of the complexity. It also provides features that
- are not available using JMS.</para>
+ <title>使用HornetQ内核</title>
+ <para>HornetQ内核是一个与JMS无关的消息系统,它有一套自己的API。我们称它为<emphasis>内核API</emphasis>.</para>
+ <para>你可以直接使用内核API。使用内核API可以完成JMS同样的功能,只是比起JMS API使用更加简单方便。另外,内核API
+ 还提供了JMS不具有的额外的功能。</para>
<section>
- <title>Core Messaging Concepts</title>
- <para>Some of the core messaging concepts are similar to JMS concepts, but core messaging
- concepts differ in some ways. In general the core messaging API is simpler than the JMS
- API, since we remove distinctions between queues, topics and subscriptions. We'll
- discuss each of the major core messaging concepts in turn, but to see the API in detail,
- please consult the Javadoc.</para>
+ <title>内核消息系统的相关概念</title>
+ <para>内核消息系统中有许多概念是与JMS相似的,但有些方面是不同的。总的来说内核消息系统的接口相对简单。这是因为
+ 在内核中没有队列(queue)、话题(topic)和订阅(subscription)的概念。下面我们就内核消息中的概念作逐一介绍。
+ 但是每个API的详细说明还是要参见相应的javadoc。</para>
<section>
- <title>Message</title>
+ <title>消息</title>
<itemizedlist>
<listitem>
- <para>A message is the unit of data which is sent between clients and
- servers.</para>
+ <para>一个消息就是客户端与服务器传递信息的单位数据。</para>
</listitem>
<listitem>
- <para>A message has a body which is a buffer containing convenient methods for
- reading and writing data into it.</para>
+ <para>一个消息有一个消息体(body),即一个缓存用以写入数据或从中读取数据。</para>
</listitem>
<listitem>
- <para>A message has a set of properties which are key-value pairs. Each property
- key is a string and property values can be of type integer, long, short,
- byte, byte[], String, double, float or boolean.</para>
+ <para>一个消息有一个属性集,这个属性集实际上包含的是主键-值的集合。每个属性的主键是一个字符串,值可
+ 以是一个整数(integer)、长整数(long)、短整数(short)、字节(byte)、字节数组(byte[])、
+ 字符串(String),双精度值(double)、浮点数(float)或是布尔值(boolean)。</para>
</listitem>
<listitem>
- <para>A message has an <emphasis>address</emphasis> it is being sent to. When
- the message arrives on the server it is routed to any queues that are bound
- to the address - if the queues are bound with any filter, the message will
- only be routed to that queue if the filter matches. An address may have many
- queues bound to it or even none. There may also be entities other than
- queues, like <emphasis role="italic">diverts</emphasis> bound to
- addresses.</para>
+ <para>每个消息都有一个<emphasis>地址(address)</emphasis>做为它的目的地。当一个消息被发到
+ 服务器上时,它会被路由到与该地址绑定的所有队列中(queue)。如果queue配置了过滤器(filter),
+ 那么只有与过滤器相匹配的消息才会被路由到该queue。一个地址可以绑定多个queue,也可以一个也不
+ 绑定。注意这里所说的queue是内核的概念,不是JMS的queue。除了queue之外,还有其它一些实体可以
+ 绑定到某一地址上。比如<emphasis role="italic">divert(转发器)</emphasis>。</para>
</listitem>
<listitem>
- <para>Messages can be either durable or non durable. Durable messages in a
- durable queue will survive a server crash or restart. Non durable messages
- will never survive a server crash or restart.</para>
+ <para>消息可以是持久的(durable)或非持久的(non-durable)。持久的消息不会因为服务器故障或重启而丢失。
+ 非持久消息则会因为服务器的故障或重启而丢失。</para>
</listitem>
<listitem>
- <para>Messages can be specified with a priority value between 0 and 9. 0
- represents the lowest priority and 9 represents the highest. HornetQ will
- attempt to deliver higher priority messages before lower priority
- ones.</para>
+ <para>消息具有优先级。优先级的值为从0到9的整数。0代表最低优先级,9代表最高优先级。HornetQ总
+ 会尝试先传送优先级高的消息。</para>
</listitem>
<listitem>
- <para>Messages can be specified with an optional expiry time. HornetQ will not
- deliver messages after its expiry time has been exceeded.</para>
+ <para>消息还有一个可选的失效时间。如果一个消息过了失效时间,HornetQ将不再传送它。</para>
</listitem>
<listitem>
- <para>Messages also have an optional timestamp which represents the time the
- message was sent.</para>
+ <para>消息还有一个可选的时间戳(timestamp)。这个时间戳表示的是消息被发送的时间。</para>
</listitem>
<listitem>
- <para>HornetQ also supports the sending/consuming of very large messages - much
- larger than can fit in available RAM at any one time.</para>
+ <para>HornetQ还支持大消息的发送。它可以处理大到内存装不下的超大消息。</para>
</listitem>
</itemizedlist>
</section>
<section>
- <title>Address</title>
- <para>A server maintains a mapping between an address and a set of queues. Zero or more
- queues can be bound to a single address. Each queue can be bound with an optional
- message filter. When a message is routed, it is routed to the set of queues bound to
- the message's address. If any of the queues are bound with a filter expression, then
- the message will only be routed to the subset of bound queues which match that
- filter expression.</para>
- <para>Other entities, such as <emphasis role="italic">diverts</emphasis> can also be
- bound to an address and messages will also be routed there.</para>
+ <title>地址(Address)</title>
+ <para>HornetQ服务器保存有地址和queue的映射集。一个地址对应零个或多个queue。每个queue还可以拥有消息
+ 过滤器(filter)。当一个消息在服务器内进行路由时,它将会被送往与其地址相绑定的所有的queue中。但是
+ 如果其中某个queue有过滤器,那么只有与其过滤器相匹配的消息才会被发到这个queue中。</para>
+ <para>其它的实体如<emphasis role="italic">diverts</emphasis>也可以与一地址进行绑定,消息也会被同样
+ 路由到相应的实体中。</para>
<note>
- <para>In core, there is no concept of a Topic, Topic is a JMS only term. Instead, in
- core, we just deal with <emphasis>addresses</emphasis> and
- <emphasis>queues</emphasis>.</para>
- <para>For example, a JMS topic would implemented by a single address to which many
- queues are bound. Each queue represents a subscription of the topic. A JMS Queue
- would be implemented as a single address to which one queue is bound - that
- queue represents the JMS queue.</para>
+ <para>在内核中,没有Topic的概念。只有<emphasis>地址(address)</emphasis> 和
+ <emphasis>queue</emphasis>。</para>
+ <para>假如想在内核实现JMS topic的功能,只要将一地址绑定到多个queue即可。其中的每一个queue就相当
+ 于一个订阅(subscription)。类似地,一个JMS queue则可以通过一个地址与一个queue的绑定来实现。</para>
</note>
</section>
<section>
<title>Queue</title>
- <para>Queues can be durable, meaning the messages they contain survive a server crash or
- restart, as long as the messages in them are durable. Non durable queues do not
- survive a server restart or crash even if the messages they contain are
- durable.</para>
- <para>Queues can also be temporary, meaning they are automatically deleted when the
- client connection is closed, if they are not explicitly deleted before that.</para>
- <para>Queues can be bound with an optional filter expression. If a filter expression is
- supplied then the server will only route messages that match that filter expression
- to any queues bound to the address.</para>
- <para>Many queues can be bound to a single address. A particular queue is only bound to
- a maximum of one address.</para>
+ <para>Queue可以的持久的。意思是如果queue中的消息是持久的,那么当发生服务器故障或重启时,这些消息不会丢失。
+ Queue也可是非持久的,这意谓着如果服务器发的故障或重启,queue中的消息将会丢失,不管消息是不是持久的。</para>
+ <para>Queue也可以是临时的,意思是临时的queue在客户端断开连接时,它将会被删除。</para>
+ <para>Queue可以有一个过滤器表达式。服务器在向这样的queue路由消息时,先判定消息是否与过滤器表达式相匹配,
+ 只有匹配的消息才会被发到该queue。</para>
+ <para>一个地址可以绑定多个queue、。但是一个queue只能被绑定到一个地址上。</para>
</section>
<section>
<title>ClientSessionFactory</title>
- <para>Clients use <literal>ClientSessionFactory</literal> instances to create <literal
- >ClientSession</literal> instances. <literal>ClientSessionFactory</literal>
- instances know how to connect to the server to create sessions, and are configurable
- with many settings.</para>
- <para><literal>ClientSessionFactory</literal> instances are created using the <literal
- >HornetQClient</literal> factory class.</para>
+ <para>客户端使用 <literal>ClientSessionFactory</literal> 类的实例创建 <literal
+ >ClientSession</literal> 实例。 <literal>ClientSessionFactory</literal>
+ 知道如何连接到服务器并创建会话(session)。它是可以根据不同需要灵活配置的。</para>
+ <para><literal>ClientSessionFactory</literal>实例是通过 <literal
+ >HornetQClient</literal> 工厂类创建的。</para>
</section>
<section>
<title>ClientSession</title>
- <para>A client uses a ClientSession for consuming and producing messages and for
- grouping them in transactions. ClientSession instances can support both
- transactional and non transactional semantics and also provide an <literal
- >XAResource</literal> interface so messaging operations can be performed as part
- of a <ulink url="http://java.sun.com/javaee/technologies/jta/index.jsp">JTA</ulink>
- transaction.</para>
- <para>ClientSession instances group ClientConsumers and ClientProducers.</para>
- <para>ClientSession instances can be registered with an optional <literal
- >SendAcknowledgementHandler</literal>. This allows your client code to be
- notified asynchronously when sent messages have successfully reached the server.
- This unique HornetQ feature, allows you to have full guarantees that sent messages
- have reached the server without having to block on each message sent until a
- response is received. Blocking on each messages sent is costly since it requires a
- network round trip for each message sent. By not blocking and receiving send
- acknowledgements asynchronously you can create true end to end asynchronous systems
- which is not possible using the standard JMS API. For more information on this
- advanced feature please see the section <xref linkend="send-guarantees"/>.</para>
+ <para>客户端使用ClientSession来发送和接收消息,并控制事务的使用。ClientSession可以支持事务性
+ 和非事务性的应用。它还提供了一个 <literal
+ >XAResource</literal> 接口,因些它可以加入到一个<ulink url="http://java.sun.com/javaee/technologies/jta/index.jsp">JTA</ulink>
+ 交易中。</para>
+ <para>ClientSession 管理着ClientConsumers和ClientProducers。</para>
+ <para>ClientSession 实例可以注册一个可选的 <literal
+ >SendAcknowledgementHandler</literal>。每当消息被送达HornetQ服务器中时,
+ HornetQ就用它来异步地发出通知。有了这个独特的功能,客户可以不必阻塞在每次消息的发送操作上来保证
+ 消息安全到达服务器。如果采用阻塞的方法,那么每一个消息的发送都要包括往返两次的网络传递操作,开销
+ 是很大的。有了这个异步方式就可以避免这种开销,建立真正的异步的端到端间的系统。这是标准的JMS接口
+ 无法做到的。参见 <xref linkend="send-guarantees"/>了解相关的更详细的信息。</para>
</section>
<section>
<title>ClientConsumer</title>
- <para>Clients use <literal>ClientConsumer</literal> instances to consume messages from a
- queue. Core Messaging supports both synchronous and asynchronous message consumption
- semantics. <literal>ClientConsumer</literal> instances can be configured with an
- optional filter expression and will only consume messages which match that
- expression.</para>
+ <para>客户端使用 <literal>ClientConsumer</literal> 实例来接收来自queue的消息。HornetQ的内核同时支持
+ 同步与异步的消息接收。<literal>ClientConsumer</literal> 实例可以配置有可选的过滤器。它只接收与过滤
+ 器相匹配的消息。</para>
</section>
<section>
<title>ClientProducer</title>
- <para>Clients create <literal>ClientProducer</literal> instances on <literal
- >ClientSession</literal> instances so they can send messages. ClientProducer
- instances can specify an address to which all sent messages are routed, or they can
- have no specified address, and the address is specified at send time for the
- message.</para>
+ <para>客户端使用<literal>ClientSession</literal>创建 <literal>ClientProducer</literal> 实例
+ 来向服务器发送消息。ClientProducer可以指定一个地址,用来向其发送消息。或者不指定地址,消息在发送时
+ 再指定地址。</para>
</section>
<warning>
- <para>Please note that ClientSession, ClientProducer and ClientConsumer instances are
- <emphasis>designed to be re-used</emphasis>.</para>
- <para>It's an anti-pattern to create new ClientSession, ClientProducer and ClientConsumer instances
- for each message you produce or consume. If you do this, your application will
- perform very poorly. This is discussed further in the section on performance tuning
- <xref linkend="perf-tuning"/>.</para>
+ <para>请注意 ClientSession、 ClientProducer和ClientConsumer 实例是可以被
+ <emphasis>重用</emphasis>的。</para>
+ <para>在每次发送或接收一个消息时都创建新的 ClientSession, ClientProducer 和 ClientConsumer是不符合
+ 设计模式的要求的。这样做会导致性能低下。在<xref linkend="perf-tuning"/>中我们会做进一步的讨论。</para>
</warning>
</section>
<section>
- <title>A simple example of using Core</title>
- <para>Here's a very simple program using the core messaging API to send and receive a
- message:</para>
+ <title>一个内核的应用实例</title>
+ <para>下面是一个非常简单的使用内核API来发送的接收消息的实例:</para>
<programlisting>
ClientSessionFactory factory = HornetQClient.createClientSessionFactory(
new TransportConfiguration(
14 years, 2 months
JBoss hornetq SVN: r8956 - trunk.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2010-03-24 10:51:31 -0400 (Wed, 24 Mar 2010)
New Revision: 8956
Modified:
trunk/build-maven.xml
Log:
chnage version
Modified: trunk/build-maven.xml
===================================================================
--- trunk/build-maven.xml 2010-03-24 14:36:08 UTC (rev 8955)
+++ trunk/build-maven.xml 2010-03-24 14:51:31 UTC (rev 8956)
@@ -13,7 +13,7 @@
-->
<project default="upload" name="HornetQ">
- <property name="hornetq.version" value="2.1.0.r8945"/>
+ <property name="hornetq.version" value="2.1.0.r8956"/>
<property name="build.dir" value="build"/>
<property name="jars.dir" value="${build.dir}/jars"/>
14 years, 2 months
JBoss hornetq SVN: r8955 - trunk/src/main/org/hornetq/core/journal/impl.
by do-not-reply@jboss.org
Author: timfox
Date: 2010-03-24 10:36:08 -0400 (Wed, 24 Mar 2010)
New Revision: 8955
Modified:
trunk/src/main/org/hornetq/core/journal/impl/TimedBuffer.java
Log:
some sanity checking on TimedBuffer to prevent it being used when not started
Modified: trunk/src/main/org/hornetq/core/journal/impl/TimedBuffer.java
===================================================================
--- trunk/src/main/org/hornetq/core/journal/impl/TimedBuffer.java 2010-03-24 13:54:59 UTC (rev 8954)
+++ trunk/src/main/org/hornetq/core/journal/impl/TimedBuffer.java 2010-03-24 14:36:08 UTC (rev 8955)
@@ -20,7 +20,6 @@
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Semaphore;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import org.hornetq.api.core.HornetQBuffer;
@@ -203,6 +202,11 @@
*/
public synchronized boolean checkSize(final int sizeChecked)
{
+ if (!started)
+ {
+ throw new IllegalStateException("TimedBuffer is not started");
+ }
+
if (sizeChecked > bufferSize)
{
throw new IllegalStateException("Can't write records bigger than the bufferSize(" + bufferSize +
@@ -250,6 +254,11 @@
public synchronized void addBytes(final EncodingSupport bytes, final boolean sync, final IOAsyncTask callback)
{
+ if (!started)
+ {
+ throw new IllegalStateException("TimedBuffer is not started");
+ }
+
delayFlush = false;
bytes.encode(buffer);
@@ -292,6 +301,11 @@
{
synchronized (this)
{
+ if (!started)
+ {
+ throw new IllegalStateException("TimedBuffer is not started");
+ }
+
if ((force || !delayFlush) && buffer.writerIndex() > 0)
{
int pos = buffer.writerIndex();
14 years, 2 months
JBoss hornetq SVN: r8954 - trunk/tests/src/org/hornetq/tests/unit/core/deployers/impl.
by do-not-reply@jboss.org
Author: ataylor
Date: 2010-03-24 09:54:59 -0400 (Wed, 24 Mar 2010)
New Revision: 8954
Modified:
trunk/tests/src/org/hornetq/tests/unit/core/deployers/impl/QueueDeployerTest.java
Log:
fixed test
Modified: trunk/tests/src/org/hornetq/tests/unit/core/deployers/impl/QueueDeployerTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/core/deployers/impl/QueueDeployerTest.java 2010-03-24 13:28:09 UTC (rev 8953)
+++ trunk/tests/src/org/hornetq/tests/unit/core/deployers/impl/QueueDeployerTest.java 2010-03-24 13:54:59 UTC (rev 8954)
@@ -15,6 +15,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import junit.framework.Assert;
@@ -24,6 +25,8 @@
import org.hornetq.core.config.CoreQueueConfiguration;
import org.hornetq.core.deployers.DeploymentManager;
import org.hornetq.core.deployers.impl.QueueDeployer;
+import org.hornetq.core.security.Role;
+import org.hornetq.core.settings.impl.AddressSettings;
import org.hornetq.tests.util.UnitTestCase;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -576,7 +579,12 @@
public void removeSecuritySettings(String addressMatch) throws Exception
{
}
-
+
+ public Set<Role> getSecuritySettings(String addressMatch) throws Exception
+ {
+ return null;
+ }
+
public Object[] getRoles(String addressMatch) throws Exception
{
return null;
@@ -587,9 +595,24 @@
return null;
}
+ public void addAddressSettings(@Parameter(desc = "an address match", name = "addressMatch") String addressMatch, @Parameter(desc = "the dead letter address setting", name = "DLA") String DLA, @Parameter(desc = "the expiry address setting", name = "expiryAddress") String expiryAddress, @Parameter(desc = "are any queues created for this address a last value queue", name = "lastValueQueue") boolean lastValueQueue, @Parameter(desc = "the delivery attempts", name = "deliveryAttempts") int deliveryAttempts, @Parameter(desc = "the max size in bytes", name = "maxSizeBytes") long maxSizeBytes, @Parameter(desc = "the page size in bytes", name = "pageSizeBytes") int pageSizeBytes, @Parameter(desc = "the redelivery delay", name = "redeliveryDelay") long redeliveryDelay, @Parameter(desc = "the redistribution delay", name = "redistributionDelay") long redistributionDelay, @Parameter(desc = "do we send to the DLA when there is no where to route the message", name = "sendToDLAOnNoRou!
te") boolean sendToDLAOnNoRoute, @Parameter(desc = "the ploicy to use when the address is full", name = "addressFullMessagePolicy") String addressFullMessagePolicy) throws Exception
+ {
+
+ }
+
+ public AddressSettings getAddressSettings(String address)
+ {
+ return null;
+ }
+
+ public void removeAddressSettings(String addressMatch)
+ {
+
+ }
+
public String getAddressSettingsAsJSON(@Parameter(desc = "an address match", name = "addressMatch") String addressMatch) throws Exception
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return null;
}
}
14 years, 2 months
JBoss hornetq SVN: r8953 - in trunk: src/main/org/hornetq/core/management/impl and 2 other directories.
by do-not-reply@jboss.org
Author: ataylor
Date: 2010-03-24 09:28:09 -0400 (Wed, 24 Mar 2010)
New Revision: 8953
Modified:
trunk/src/main/org/hornetq/api/core/management/HornetQServerControl.java
trunk/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java
trunk/tests/src/org/hornetq/tests/integration/management/HornetQServerControlUsingCoreTest.java
Log:
fixed tests
Modified: trunk/src/main/org/hornetq/api/core/management/HornetQServerControl.java
===================================================================
--- trunk/src/main/org/hornetq/api/core/management/HornetQServerControl.java 2010-03-24 12:46:38 UTC (rev 8952)
+++ trunk/src/main/org/hornetq/api/core/management/HornetQServerControl.java 2010-03-24 13:28:09 UTC (rev 8953)
@@ -498,7 +498,7 @@
@Operation(desc = "Remove security settings for an address", impact = MBeanOperationInfo.ACTION)
void removeSecuritySettings(@Parameter(desc = "an address match", name = "addressMatch") String addressMatch) throws Exception;
- Set<Role> getSecuritySettings(String addressMatch);
+ Set<Role> getSecuritySettings(String addressMatch) throws Exception;
@Operation(desc = "get roles for a specific address match", impact = MBeanOperationInfo.INFO)
Object[] getRoles(@Parameter(desc = "an address match", name = "addressMatch") String addressMatch) throws Exception;
Modified: trunk/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java 2010-03-24 12:46:38 UTC (rev 8952)
+++ trunk/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java 2010-03-24 13:28:09 UTC (rev 8953)
@@ -1089,7 +1089,7 @@
}
}
- public Set<Role> getSecuritySettings(String addressMatch)
+ public Set<Role> getSecuritySettings(String addressMatch) throws Exception
{
clearIO();
try
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java 2010-03-24 12:46:38 UTC (rev 8952)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java 2010-03-24 13:28:09 UTC (rev 8953)
@@ -300,47 +300,6 @@
});
}
- public void testSecuritySettings() throws Exception
- {
- JMSServerControl serverControl = createManagementControl();
- String destination = HornetQDestination.createQueueAddressFromName(randomString()).toString();
-
- serverControl.addSecuritySettings(destination, "foo", "foo, bar", "foo", "bar", "foo, bar", "", "");
-
- String rolesAsJSON = serverControl.getSecuritySettingsAsJSON(destination);
- RoleInfo[] roleInfos = RoleInfo.from(rolesAsJSON);
- assertEquals(2, roleInfos.length);
- RoleInfo fooRole = null;
- RoleInfo barRole = null;
- if (roleInfos[0].getName().equals("foo"))
- {
- fooRole = roleInfos[0];
- barRole = roleInfos[1];
- }
- else
- {
- fooRole = roleInfos[1];
- barRole = roleInfos[0];
- }
- assertTrue(fooRole.isSend());
- assertTrue(fooRole.isConsume());
- assertTrue(fooRole.isCreateDurableQueue());
- assertFalse(fooRole.isDeleteDurableQueue());
- assertTrue(fooRole.isCreateNonDurableQueue());
- assertFalse(fooRole.isDeleteNonDurableQueue());
- assertFalse(fooRole.isManage());
-
- assertFalse(barRole.isSend());
- assertTrue(barRole.isConsume());
- assertFalse(barRole.isCreateDurableQueue());
- assertTrue(barRole.isDeleteDurableQueue());
- assertTrue(barRole.isCreateNonDurableQueue());
- assertFalse(barRole.isDeleteNonDurableQueue());
- assertFalse(barRole.isManage());
-
- serverControl.removeSecuritySettings(destination);
- }
-
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: trunk/tests/src/org/hornetq/tests/integration/management/HornetQServerControlUsingCoreTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/management/HornetQServerControlUsingCoreTest.java 2010-03-24 12:46:38 UTC (rev 8952)
+++ trunk/tests/src/org/hornetq/tests/integration/management/HornetQServerControlUsingCoreTest.java 2010-03-24 13:28:09 UTC (rev 8953)
@@ -22,7 +22,11 @@
import org.hornetq.api.core.management.ResourceNames;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
+import org.hornetq.core.security.Role;
+import org.hornetq.core.settings.impl.AddressSettings;
+import java.util.Set;
+
/**
* A HornetQServerControlUsingCoreTest
*
@@ -466,7 +470,12 @@
public void removeSecuritySettings(String addressMatch) throws Exception {
proxy.invokeOperation("removeSecuritySettings", addressMatch);
- };
+ }
+
+ public Set<Role> getSecuritySettings(String addressMatch) throws Exception
+ {
+ return (Set<Role>)proxy.invokeOperation("removeSecuritySettings", addressMatch);
+ }
public Object[] getRoles(String addressMatch) throws Exception
{
@@ -478,6 +487,21 @@
return (String)proxy.invokeOperation("getRolesAsJSON", addressMatch);
}
+ public void addAddressSettings(@Parameter(desc = "an address match", name = "addressMatch") String addressMatch, @Parameter(desc = "the dead letter address setting", name = "DLA") String DLA, @Parameter(desc = "the expiry address setting", name = "expiryAddress") String expiryAddress, @Parameter(desc = "are any queues created for this address a last value queue", name = "lastValueQueue") boolean lastValueQueue, @Parameter(desc = "the delivery attempts", name = "deliveryAttempts") int deliveryAttempts, @Parameter(desc = "the max size in bytes", name = "maxSizeBytes") long maxSizeBytes, @Parameter(desc = "the page size in bytes", name = "pageSizeBytes") int pageSizeBytes, @Parameter(desc = "the redelivery delay", name = "redeliveryDelay") long redeliveryDelay, @Parameter(desc = "the redistribution delay", name = "redistributionDelay") long redistributionDelay, @Parameter(desc = "do we send to the DLA when there is no where to route the message", name = "sendToDLAOnNo!
Route") boolean sendToDLAOnNoRoute, @Parameter(desc = "the ploicy to use when the address is full", name = "addressFullMessagePolicy") String addressFullMessagePolicy) throws Exception
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public AddressSettings getAddressSettings(String address)
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void removeAddressSettings(String addressMatch)
+ {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public String getAddressSettingsAsJSON(@Parameter(desc = "an address match", name = "addressMatch") String addressMatch) throws Exception
{
return (String)proxy.invokeOperation("getAddressSettingsAsJSON", addressMatch);
14 years, 2 months
JBoss hornetq SVN: r8952 - in trunk: src/main/org/hornetq/api/jms/management and 3 other directories.
by do-not-reply@jboss.org
Author: ataylor
Date: 2010-03-24 08:46:38 -0400 (Wed, 24 Mar 2010)
New Revision: 8952
Modified:
trunk/src/main/org/hornetq/api/core/management/HornetQServerControl.java
trunk/src/main/org/hornetq/api/jms/management/JMSServerControl.java
trunk/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java
trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
Log:
moved address and security management methods from jms to core where they belong
Modified: trunk/src/main/org/hornetq/api/core/management/HornetQServerControl.java
===================================================================
--- trunk/src/main/org/hornetq/api/core/management/HornetQServerControl.java 2010-03-24 11:56:47 UTC (rev 8951)
+++ trunk/src/main/org/hornetq/api/core/management/HornetQServerControl.java 2010-03-24 12:46:38 UTC (rev 8952)
@@ -17,11 +17,13 @@
import org.hornetq.api.core.HornetQException;
import org.hornetq.api.core.Interceptor;
+import org.hornetq.core.security.Role;
import org.hornetq.core.settings.impl.AddressFullMessagePolicy;
import org.hornetq.core.settings.impl.AddressSettings;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
/**
* A HornetQServerControl is used to manage HornetQ servers.
@@ -496,13 +498,38 @@
@Operation(desc = "Remove security settings for an address", impact = MBeanOperationInfo.ACTION)
void removeSecuritySettings(@Parameter(desc = "an address match", name = "addressMatch") String addressMatch) throws Exception;
+ Set<Role> getSecuritySettings(String addressMatch);
+
@Operation(desc = "get roles for a specific address match", impact = MBeanOperationInfo.INFO)
Object[] getRoles(@Parameter(desc = "an address match", name = "addressMatch") String addressMatch) throws Exception;
@Operation(desc = "get roles (as a JSON string) for a specific address match", impact = MBeanOperationInfo.INFO)
String getRolesAsJSON(@Parameter(desc = "an address match", name = "addressMatch") String addressMatch) throws Exception;
- @Operation(desc = "get address settings (as a JSON string) for a specific address match", impact = MBeanOperationInfo.INFO)
- String getAddressSettingsAsJSON(@Parameter(desc = "an address match", name = "addressMatch") String addressMatch) throws Exception;
+ /**
+ * adds a new address setting for a specific address
+ */
+ @Operation(desc= "Add address settings for addresses matching the addressMatch", impact = MBeanOperationInfo.ACTION)
+ void addAddressSettings(@Parameter(desc="an address match", name="addressMatch") String addressMatch,
+ @Parameter(desc="the dead letter address setting", name="DLA") String DLA,
+ @Parameter(desc="the expiry address setting", name="expiryAddress") String expiryAddress,
+ @Parameter(desc="are any queues created for this address a last value queue", name="lastValueQueue") boolean lastValueQueue,
+ @Parameter(desc="the delivery attempts", name="deliveryAttempts") int deliveryAttempts,
+ @Parameter(desc="the max size in bytes", name="maxSizeBytes") long maxSizeBytes,
+ @Parameter(desc="the page size in bytes", name="pageSizeBytes") int pageSizeBytes,
+ @Parameter(desc="the redelivery delay", name="redeliveryDelay") long redeliveryDelay,
+ @Parameter(desc="the redistribution delay", name="redistributionDelay") long redistributionDelay,
+ @Parameter(desc="do we send to the DLA when there is no where to route the message", name="sendToDLAOnNoRoute") boolean sendToDLAOnNoRoute,
+ @Parameter(desc="the ploicy to use when the address is full", name="addressFullMessagePolicy") String addressFullMessagePolicy) throws Exception;
+ AddressSettings getAddressSettings(String address);
+
+ void removeAddressSettings(String addressMatch);
+
+ /**
+ * returns the address settings as a JSON string
+ */
+ @Operation(desc = "returns the address settings as a JSON string for an address match", impact = MBeanOperationInfo.INFO)
+ String getAddressSettingsAsJSON(@Parameter(desc="an address match", name="addressMatch") String addressMatch) throws Exception;
+
}
Modified: trunk/src/main/org/hornetq/api/jms/management/JMSServerControl.java
===================================================================
--- trunk/src/main/org/hornetq/api/jms/management/JMSServerControl.java 2010-03-24 11:56:47 UTC (rev 8951)
+++ trunk/src/main/org/hornetq/api/jms/management/JMSServerControl.java 2010-03-24 12:46:38 UTC (rev 8952)
@@ -204,48 +204,5 @@
@Operation(desc = "List the sessions for the given connectionID", impact = MBeanOperationInfo.INFO)
String[] listSessions(@Parameter(desc = "a connection ID", name = "connectionID") String connectionID) throws Exception;
- /**
- * adds a new address setting for a specific address
- */
- @Operation(desc= "Add address settings for addresses matching the addressMatch", impact = MBeanOperationInfo.ACTION)
- void addAddressSettings(@Parameter(desc="an address match", name="addressMatch") String addressMatch,
- @Parameter(desc="the dead letter address setting", name="DLA") String DLA,
- @Parameter(desc="the expiry address setting", name="expiryAddress") String expiryAddress,
- @Parameter(desc="are any queues created for this address a last value queue", name="lastValueQueue") boolean lastValueQueue,
- @Parameter(desc="the delivery attempts", name="deliveryAttempts") int deliveryAttempts,
- @Parameter(desc="the max size in bytes", name="maxSizeBytes") long maxSizeBytes,
- @Parameter(desc="the page size in bytes", name="pageSizeBytes") int pageSizeBytes,
- @Parameter(desc="the redelivery delay", name="redeliveryDelay") long redeliveryDelay,
- @Parameter(desc="the redistribution delay", name="redistributionDelay") long redistributionDelay,
- @Parameter(desc="do we send to the DLA when there is no where to route the message", name="sendToDLAOnNoRoute") boolean sendToDLAOnNoRoute,
- @Parameter(desc="the ploicy to use when the address is full", name="addressFullMessagePolicy") String addressFullMessagePolicy) throws Exception;
- AddressSettings getAddressSettings(String address);
-
- /**
- * returns the address settings as a JSON string
- */
- @Operation(desc = "returns the address settings as a JSON string for an address match", impact = MBeanOperationInfo.INFO)
- String getAddressSettingsAsJSON(@Parameter(desc="an address match", name="addressMatch") String addressMatch) throws Exception;
-
- @Operation(desc= "Add security settings for addresses matching the addressMatch", impact = MBeanOperationInfo.ACTION)
- void addSecuritySettings(
- @Parameter(desc="an address match", name="addressMatch") String addressMatch,
- @Parameter(desc="a comma-separated list of roles allowed to send messages", name="send") String sendRoles,
- @Parameter(desc="a comma-separated list of roles allowed to consume messages", name="consume") String consumeRoles,
- @Parameter(desc="a comma-separated list of roles allowed to create durable queues", name="createDurableQueueRoles") String createDurableQueueRoles,
- @Parameter(desc="a comma-separated list of roles allowed to delete durable queues", name="deleteDurableQueueRoles") String deleteDurableQueueRoles,
- @Parameter(desc="a comma-separated list of roles allowed to create temporary queues", name="createTempQueueRoles") String createTempQueueRoles,
- @Parameter(desc="a comma-separated list of roles allowed to delete temporary queues", name="deleteTempQueueRoles") String deleteTempQueueRoles,
- @Parameter(desc="a comma-separated list of roles allowed to send management messages messages", name="manage") String manageRoles) throws Exception;
-
- /**
- * removes the address settings as a JSON string
- */
- @Operation(desc = "removes the address settings for an address match", impact = MBeanOperationInfo.INFO)
- void removeSecuritySettings(@Parameter(desc="an address match", name="addressMatch") String addressMatch) throws Exception;
-
- Set<Role> getSecuritySettings(final String addressMatch) throws Exception;
-
- String getSecuritySettingsAsJSON(String destination) throws Exception;
}
Modified: trunk/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java 2010-03-24 11:56:47 UTC (rev 8951)
+++ trunk/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java 2010-03-24 12:46:38 UTC (rev 8952)
@@ -1088,7 +1088,19 @@
blockOnIO();
}
}
-
+
+ public Set<Role> getSecuritySettings(String addressMatch)
+ {
+ clearIO();
+ try
+ {
+ return server.getSecurityRepository().getMatch(addressMatch);
+ }
+ finally
+ {
+ blockOnIO();
+ }
+ }
public Object[] getRoles(String addressMatch) throws Exception
{
clearIO();
@@ -1164,6 +1176,57 @@
return jsonObject.toString();
}
+ public void addAddressSettings(final String address,
+ final String DLA,
+ final String expiryAddress,
+ final boolean lastValueQueue,
+ final int deliveryAttempts,
+ final long maxSizeBytes,
+ final int pageSizeBytes,
+ final long redeliveryDelay,
+ final long redistributionDelay,
+ final boolean sendToDLAOnNoRoute,
+ final String addressFullMessagePolicy) throws Exception
+ {
+ AddressSettings addressSettings = new AddressSettings();
+ addressSettings.setDeadLetterAddress(DLA == null?null:new SimpleString(DLA));
+ addressSettings.setExpiryAddress(expiryAddress == null?null:new SimpleString(expiryAddress));
+ addressSettings.setLastValueQueue(lastValueQueue);
+ addressSettings.setMaxDeliveryAttempts(deliveryAttempts);
+ addressSettings.setMaxSizeBytes(maxSizeBytes);
+ addressSettings.setPageSizeBytes(pageSizeBytes);
+ addressSettings.setRedeliveryDelay(redeliveryDelay);
+ addressSettings.setRedistributionDelay(redistributionDelay);
+ addressSettings.setSendToDLAOnNoRoute(sendToDLAOnNoRoute);
+ if(addressFullMessagePolicy == null)
+ {
+ addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
+ }
+ else if(addressFullMessagePolicy.equalsIgnoreCase("PAGE"))
+ {
+ addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
+ }
+ else if(addressFullMessagePolicy.equalsIgnoreCase("DROP"))
+ {
+ addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.DROP);
+ }
+ else if(addressFullMessagePolicy.equalsIgnoreCase("BLOCK"))
+ {
+ addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK);
+ }
+ server.getAddressSettingsRepository().addMatch(address, addressSettings);
+ }
+
+ public AddressSettings getAddressSettings(final String address)
+ {
+ return server.getAddressSettingsRepository().getMatch(address);
+ }
+
+ public void removeAddressSettings(String addressMatch)
+ {
+ server.getAddressSettingsRepository().removeMatch(addressMatch);
+ }
+
public void sendQueueInfoToQueue(final String queueName, final String address) throws Exception
{
clearIO();
Modified: trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java 2010-03-24 11:56:47 UTC (rev 8951)
+++ trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java 2010-03-24 12:46:38 UTC (rev 8952)
@@ -376,92 +376,8 @@
}
- public void addAddressSettings(final String address,
- final String DLA,
- final String expiryAddress,
- final boolean lastValueQueue,
- final int deliveryAttempts,
- final long maxSizeBytes,
- final int pageSizeBytes,
- final long redeliveryDelay,
- final long redistributionDelay,
- final boolean sendToDLAOnNoRoute,
- final String addressFullMessagePolicy) throws Exception
- {
- AddressSettings addressSettings = new AddressSettings();
- addressSettings.setDeadLetterAddress(DLA == null?null:new SimpleString(DLA));
- addressSettings.setExpiryAddress(expiryAddress == null?null:new SimpleString(expiryAddress));
- addressSettings.setLastValueQueue(lastValueQueue);
- addressSettings.setMaxDeliveryAttempts(deliveryAttempts);
- addressSettings.setMaxSizeBytes(maxSizeBytes);
- addressSettings.setPageSizeBytes(pageSizeBytes);
- addressSettings.setRedeliveryDelay(redeliveryDelay);
- addressSettings.setRedistributionDelay(redistributionDelay);
- addressSettings.setSendToDLAOnNoRoute(sendToDLAOnNoRoute);
- if(addressFullMessagePolicy == null)
- {
- addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
- }
- else if(addressFullMessagePolicy.equalsIgnoreCase("PAGE"))
- {
- addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
- }
- else if(addressFullMessagePolicy.equalsIgnoreCase("DROP"))
- {
- addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.DROP);
- }
- else if(addressFullMessagePolicy.equalsIgnoreCase("BLOCK"))
- {
- addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK);
- }
- server.addAddressSettings(address, addressSettings);
- }
- public AddressSettings getAddressSettings(final String address)
- {
- return server.getAddressSettings(address);
- }
- public String getAddressSettingsAsJSON(final String address) throws Exception
- {
- return server.getHornetQServer().getHornetQServerControl().getAddressSettingsAsJSON(address);
- }
-
- public void addSecuritySettings(final String addressMatch,
- final String sendRoles,
- final String consumeRoles,
- final String createDurableQueueRoles,
- final String deleteDurableQueueRoles,
- final String createTempQueueRoles,
- final String deleteTempQueueRoles,
- final String manageRoles) throws Exception
- {
- Set<Role> roles = SecurityFormatter.createSecurity(sendRoles, consumeRoles, createDurableQueueRoles, deleteDurableQueueRoles, createTempQueueRoles, deleteTempQueueRoles, manageRoles);
- server.addSecurity(addressMatch, roles);
- }
-
- public Set<Role> getSecuritySettings(final String addressMatch)
- {
- return server.getSecurity(addressMatch);
- }
-
- public String getSecuritySettingsAsJSON(final String addressMatch) throws Exception
- {
- JSONArray json = new JSONArray();
- Set<Role> roles = server.getSecurity(addressMatch);
-
- for (Role role : roles)
- {
- json.put(new JSONObject(role));
- }
- return json.toString();
- }
-
- public void removeSecuritySettings(String addressMatch) throws Exception
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
@Override
public MBeanInfo getMBeanInfo()
{
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java 2010-03-24 11:56:47 UTC (rev 8951)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java 2010-03-24 12:46:38 UTC (rev 8952)
@@ -238,53 +238,6 @@
return (String[])proxy.invokeOperation("listSessions", connectionID);
}
- public void addAddressSettings(String addressMatch,
- String DLA,
- String expiryAddress,
- boolean lastValueQueue,
- int deliveryAttempts,
- long maxSizeBytes,
- int pageSizeBytes,
- long redeliveryDelay,
- long redistributionDelay,
- boolean sendToDLAOnNoRoute,
- String addressFullMessagePolicy) throws Exception
- {
- // TODO Auto-generated method stub
-
- }
-
- public void addSecuritySettings(String addressMatch,
- String sendRoles,
- String consumeRoles,
- String createDurableQueueRoles,
- String deleteDurableQueueRoles,
- String createTempQueueRoles,
- String deleteTempQueueRoles,
- String manageRoles) throws Exception
- {
- proxy.invokeOperation("addSecuritySettings", addressMatch,
- sendRoles,
- consumeRoles,
- createDurableQueueRoles,
- deleteDurableQueueRoles,
- createTempQueueRoles,
- deleteTempQueueRoles,
- manageRoles);
- }
-
- public AddressSettings getAddressSettings(String address)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getAddressSettingsAsJSON(String addressMatch) throws Exception
- {
- // TODO Auto-generated method stub
- return null;
- }
-
public void removeSecuritySettings(String addressMatch) throws Exception
{
proxy.invokeOperation("removeSecuritySettings", addressMatch);
14 years, 2 months
JBoss hornetq SVN: r8951 - trunk/src/main/org/hornetq/core/message/impl.
by do-not-reply@jboss.org
Author: timfox
Date: 2010-03-24 07:56:47 -0400 (Wed, 24 Mar 2010)
New Revision: 8951
Modified:
trunk/src/main/org/hornetq/core/message/impl/MessageImpl.java
Log:
fixed race with copying and getting encoded buffer
Modified: trunk/src/main/org/hornetq/core/message/impl/MessageImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/message/impl/MessageImpl.java 2010-03-24 10:06:32 UTC (rev 8950)
+++ trunk/src/main/org/hornetq/core/message/impl/MessageImpl.java 2010-03-24 11:56:47 UTC (rev 8951)
@@ -48,11 +48,11 @@
public abstract class MessageImpl implements MessageInternal
{
// Constants -----------------------------------------------------
-
+
private static final Logger log = Logger.getLogger(MessageImpl.class);
public static final SimpleString HDR_ROUTE_TO_IDS = new SimpleString("_HQ_ROUTE_TO");
-
+
public static final int BUFFER_HEADER_SPACE = PacketImpl.PACKET_HEADERS_SIZE;
protected long messageID;
@@ -144,18 +144,26 @@
priority = other.getPriority();
properties = new TypedProperties(other.getProperties());
- bufferValid = other.bufferValid;
- endOfBodyPosition = other.endOfBodyPosition;
- endOfMessagePosition = other.endOfMessagePosition;
- copied = other.copied;
+ // This MUST be synchronized using the monitor on the other message to prevent it running concurrently
+ // with getEncodedBuffer(), otherwise can introduce race condition when delivering concurrently to
+ // many subscriptions and bridging to other nodes in a cluster
+ synchronized (other)
+ {
+ bufferValid = other.bufferValid;
+ endOfBodyPosition = other.endOfBodyPosition;
+ endOfMessagePosition = other.endOfMessagePosition;
+ copied = other.copied;
- if (other.buffer != null)
- {
- createBody(other.buffer.capacity());
- // We need to copy the underlying buffer too, since the different messsages thereafter might have different
- // properties set on them, making their encoding different
- buffer = other.buffer.copy(0, other.buffer.capacity());
- buffer.setIndex(other.buffer.readerIndex(), other.buffer.writerIndex());
+ if (other.buffer != null)
+ {
+ createBody(other.buffer.capacity());
+
+ // We need to copy the underlying buffer too, since the different messsages thereafter might have different
+ // properties set on them, making their encoding different
+ buffer = other.buffer.copy(0, other.buffer.capacity());
+
+ buffer.setIndex(other.buffer.readerIndex(), other.buffer.writerIndex());
+ }
}
}
@@ -214,9 +222,7 @@
{
if (buffer instanceof LargeMessageBufferInternal == false)
{
- bodyBuffer = new ResetLimitWrappedHornetQBuffer(BUFFER_HEADER_SPACE + DataConstants.SIZE_INT,
- buffer,
- this);
+ bodyBuffer = new ResetLimitWrappedHornetQBuffer(BUFFER_HEADER_SPACE + DataConstants.SIZE_INT, buffer, this);
}
else
{
@@ -257,7 +263,6 @@
this.type = type;
}
-
public boolean isDurable()
{
return durable;
@@ -434,7 +439,7 @@
buffer.setIndex(0, endOfMessagePosition);
bufferUsed = true;
-
+
return buffer;
}
}
@@ -800,12 +805,11 @@
// Private -------------------------------------------------------
-
private TypedProperties getProperties()
{
return properties;
}
-
+
// This must be synchronized as it can be called concurrently id the message is being delivered concurently to
// many queues - the first caller in this case will actually encode it
private synchronized HornetQBuffer encodeToBuffer()
@@ -830,7 +834,7 @@
// Position at end of body and skip past the message end position int.
// check for enough room in the buffer even tho it is dynamic
- if((endOfBodyPosition + 4) > buffer.capacity())
+ if ((endOfBodyPosition + 4) > buffer.capacity())
{
buffer.setIndex(0, endOfBodyPosition);
buffer.writeInt(0);
14 years, 2 months
JBoss hornetq SVN: r8950 - trunk/tests/src/org/hornetq/tests/timing/core/server/impl.
by do-not-reply@jboss.org
Author: timfox
Date: 2010-03-24 06:06:32 -0400 (Wed, 24 Mar 2010)
New Revision: 8950
Modified:
trunk/tests/src/org/hornetq/tests/timing/core/server/impl/QueueImplTest.java
Log:
fixed test
Modified: trunk/tests/src/org/hornetq/tests/timing/core/server/impl/QueueImplTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/timing/core/server/impl/QueueImplTest.java 2010-03-23 15:20:55 UTC (rev 8949)
+++ trunk/tests/src/org/hornetq/tests/timing/core/server/impl/QueueImplTest.java 2010-03-24 10:06:32 UTC (rev 8950)
@@ -64,16 +64,6 @@
// The tests ----------------------------------------------------------------
- public void testScheduledDirect() throws Exception
- {
- testScheduled(true);
- }
-
- public void testScheduledQueueing() throws Exception
- {
- testScheduled(false);
- }
-
public void testScheduledNoConsumer() throws Exception
{
QueueImpl queue = new QueueImpl(1,
@@ -149,7 +139,7 @@
assertRefListsIdenticalRefs(refs, consumer.getReferences());
}
- private void testScheduled(final boolean direct) throws Exception
+ public void testScheduled() throws Exception
{
QueueImpl queue = new QueueImpl(1,
new SimpleString("address1"),
@@ -165,13 +155,7 @@
FakeConsumer consumer = null;
- if (direct)
- {
- consumer = new FakeConsumer();
-
- queue.addConsumer(consumer);
- }
-
+
// Send one scheduled
long now = System.currentTimeMillis();
@@ -207,14 +191,12 @@
ref8.setScheduledDeliveryTime(now + 6000);
queue.addLast(ref8);
- if (!direct)
- {
- consumer = new FakeConsumer();
+ consumer = new FakeConsumer();
- queue.addConsumer(consumer);
+ queue.addConsumer(consumer);
- queue.deliverNow();
- }
+ queue.deliverNow();
+
List<MessageReference> refs = new ArrayList<MessageReference>();
14 years, 2 months
JBoss hornetq SVN: r8949 - branches/HnetQ_323_cn/docs/user-manual/zh.
by do-not-reply@jboss.org
Author: gaohoward
Date: 2010-03-23 11:20:55 -0400 (Tue, 23 Mar 2010)
New Revision: 8949
Modified:
branches/HnetQ_323_cn/docs/user-manual/zh/using-jms.xml
Log:
one more chapter done.
Modified: branches/HnetQ_323_cn/docs/user-manual/zh/using-jms.xml
===================================================================
--- branches/HnetQ_323_cn/docs/user-manual/zh/using-jms.xml 2010-03-23 15:18:38 UTC (rev 8948)
+++ branches/HnetQ_323_cn/docs/user-manual/zh/using-jms.xml 2010-03-23 15:20:55 UTC (rev 8949)
@@ -17,46 +17,32 @@
<!-- permitted by applicable law. -->
<!-- ============================================================================= -->
<chapter id="using-jms">
- <title>Using JMS</title>
- <para>Although HornetQ provides a JMS agnostic messaging API, many users will be more
- comfortable using JMS.</para>
- <para>JMS is a very popular API standard for messaging, and most messaging systems provide a JMS
- API. If you are completely new to JMS we suggest you follow the<ulink
- url="http://java.sun.com/products/jms/tutorial/1_3_1-fcs/doc/jms_tutorialTOC.html"> Sun
- JMS tutorial</ulink> - a full JMS tutorial is out of scope for this guide.</para>
- <para>HornetQ also ships with a wide range of examples, many of which demonstrate JMS API usage.
- A good place to start would be to play around with the simple JMS Queue and Topic example,
- but we also provide examples for many other parts of the JMS API. A full description of the
- examples is available in <xref linkend="examples"/>.</para>
- <para>In this section we'll go through the main steps in configuring the server for JMS and
- creating a simple JMS program. We'll also show how to configure and use JNDI, and also how
- to use JMS with HornetQ without using any JNDI.</para>
+ <title>使用JMS</title>
+ <para>很多用户喜欢使JMS,因此HornetQ提供了JMS服务。</para>
+ <para>JMS是一个普遍使用API标准,绝大多数的消息系统都提供JMS接口。如果你对JMS还不熟悉,建议你先参考一下
+ Sun的<ulink url="http://java.sun.com/products/jms/tutorial/1_3_1-fcs/doc/jms_tutorialTOC.html">
+ JMS 教程</ulink>。</para>
+ <para>HornetQ还提供了许多的JMS的示例程序(examples)。比如简单的JMS Queue和Topic的示例,就很适合初学者做为了
+ 解HornetQ JMS的起点。<xref linkend="examples"/>对这些示例作了详细的说明。</para>
+ <para>下面我们将带领读者一步步地配置HornetQ的JMS服务,并创建一个简单的JMS程序。我们还将展示如何在没有JNDI的情况下
+ 来使用HornetQ中的JMS。</para>
<section>
- <title>A simple ordering system</title>
- <para>For this chapter we're going to use a very simple ordering system as our example. It's
- a somewhat contrived example because of its extreme simplicity, but it serves to
- demonstrate the very basics of setting up and using JMS.</para>
- <para>We will have a single JMS Queue called <literal>OrderQueue</literal>, and we will have
- a single <literal>MessageProducer</literal> sending an order message to the queue and a
- single <literal>MessageConsumer</literal> consuming the order message from the
- queue.</para>
- <para>The queue will be a <literal>durable</literal> queue, i.e. it will survive a server
- restart or crash. We also want to predeploy the queue, i.e. specify the queue in the
- server JMS configuration so it's created automatically without us having to explicitly
- create it from the client.</para>
+ <title>一个简单的订购系统</title>
+ <para>本章我们将用一个简单的订购系统做为一个例子。尽管它十分简单,但是它能够很好地向大家展示JMS的设置和使用。</para>
+ <para>本例中有一个名为 <literal>OrderQueue</literal>JMS队列,还将有一个 <literal>MessageProducer</literal>
+ 用来向队列发送订购消息。发送到队列的消息由一个 <literal>MessageConsumer</literal> 来接收。</para>
+ <para>我们所用的队列是<literal>持久(durable)</literal>的队列,也就是说这个队列不受服务器故障的影响。当服务器
+ 发生故障重新启动后,这个队列仍然存在。我们需要把这个队列事先部署好。办法就是将队列写到JMS的配置文件中。当服务启动
+ 时将配置文件中的队列自动部署好。</para>
</section>
<section id="using-jms.server.configuration">
- <title>JMS Server Configuration</title>
- <para>The file <literal>hornetq-jms.xml</literal> on the server classpath contains any JMS
- Queue, Topic and ConnectionFactory instances that we wish to create and make available
- to lookup via the JNDI.</para>
- <para>A JMS ConnectionFactory object is used by the client to make connections to the
- server. It knows the location of the server it is connecting to, as well as many other
- configuration parameters. In most cases the defaults will be acceptable.</para>
- <para>We'll deploy a single JMS Queue and a single JMS Connection Factory instance on the
- server for this example but there are no limits to the number of Queues, Topics and
- Connection Factory instances you can deploy from the file. Here's our
- configuration:</para>
+ <title>JMS服务的配置</title>
+ <para><literal>hornetq-jms.xml</literal>文件包含了需要创建与部署的JMS Queue,Topic和ConnectionFactory
+ 的实例。该文件必须要指定在classpath中。从这个文件中部署好的对象都可以用JNDI来找到。</para>
+ <para>JMS客户端可以利用JMS ConnectionFactory对象来创建与服务器的连接。ConnectionFactory中有关于服务器地址的
+ 信息以及各种参数。通常使用这些参数的默认值即可。</para>
+ <para>这里我们将要在服务器端部署一个JMS队列和一个JMS ConnectionFactory (连接工厂)。当然完全可以部署多个JMS对象。
+ 下面给出了具体的配置内容:</para>
<programlisting>
<configuration xmlns="urn:hornetq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -77,38 +63,32 @@
</configuration>
</programlisting>
- <para>We deploy one ConnectionFactory called <literal>ConnectionFactory</literal> and bind
- it in just one place in JNDI as given by the <literal>entry</literal> element.
- ConnectionFactory instances can be bound in many places in JNDI if you require. </para>
+ <para>在本文件中我们部署了一个名为 <literal>ConnectionFactory</literal> 的一个连接工厂,并且将其绑定到
+ JNDI中。如果需要可以将一个连接工厂绑定为多个名称。只需要将绑定的名字加入到 <literal>entry</literal>
+ 中即可。</para>
<note>
- <para>The JMS connection factory references a <literal>connector</literal> called
- <literal>netty</literal>. This is a reference to a connector object deployed in
- the main core configuration file <literal>hornetq-configuration.xml</literal> which
- defines the transport and parameters used to actually connect to the server.</para>
+ <para>在JMS ConnectionFactory的配置中引用了一个名为 <literal>netty</literal>的<literal>connector</literal>。
+ 它实际上指向的是HornetQ核心中部署的一个连接器(connector)。它的配置在HornetQ的核心配置文件
+ <literal>hornetq-configuration.xml</literal> 中。它定义了采用何种传输与服务器连接。</para>
</note>
</section>
<section>
- <title>JNDI configuration</title>
- <para>When using JNDI from the client side you need to specify a set of JNDI properties
- which tell the JNDI client where to locate the JNDI server, amongst other things. These
- are often specified in a file called <literal>jndi.properties</literal> on the client
- classpath, or you can specify them directly when creating the JNDI initial context. A
- full JNDI tutorial is outside the scope of this document, please see the <ulink
- url="http://java.sun.com/products/jndi/tutorial/TOC.html">Sun JNDI tutorial</ulink>
- for more information on how to use JNDI.</para>
- <para>For talking to the JBoss JNDI Server, the jndi properties will look something like
- this:</para>
+ <title>JNDI的配置</title>
+ <para>当客户端使用JNDI时需要定义一些JNDI的参数。这些参数主要用来确定JNDI服务的地址。这些参数通常保存在
+ 一个名为 <literal>jndi.properties</literal> 的文件中。这个文件需要在客户端的classpath中。或者你
+ 可以在创建JNDI的InitialContext时将这些参数传进去。想了解全面的JNDI知识,可以参见 <ulink
+ url="http://java.sun.com/products/jndi/tutorial/TOC.html">Sun JNDI 教程</ulink>
+ 。</para>
+ <para>要与JBoss的JNDI Server进行通迅,需要指定以下的JNDI参数:</para>
<programlisting>
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://myhost:1099
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
</programlisting>
- <para>Where <literal>myhost</literal> is the hostname or IP address of the JNDI server. 1099
- is the port used by the JNDI server and may vary depending on how you have configured
- your JNDI server.</para>
- <para>In the default standalone configuration, JNDI server ports are configured in the file
- <literal>hornetq-beans.xml</literal> by setting properties on the <literal
- >JNDIServer</literal> bean:</para>
+ <para>其中的 <literal>myhost</literal> 是 JNDI server的主机名或IP地址。 1099是端口号,根据不同的配置,
+ 端口号也可能不同。</para>
+ <para>在默认的单独方式(standalone)配置中,JNDI服务端口等参数定义在<literal>hornetq-beans.xml</literal>
+ 文件中的 <literal>JNDIServer</literal> bean下,如:</para>
<programlisting>
<bean name="JNDIServer" class="org.jnp.server.Main">
<property name="namingInfo">
@@ -121,119 +101,102 @@
</bean>
</programlisting>
<note>
- <para>If you want your JNDI server to be available to non local clients make sure you
- change it's bind address to something other than <literal
- >localhost</literal>!</para>
+ <para>如果你的JNDI服务器与客户端不在同一台机器上,一定不要忘记将bindAddress改成相应的地址,
+ 千万不能用<literal>localhost</literal>!</para>
</note>
<note>
- <para>The JNDIServer bean must be defined <emphasis>only when HornetQ is running in
- stand-alone mode</emphasis>. When HornetQ is integrated to JBoss Application
- Server, JBoss AS will provide a ready-to-use JNDI server without any additional
- configuration.</para>
+ <para><emphasis>只有当HornetQ作为独立服务器运行时</emphasis>
+ 才可以配置JNDIServer bean。当HornetQ运行于JBoss应用服务器中时,由于JBOSS服务器已经提供了
+ JNDI服务,所以就不需要再进行配置了。</para>
</note>
</section>
<section>
- <title>The code</title>
- <para>Here's the code for the example:</para>
- <para>First we'll create a JNDI initial context from which to lookup our JMS objects:</para>
+ <title>程序代码</title>
+ <para>下面给出的例子中的代码:</para>
+ <para>首先我们创建一个JNDI的Initial Context:</para>
<programlisting>InitialContect ic = new InitialContext();</programlisting>
- <para>Now we'll look up the connection factory:</para>
+ <para>下面我们查找 connection factory:</para>
<programlisting>ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");</programlisting>
- <para>And look up the Queue:</para>
+ <para>然后查找 Queue:</para>
<programlisting>Queue orderQueue = (Queue)ic.lookup("/queues/OrderQueue");</programlisting>
- <para>Next we create a JMS connection using the connection factory:</para>
+ <para>接下来用拿到的ConnectionFactory建立JMS连接:</para>
<programlisting>Connection connection = cf.createConnection();</programlisting>
- <para>And we create a non transacted JMS Session, with AUTO_ACKNOWLEDGE acknowledge
- mode:</para>
+ <para>再创建一个非事务的、AUTO_ACKNOWLEDGE方式的JMS Session:</para>
<programlisting>Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);</programlisting>
- <para>We create a MessageProducer that will send orders to the queue:</para>
+ <para>创建一个 MessageProducer 以向队列发送订单消息:</para>
<programlisting>MessageProducer producer = session.createProducer(orderQueue);</programlisting>
- <para>And we create a MessageConsumer which will consume orders from the queue:</para>
+ <para>创建一个 MessageConsumer 以从队列中接收订单消息:</para>
<programlisting>MessageConsumer consumer = session.createConsumer(orderQueue);</programlisting>
- <para>We make sure we start the connection, or delivery won't occur on it:</para>
+ <para>要启动连接,以使消息能传递给接收者:</para>
<programlisting>connection.start();</programlisting>
- <para>We create a simple TextMessage and send it:</para>
+ <para>发送一个简单的TextMessage:</para>
<programlisting>TextMessage message = session.createTextMessage("This is an order");
producer.send(message);</programlisting>
- <para>And we consume the message:</para>
+ <para>之后接收这个消息:</para>
<programlisting>TextMessage receivedMessage = (TextMessage)consumer.receive();
System.out.println("Got order: " + receivedMessage.getText());
</programlisting>
- <para>It's as simple as that. For a wide range of working JMS examples please see the
- examples directory in the distribution.</para>
+ <para>看起来就是这么简单。 在HornetQ有发布包中有很多各种各样的JMS例子供用户参考。</para>
<warning>
- <para>Please note that JMS connections, sessions, producers and consumers are
- <emphasis>designed to be re-used</emphasis>.</para>
- <para>It's an anti-pattern to create new connections, sessions, producers and consumers
- for each message you produce or consume. If you do this, your application will
- perform very poorly. This is discussed further in the section on performance tuning
- <xref linkend="perf-tuning"/>.</para>
+ <para>请注意,JMS的连接(connection)、会话(session)、生产者(producer)和消费者(consumer)
+ 对象是可以<emphasis>重用</emphasis>的。</para>
+ <para>如果每发送或接收一个消息都要重新创建这些JMS对象,是不符合设计模式的要求的。这样做会造成应用程序
+ 的性能很差。这方面的内容在<xref linkend="perf-tuning"/>中将会进一步的讨论。</para>
</warning>
</section>
<section>
- <title>Directly instantiating JMS Resources without using JNDI</title>
- <para>Although it's a very common JMS usage pattern to lookup JMS <emphasis>Administered
- Objects</emphasis> (that's JMS Queue, Topic and ConnectionFactory instances) from
- JNDI, in some cases a JNDI server is not available and you still want to use JMS, or you
- just think "Why do I need JNDI? Why can't I just instantiate these objects
- directly?"</para>
- <para>With HornetQ you can do exactly that. HornetQ supports the direct instantiation of JMS
- Queue, Topic and ConnectionFactory instances, so you don't have to use JNDI at
- all.</para>
- <para>For a full working example of direct instantiation please see the JMS examples in
- <xref linkend="examples"/>.</para>
- <para>Here's our simple example, rewritten to not use JNDI at all:</para>
- <para>We create the JMS ConnectionFactory object via the HornetQJMSClient Utility class,
- note we need to provide connection parameters and specify which transport we are using,
- for more information on connectors please see <xref linkend="configuring-transports"
- />.</para>
+ <title>不使用JNDI而直接创建JMS的对象</title>
+ <para>尽管采用JNDI对 JMS 的各种<emphasis>管理对象(Administered
+ Objects)</emphasis> (即JMS Queue, Topic and ConnectionFactory)是很常用的方法,但在有些
+ 情况时JNDI不可用,或者你不需要用JNDI时,如何还能正常使用JMS呢?</para>
+ <para>HornetQ允许你不通过JNDI也能使用JMS。HornetQ支持直接创建JMS的各种对象而无需JNDI的存在。</para>
+ <para>在<xref linkend="examples"/>中包括有这样的例子供读者参考。</para>
+ <para>下面我们就将上述那个简单的例子重写,以抛开对JNDI的依赖:</para>
+ <para>我们通过HornetQJMSClient类来方便地创建JMS的ConnectionFactory。注意这里要提供各种连接参数和定义
+ 所用的传输方式。有关连接器(connector)的信息参见<xref linkend="configuring-transports"
+ />。</para>
<programlisting>
TransportConfiguration transportConfiguration =
new TransportConfiguration(NettyConnectorFactory.class.getName());
ConnectionFactory cf = HornetQJMSClient.createConnectionFactory(transportConfiguration);
</programlisting>
- <para>We also create the JMS Queue object via the HornetQJMSClient Utility class:</para>
+ <para>同样利用HornetQJMSClient类创建JMS Queue对象:</para>
<programlisting>Queue orderQueue = HornetQJMSClient.createQueue("OrderQueue");</programlisting>
- <para>Next we create a JMS connection using the connection factory:</para>
+ <para>然后用连接工厂创建 JMS 连接:</para>
<programlisting>Connection connection = cf.createConnection();</programlisting>
- <para>And we create a non transacted JMS Session, with AUTO_ACKNOWLEDGE acknowledge
- mode:</para>
+ <para>还有非事务的\AUTO_ACKNOWLEDGE方式的 JMS 会话(session):</para>
<programlisting>Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);</programlisting>
- <para>We create a MessageProducer that will send orders to the queue:</para>
+ <para>以及用于发送消息的MessageProducer:</para>
<programlisting>MessageProducer producer = session.createProducer(orderQueue);</programlisting>
- <para>And we create a MessageConsumer which will consume orders from the queue:</para>
+ <para>和接收消息的 MessageConsumer:</para>
<programlisting>MessageConsumer consumer = session.createConsumer(orderQueue);</programlisting>
- <para>We make sure we start the connection, or delivery won't occur on it:</para>
+ <para>启动连接:</para>
<programlisting>connection.start();</programlisting>
- <para>We create a simple TextMessage and send it:</para>
+ <para>创建一个简单的 TextMessage 并将其发送到队列:</para>
<programlisting>TextMessage message = session.createTextMessage("This is an order");
producer.send(message);</programlisting>
- <para>And we consume the message:</para>
+ <para>接收消息:</para>
<programlisting>TextMessage receivedMessage = (TextMessage)consumer.receive();
System.out.println("Got order: " + receivedMessage.getText());
</programlisting>
</section>
<section id="using-jms.clientid">
- <title>Setting The Client ID</title>
- <para>This represents the client id for a JMS client and is needed for creating durable
- subscriptions. It is possible to configure this on the connection factory and can be set
- via the <literal>client-id</literal> element. Any connection created by this connection
- factory will have this set as its client id.</para>
+ <title>Client ID的设置</title>
+ <para>在建立持久的订阅(subscription)时,JMS客户需要有一个客户ID (client id)。我们可以通过配置
+ connection factory来定义它。(其中的 <literal>client-id</literal>项)。这样所有通过这个
+ connection factory来创建的连接都具有这个客户ID。</para>
</section>
<section id="using-jms.dupsokbatchsize">
- <title>Setting The Batch Size for DUPS_OK </title>
- <para>When the JMS acknowledge mode is set to <literal>DUPS_OK</literal> it is possible to
- configure the consumer so that it sends acknowledgements in batches rather that one at a
- time, saving valuable bandwidth. This can be configured via the connection factory via
- the <literal>dups-ok-batch-size</literal> element and is set in bytes. The default is
- 1024 * 1024 bytes = 1 MiB.</para>
+ <title>设置DUPS_OK的Batch Size </title>
+ <para>如果JMS的通知模式为<literal>DUPS_OK</literal>,我们可以配置接收者(consumer)以使得它以批为单位
+ 发送通知,而不是一个一个地发通知。这样做可以节省很多带宽,效率高。配置的方法是设置connection factory下
+ 的<literal>dups-ok-batch-size</literal>项。单位是字节(byte)。默认值是1024 * 1024 bytes = 1 MiB。</para>
</section>
<section id="using-jms.txbatchsize">
- <title>Setting The Transaction Batch Size</title>
- <para>When receiving messages in a transaction it is possible to configure the consumer to
- send acknowledgements in batches rather than individually saving valuable bandwidth.
- This can be configured on the connection factory via the <literal
- >transaction-batch-size</literal> element and is set in bytes. The default is 1024 *
- 1024.</para>
+ <title>设置事务(Transaction)的Batch Size</title>
+ <para>当在一个事务内接收消息时,可能通过配置使接收者采用批量的方式发送通知,而不是一个一个的发送。这样也可以节省带宽。
+ 配置方法是设置connection factory下的<literal
+ >transaction-batch-size</literal>项。 单位是字节(byte)。默认值是1024 *
+ 1024。</para>
</section>
</chapter>
14 years, 2 months