Hi Tim,
I haven't been able to reproduce your issue, with the following code I
get one message returned from the LVQ as expected - "Message 1" when
the second send is commented out, "Message 2" when the second send is
uncommented. Does this code not work for you?
public static void main(String[] args) throws Exception
{
Connection producerConnection = new AMQConnection("127.0.0.1",
5672, "guest", "guest", "producer", "/test");
AMQSession producerSession = (AMQSession)
producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
final Map<String,Object> arguments = new HashMap<String, Object>();
arguments.put("qpid.last_value_queue_key","LVQ.key");
producerSession.createQueue(new AMQShortString("QUEUE"),
false, true, false, arguments);
AMQQueue queue = new
org.apache.qpid.client.AMQQueue("amq.direct","QUEUE");
producerSession.declareAndBind(queue);
MessageProducer producer = producerSession.createProducer(queue);
Message msg = producerSession.createTextMessage("Message 1");
msg.setStringProperty( "LVQ.key", "test");
producer.send(msg);
// Uncomment below to test conflation is occurring
/*
msg = producerSession.createTextMessage("Message 2");
msg.setStringProperty( "LVQ.key", "test");
producer.send(msg);
*/
producer.close();
producerSession.close();
producerConnection.close();
Connection consumerConnection = new AMQConnection("127.0.0.1",
5672, "guest", "guest", "consumer", "/test");
AMQSession consumerSession = (AMQSession)
consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = consumerSession.createConsumer(queue);
consumerConnection.start();
Message received;
while((received = consumer.receive(1000))!=null)
{
System.out.println("Message: \"" +
((TextMessage)received).getText() + "\"\t key: " +
received.getStringProperty("LVQ.key"));
}
consumer.close();
consumerSession.close();
consumerConnection.close();
}
Cheers,
Rob
On 7 August 2010 01:19, Tim Chen <[email protected]> wrote:
> Hi Robert,
>
> So I do have a consumer waiting for it, and it's not picking up anything
> (consumer.receive(1000) gives null all the time).
>
> I want to use the LVQ to provide a queue for one (maybe more?) client to
> receive messages,
>
> and when the user is still processing the earlier messages, the producer
> side can update the items in the LVQ using keys that is not yet processed
> but has newer content available.
>
> Hopefully this makes sense.
>
> Anyhow, currently the queue doesn't seem to receive anything since both
> consumer and JMX shows nothing coming in or out of it.
>
> Please let me know is there something wrong in my setup.
>
> Thanks!
>
> Tim
>
>
>
> On Aug 6, 2010, at 2:59 PM, Robert Godfrey wrote:
>
>> On 6 August 2010 20:15, Tim Chen <[email protected]> wrote:
>>>
>>> Hi all,
>>>
>>> I'm trying to play with last value queue. I see that there isn't any
>>> development release for 0.7, so I grabbed trunk from git and tried to do
>>> the
>>> following:
>>>
>>> Map arguments = new HashMap<String, Object>();
>>> arguments.put("qpid.last_value_queue",true);
>>>
>>> arguments.put("qpid.last_value_queue_key","LVQ.key");
>>>
>>> AMQShortString name = new
>>> AMQShortString(_queueName);
>>> session.createQueue( name, true, true, false,
>>> arguments );
>>>
>>> To create the LVQ. And if I don't set the key on the messages, it seems
>>> to
>>> be able to send messages correctly.
>>>
>>> However, once I set the key on the message:
>>>
>>> message.setStringProperty( "LVQ.key", key );
>>>
>>> Messages won't be delieverd to the queue at all, from looking at the JMX
>>> console.
>>>
>>> I wonder how do I make it work?
>>>
>>> Thanks,
>>>
>>> Tim
>>
>> Hi Tim,
>>
>> from the above description (and mention of JMX console) I'm assuming
>> you're trying to use the LVQ on the Java Broker (the C++ Broker also
>> has an implementation of LVQ, but it doesn't work in quite the same
>> way).
>>
>> From the above, and the fact that you see something "different" happen
>> when you send a message with the key set, it sounds like you have set
>> the queue up correctly... What are you seeing on the JMX console that
>> makes you think it is not being delivered? Do you have an consumers
>> on the queue to which the messages are being sent?
>>
>> More generally what is your use case for the LVQ - are you wanting to
>> use it as a "queue" where at most one client will see any message sent
>> to it, or are you looking for more topic like behaviour (where each
>> client listening to the queue will see updates)?
>>
>> Cheers,
>> Rob
>>
>>>
>>> ---------------------------------------------------------------------
>>> Apache Qpid - AMQP Messaging Implementation
>>> Project: http://qpid.apache.org
>>> Use/Interact: mailto:[email protected]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> Apache Qpid - AMQP Messaging Implementation
>> Project: http://qpid.apache.org
>> Use/Interact: mailto:[email protected]
>>
>
>
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:[email protected]