Return-Path: X-Original-To: apmail-qpid-users-archive@www.apache.org Delivered-To: apmail-qpid-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0C5B89FFB for ; Wed, 16 May 2012 17:02:50 +0000 (UTC) Received: (qmail 9294 invoked by uid 500); 16 May 2012 17:02:49 -0000 Delivered-To: apmail-qpid-users-archive@qpid.apache.org Received: (qmail 9262 invoked by uid 500); 16 May 2012 17:02:49 -0000 Mailing-List: contact users-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@qpid.apache.org Delivered-To: mailing list users@qpid.apache.org Received: (qmail 9254 invoked by uid 99); 16 May 2012 17:02:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 May 2012 17:02:49 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of gogden@gmail.com designates 209.85.213.42 as permitted sender) Received: from [209.85.213.42] (HELO mail-yw0-f42.google.com) (209.85.213.42) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 May 2012 17:02:41 +0000 Received: by yhfq11 with SMTP id q11so994258yhf.15 for ; Wed, 16 May 2012 10:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=mo5+z1BvR8P0eKbQDNDZVLoCZlS1SQ5VMlQfJabQOp8=; b=JMc/4TAQT+WeQbcFjknGe5XXpEkHa1c93ZerCv/FE+HGg3NTzfSBiN1brjw/H6DEj8 kTJw1AwnVVPMsP1vRurHLXY3TFznadyxA4V1Y9CSHkJKKiEDE23KHtxCIDCOPEnweGRW VfNPhu3weSrG049Gf5PcTQwBlr1l/drlX2QWRePOtgTRpkNrvnoEXO5yoCHI7PqgPXo6 sy3N1IZaSGU7FjlexF9PEfHAu+ajgpN9AUScPitnKFyF8j9ycHsJuWNc0NFIx06EazfK d4SN5MC3dj6QFB//hRpSzwqmNx5FdczQgZ2iJP/XkIOJRV0QHqKlWWCLmMPSba95Azfl 77lQ== MIME-Version: 1.0 Received: by 10.101.165.23 with SMTP id s23mr1310062ano.51.1337187740998; Wed, 16 May 2012 10:02:20 -0700 (PDT) Received: by 10.236.182.135 with HTTP; Wed, 16 May 2012 10:02:20 -0700 (PDT) In-Reply-To: References: Date: Wed, 16 May 2012 14:02:20 -0300 Message-ID: Subject: Re: persistent messages From: Gary Ogden To: users@qpid.apache.org Content-Type: multipart/alternative; boundary=001636ed641c4cdb7704c02a48de --001636ed641c4cdb7704c02a48de Content-Type: text/plain; charset=ISO-8859-1 Thanks for all the help. I'm now able to have a persistent queue using Derby. Is it more advantageous in a production environment to use BDB instead? I found details on queue sizes. I see you can specify the max size and count of a queue, but what are the defaults if you don't specify? Will it just keep queuing them up forever if a consumer never attaches? On 15 May 2012 19:18, Robbie Gemmell wrote: > Out of interest, can I ask what client/broker versions you are using? > It would be useful to target advice accordingly, although my first > suggestion is that you switch to using the 0.16 release candidate (its > under vote and well on course to being declared the final) if you > arent already, currently available at: > http://people.apache.org/~jross/qpid-0.16-rc4/ > > On 15 May 2012 21:05, Gary Ogden wrote: > > So I did some more reading and I now understand why the messages weren't > > being retained. So I need to create a queue, and have that queue created > in > > the virtualhosts file so that the broker starts it up. But even after > doing > > that, I still have the issue where the messages are getting dropped until > > the consumer starts. > > > > The isue here is that you are sending messages to an exchange with a > given routing key, but that key (which is typically the queue name, or > topic name/subject when using the JMS client) has not yet been used as > a binding key to bind a queue to the exchange. In this case the > exchange is unable to route the messages anywhere, and has thus > discarded them (which is logged). When you connect your client, it > must then be causing an appropriate binding to be eastblished. I can > think of 1 bug we resolved some time ago (but it may only now be > included as part of 0.16) that would cause such annoyance when using > queues in the configuration file in this regard, causing them not to > be bound to the nameless 'default' exchange with their name, which is > the binding used by the clients default addressing syntax when > 'sending to Queues'. However, I notice your producer code below > appears to be sending to the amq.direct exchange so it may not be > related here. > > As an aside, you can create queues in the configuration files, through > the brokers JMX management interface, or using message clients > themselves. > > > Here's my VH file: > > > > > > blah > > > > > > blahqueue > > > > amq.direct > > 4235264 > > 2117632 > > 600000 > > > > > > > > > > > > If this is truly all you have in there, your peristent messages will > not be retained when you restart because it defaults to the > MemoryMessageStore. There are two persistent store implementations, > one based on Derby and an optional one based on BerkeleyDB Java > Edition (which is available under the Sleepycat licence, which isnt > compatible with the Apache Licence). You can configure their on a > per-virtualhost basis use by inserting one of the following into a > given virtualhosts configuraton (see > > http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/etc/virtualhosts.xml?revision=1195211&view=co > for context of a full config file), substituting the placeholders I > added: > > MemoryMessageStore: > > org.apache.qpid.server.store.MemoryMessageStore > > > DerbyMessageStore: > > org.apache.qpid.server.store.DerbyMessageStore > PATH.TO.STORE.FILES/derbystore/VHOST.NAME > > > > > org.apache.qpid.server.store.berkeleydb.BDBMessageStore > PATH.TO.STORE.FILES/bdbstore/VHOST.NAME > > > > In order to use the last one, you would also need to download BDB JE > from the Oracle website, and place the je-X.Y.Z.jar file into a > /lib/opt/ directory where it will then get picked up. > > > Here's my properties file: > > > > java.naming.factory.initial = > > org.apache.qpid.jndi.PropertiesFileInitialContextFactory > > connectionfactory.qpidConnectionfactory = amqp://guest:guest@clientid > > /blah?brokerlist='tcp://localhost:5672' > > destination.queueExchange = amq.direct > > > > The property above is defining the address of an Exchange, as opposed > to the specific Queue which you suggest above is what you actually > want to send to (and what you are consuming from? It may be helpful to > post the matching consumer code) > > The format for the address strings is described fruther at: > > http://qpid.apache.org/books/trunk/Programming-In-Apache-Qpid/html/section-addresses.html > but a basic address string which defines a queue named blahqueue and > tells the client never to create the queue (at the point of > establishing a producer or consumer) might be: > > destination.queueAddress = blahqueue; {create: never, node: { type: queue > } } > > > Here's a simple method to produce: > > private void startProducing() { > > Context context = null; > > Connection connection = null; > > try { > > Properties properties = new Properties(); > > > > properties.load(this.getClass().getResourceAsStream("blah.properties")); > > context = new InitialContext(properties); > > > > ConnectionFactory connectionFactory = (ConnectionFactory) > > context.lookup("qpidConnectionfactory"); > > connection = connectionFactory.createConnection(); > > connection.start(); > > > > Session session = connection.createSession(false, > > Session.AUTO_ACKNOWLEDGE); > > Destination destination = (AMQAnyDestination) > > context.lookup("queueExchange"); > > > > MessageProducer messageProducer = > > session.createProducer(destination); > > int count = 0; > > while (true) { > > DataInputStream dis = new DataInputStream(new > > FileInputStream("test.xml")); > > try { > > File testFile = new File("test.xml"); > > long len = new File("test.xml").length(); > > System.out.println("test.xml length = " + len); > > byte[] bytes = new byte[(int) len]; > > dis.readFully(bytes); > > for (int i = 0; i <= 100; i++) { > > count++; > > System.out.println(" [x] Sending test.xml. > Time > > = " + System.currentTimeMillis()); > > BytesMessage message = > > session.createBytesMessage(); > > message.writeBytes(bytes); > > messageProducer.send(message); > > System.out.println(" [x] Sent test.xml + " + > > count + ". Time = " + System.currentTimeMillis()); > > } > > } finally { > > dis.close(); > > } > > Thread.sleep(4000); > > } > > } catch (Exception e) { > > System.out.println("Exception caught: " + e.getMessage() + > > e.getStackTrace().toString()); > > try { > > if (context != null) { > > context.close(); > > } > > if (connection != null) { > > connection.close(); > > } > > } catch (Exception ex) { > > System.out.println("Exception caught closing > > connection: " + e.getMessage()); > > } > > > > } > > } > > > > What am I missing? It still waits for the consumer and no messages get > > queued. > > Regards, > Robbie > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org > For additional commands, e-mail: users-help@qpid.apache.org > > --001636ed641c4cdb7704c02a48de--