qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mahmoud Parsian <mpars...@yahoo.com>
Subject Re: putting a message into a defined queue (created by a qpid server at startup time)
Date Mon, 16 May 2011 22:45:18 GMT
Hi Rajith,


Yes, I do agree with you and my next step is to use JNDI/JMS without using AMQ** classes
(but first I wanted to make sure that the qpid stuff works! and it works just fine!).
Thank you.
best,
Mahmoud


________________________________
From: Rajith Attapattu <rajith77@gmail.com>
To: users@qpid.apache.org; Mahmoud Parsian <mparsian@yahoo.com>
Sent: Monday, May 16, 2011 3:14 PM
Subject: Re: putting a message into a defined queue (created by a qpid server at startup time)

Hello Mahmoud,

This is not recommended at all.
The AMQ** classes are internal classes and can change between releases.

You are supposed to use the JMS API along with JNDI.
If you need to create queues on the fly, you could use
session.createQueue and session.createTopic methods.
Both JNDI and the above methods except address strings.

The reason why your queue wasn't durable was bcos the addressing
string is wrong.
message_testqueue; {create: always, node-properties: {durable: true}}"

It should "node", not "node-properties".

Regards,

Rajith

On Mon, May 16, 2011 at 5:35 PM, Mahmoud Parsian <mparsian@yahoo.com> wrote:
> After some research and testing, I found a solution for using persistent queues:
>
> Destination queue = new AMQAnyDestination(new AMQShortString("test.direct"),     
          // exchangeName
>   new AMQShortString("direct"),// exchangeClass
>   new AMQShortString("testqueue"), // routingKey
>   false,// isExclusive
>   false,// isAutoDelete
>   new AMQShortString("testqueue"),        // queueName
>   true,// isDurable
>   new AMQShortString[]{new AMQShortString("test")}); // bindingKeys
>
> The queue (defined above) uses pre-built persistent queue created by qpid server.
>
> Using jconsole, I verified the results.
>
> best,
> Mahmoud
>
>
> ________________________________
> From: Mahmoud Parsian <mparsian@yahoo.com>
> To: "users@qpid.apache.org" <users@qpid.apache.org>
> Cc: Mahmoud Parsian <mparsian@yahoo.com>
> Sent: Monday, May 9, 2011 3:33 PM
> Subject: putting a message into a defined queue (created by a qpid server at startup
time)
>
>
> Hello all,
>
> I posted my question in a wrong thread, so I am posting it here again (sorry about this!).
>
> I am using qpid-0.10 (Java with BDB persistence for messages). I define a single queue
(it's name is: testqueue -- definition is given below), which is created at server start up
time.
> Then I put 2 messages into this queue (code is given below), but it seems that my messages
are not put there, but put in qpid store (somewhere!). When I restart the server, the log
file indicates that:
>  "Message id 1 in store, but not in any queue - removing...."
>  "Message id 2 in store, but not in any queue - removing...."
>
> What is the proper way of putting messages into specific queues? I am using the following
to designate my testqueue (complete code is given below):
>
>         Destination queue = new AMQAnyDestination("ADDR:message_testqueue; {create:
always, node-properties: {durable: true}}");
>
>
> Many thanks in advance.
> best,
> Mahmoud
>
> === code which puts messages into a queue ---- (I want to put into "testqueue" defined
in virtualhosts.xml file which I point to) ===
>
> import java.util.ArrayList;
> import java.util.Arrays;
> import java.util.HashMap;
> import java.util.List;
> import java.util.Map;
> import javax.jms.Connection;
> import javax.jms.Destination;
> import javax.jms.MapMessage;
> import javax.jms.MessageProducer;
> import javax.jms.Session;
> import org.apache.qpid.client.AMQAnyDestination;
> import org.apache.qpid.client.AMQConnection;
>
> public class MapSender {
>
>     public static void main(String[] args) throws Exception {
>         Connection connection =  new AMQConnection("amqp://guest:guest@test/?brokerlist='tcp://dhcp45.nextbiosystem.com:5672'");
>         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
>         Destination queue = new AMQAnyDestination("ADDR:message_testqueue; {create:
always, node-properties: {durable: true}}");
>         MessageProducer producer = session.createProducer(queue);
>
>         MapMessage m = session.createMapMessage();
>         m.setIntProperty("Id", 987654321);
>         m.setStringProperty("name", "Widget");
>         m.setDoubleProperty("price", 0.99);
>         m.setJMSExpiration(0);
>         producer.send(m);
>         connection.close();
>     }
> }
>
> ====  virtualhosts.xml file which defines testqueue =====
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <virtualhosts>
>     <default>test</default>
>     <virtualhost>
>         <name>test</name>
>         <test>
>             <store>
>                  <class>org.apache.qpid.server.store.berkeleydb.BDBMessageStore</class>
>                  <!-- <class>org.apache.qpid.server.store.MemoryMessageStore</class>
 -->
>             </store>
>
>            <housekeeping>
>                 <threadCount>2</threadCount>
>                 <expiredMessageCheckPeriod>200000</expiredMessageCheckPeriod>
>             </housekeeping>
>
>             <exchanges>
>                 <exchange>
>                     <type>direct</type>
>                     <name>test.direct</name>
>                     <durable>true</durable>
>                 </exchange>
>                 <exchange>
>                     <type>topic</type>
>                     <name>test.topic</name>
>                     <durable>true</durable>
>                 </exchange>
>             </exchanges>
>
>             <queues>
>                 <minimumAlertRepeatGap>30000</minimumAlertRepeatGap>
>                 <maximumMessageCount>50</maximumMessageCount>
>                 <durable>true</durable>
>                 <queue>
>                     <name>testqueue</name>
>                     <testqueue>
>                         <exchange>amq.direct</exchange>
>                         <maximumQueueDepth>4235264</maximumQueueDepth>
    <!-- 4Mb -->
>                         <maximumMessageSize>2117632</maximumMessageSize>
  <!-- 2Mb -->
>                         <maximumMessageAge>600000</maximumMessageAge>
     <!-- 10 mins -->
>                         <durable>true</durable>
>                     </testqueue>
>                 </queue>
>                 <queue>
>                     <name>testping</name><durable>true</durable>
>                     <testping>
>                         <exchange>amq.direct</exchange>
>                         <maximumQueueDepth>4235264</maximumQueueDepth>
    <!-- 4Mb -->
>                         <maximumMessageSize>2117632</maximumMessageSize>
  <!-- 2Mb -->
>                         <maximumMessageAge>600000</maximumMessageAge>
     <!-- 10 mins -->
>                         <durable>true</durable>
>                     </testping>
>                 </queue>
>             </queues>
>         </test>
>     </virtualhost>
> </virtualhosts>
>
> ==== server log file ===============
> 2011-05-09 11:48:20,544 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] BRK-1001
: Startup : Version: 0.10 Build: 1091571
> 2011-05-09 11:48:20,683 WARN  [main] (AMQUserManagementMBean.java:441) - Access rights
contains user 'user' but there is no authentication data for that user
> 2011-05-09 11:48:20,686 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] MNG-1001
: Startup
> 2011-05-09 11:48:20,706 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] MNG-1002
: Starting : RMI Registry : Listening on port 8999
> 2011-05-09 11:48:20,815 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] MNG-1002
: Starting : JMX RMIConnectorServer : Listening on port 9099
> 2011-05-09 11:48:20,816 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] MNG-1004
: Ready
> 2011-05-09 11:48:20,824 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] VHT-1001
: Created : test
> 2011-05-09 11:48:20,866 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] EXH-1001
: Create : Durable Type: headers Name: amq.match
> 2011-05-09 11:48:20,872 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] EXH-1001
: Create : Durable Type: topic Name: amq.topic
> 2011-05-09 11:48:20,874 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] EXH-1001
: Create : Durable Type: direct Name: amq.direct
> 2011-05-09 11:48:20,876 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] EXH-1001
: Create : Durable Type: fanout Name: amq.fanout
> 2011-05-09 11:48:20,880 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] EXH-1001
: Create : Durable Type: direct Name: <<default>>
> 2011-05-09 11:48:20,884 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] EXH-1001
: Create : Durable Type: direct Name: test.direct
> 2011-05-09 11:48:20,886 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] EXH-1001
: Create : Durable Type: topic Name: test.topic
> 2011-05-09 11:48:20,912 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] [vh(/test)/qu(testqueue)]
QUE-1001 : Create : Durable
> 2011-05-09 11:48:20,936 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] [vh(/test)/ex(direct/amq.direct)/qu(testqueue)/rk(testqueue)]
BND-1001 : Create
> 2011-05-09 11:48:20,938 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] [vh(/test)/qu(testping)]
QUE-1001 : Create : Durable
> 2011-05-09 11:48:20,946 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] [vh(/test)/ex(direct/amq.direct)/qu(testping)/rk(testping)]
BND-1001 : Create
> 2011-05-09 11:48:20,963 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] [vh(/test)/ms(BDBMessageStore)]
CFG-1001 : Created : org.apache.qpid.server.store.berkeleydb.BDBMessageStore
> 2011-05-09 11:48:20,965 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] [vh(/test)/ms(BDBMessageStore)]
MST-1002 : Store location : /home/mahmoud/downloads/qpid-0.10/work/bdbstore/test
> 2011-05-09 11:48:21,163 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] [vh(/test)/ms(BDBMessageStore)]
MST-1004 : Recovery Start
> 2011-05-09 11:48:21,168 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] [vh(/test)/ms(BDBMessageStore)]
TXN-1004 : Recovery Start
> 2011-05-09 11:48:21,187 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] [vh(/test)/ms(BDBMessageStore)]
MST-1001 : Created : org.apache.qpid.server.store.berkeleydb.BDBMessageStore
> 2011-05-09 11:48:21,230 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] [vh(/test)/ms(BDBMessageStore)]
TXN-1001 : Created : org.apache.qpid.server.store.berkeleydb.BDBMessageStore
> 2011-05-09 11:48:21,231 WARN  [main] (VirtualHostConfigRecoveryHandler.java:346) - Message
id 1 in store, but not in any queue - removing....
> 2011-05-09 11:48:21,264 WARN  [main] (VirtualHostConfigRecoveryHandler.java:346) - Message
id 2 in store, but not in any queue - removing....
> 2011-05-09 11:48:21,268 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] [vh(/test)/ms(BDBMessageStore)]
TXN-1006 : Recovery Complete
> 2011-05-09 11:48:21,360 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] BRK-1002
: Starting : Listening on TCP port 5672
> 2011-05-09 11:48:21,361 INFO  [main] (Log4jMessageLogger.java:72) - [Broker] BRK-1004
: Qpid Broker Ready
> 2011-05-09 11:49:25,820 INFO  [MINANetworkDriver(Acceptor)-2] (Log4jMessageLogger.java:72)
- [con:1(/192.168.2.37:54514)] CON-1001 : Open
> 2011-05-09 11:49:25,821 INFO  [MINANetworkDriver(Acceptor)-2] (Log4jMessageLogger.java:72)
- [con:1(/192.168.2.37:54514)] CON-1001 : Open : Protocol Version : 0-10
> 2011-05-09 11:49:25,916 INFO  [MINANetworkDriver(Acceptor)-5] (Log4jMessageLogger.java:72)
- [con:1(test@/192.168.2.37:54514/test)] CON-1001 : Open : Client ID : test : Protocol Version
: 0-10
> 2011-05-09 11:49:26,039 INFO  [MINANetworkDriver(Acceptor)-6] (Log4jMessageLogger.java:72)
- [con:1(test@/192.168.2.37:54514/test)/ch:0] CHN-1001 : Create
> 2011-05-09 11:49:26,105 INFO  [MINANetworkDriver(Acceptor)-9] (Log4jMessageLogger.java:72)
- [con:1(test@/192.168.2.37:54514/test)/ch:0] [vh(/test)/qu(message_testqueue)] QUE-1001 :
Create : Transient
> 2011-05-09 11:49:26,115 INFO  [MINANetworkDriver(Acceptor)-9] (Log4jMessageLogger.java:72)
- [con:1(test@/192.168.2.37:54514/test)/ch:0] [vh(/test)/ex(direct/<<default>>)/qu(message_testqueue)/rk(message_testqueue)]
BND-1001 : Create
> 2011-05-09 11:49:26,192 INFO  [MINANetworkDriver(Acceptor)-11] (Log4jMessageLogger.java:72)
- [con:1(test@/192.168.2.37:54514/test)/ch:0] [sub:0(vh(/test)/qu(message_testqueue)] SUB-1001
: Create : Arguments : Browser
> 2011-05-09 11:49:26,199 INFO  [MINANetworkDriver(Acceptor)-11] (Log4jMessageLogger.java:72)
- [con:1(test@/192.168.2.37:54514/test)/ch:0] [sub:0(vh(/test)/qu(message_testqueue)] SUB-1002
: Close
> 2011-05-09 11:49:26,240 INFO  [MINANetworkDriver(Acceptor)-13] (Log4jMessageLogger.java:72)
- [con:1(test@/192.168.2.37:54514/test)/ch:0] [sub:1(vh(/test)/qu(message_testqueue)] SUB-1001
: Create : Arguments : Browser
> 2011-05-09 11:49:26,375 INFO  [MINANetworkDriver(Acceptor)-5] (Log4jMessageLogger.java:72)
- [con:1(test@/192.168.2.37:54514/test)/ch:0] [sub:1(vh(/test)/qu(message_testqueue)] SUB-1002
: Close
> 2011-05-09 11:49:26,378 INFO  [MINANetworkDriver(Acceptor)-5] (Log4jMessageLogger.java:72)
- [con:1(test@/192.168.2.37:54514/test)/ch:0] [con:1(test@/192.168.2.37:54514/test)/ch:0]
CHN-1003 : Close
> 2011-05-09 11:49:26,381 INFO  [MINANetworkDriver(Acceptor)-5] (Log4jMessageLogger.java:72)
- [con:1(test@/192.168.2.37:54514/test)] [con:1(test@/192.168.2.37:54514/test)] CON-1002 :
Close

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message