Hi Martin,

On Sun, Aug 10, 2008 at 6:23 PM, Martin Ritchie <[EMAIL PROTECTED]> wrote:

> 2008/8/10 lahiru gunathilake <[EMAIL PROTECTED]>:
> > Hi Martin and Aidan,
> >
> > On Sat, Aug 9, 2008 at 4:31 PM, Martin Ritchie <[EMAIL PROTECTED]>
> wrote:
> >
> >> 2008/8/8 lahiru gunathilake <[EMAIL PROTECTED]>:
> >> > Hi Martin,
> >> >
> >> > Yes, I think Aidan will agree with this idea.
> >> >
> >> > On Fri, Aug 8, 2008 at 10:27 PM, Martin Ritchie <[EMAIL PROTECTED]>
> >> wrote:
> >> >
> >> >> 2008/8/7 Aidan Skinner <[EMAIL PROTECTED]>:
> >> >> > On Thu, Aug 7, 2008 at 6:26 AM, lahiru gunathilake <
> [EMAIL PROTECTED]
> >> >
> >> >> wrote:
> >> >> >
> >> >> >> On Thu, Aug 7, 2008 at 9:13 AM, lahiru gunathilake <
> >> [EMAIL PROTECTED]
> >> >> >wrote:
> >> >> >
> >> >> > Hey dude,
> >> >> >>> I have implemented the delete command. It works like this,
> >> >> >>> queue delete -n ping -v development -t 3 <have to specify the
> >> >> virtualhost
> >> >> >>> in order to get a single queue object> : This delete top three
> >> messages
> >> >> from
> >> >> >>> the specified queue.
> >> >> >
> >> >> > Sweet! Now our users can unclog stuck brokers!
> >> >> >
> >> >> >>> If user didn't give the -t argument all the messages will be
> deleted
> >> >> from
> >> >> >>> the queue.
> >> >> >
> >> >> > I think that's a little risky, I'm quite forgetful and often try to
> do
> >> >> > things before I've had my 3rd cup of tea (which is the one that
> turns
> >> >> > me into a functional person) and I know I'd end up blowing away a
> >> >> > queue by mistake. I think this should be an error, or at least a
> "are
> >> >> > you sure? y/N" prompt
> >> >> >
> >> >> >>> I think the method I'm suppose to call moveMessages and I have to
> >> give
> >> >> >>> three arguments ( from MessageId, to MessageId,Queue). Could you
> >> please
> >> >> tell
> >> >> >>> me what does those mean.
> >> >> >>>
> >> >> >> Do you know any way to get MessageId's ?
> >> >> >
> >> >> > They should be part of the Message object,
> >> >> > Queue.getMessagesOnQueue().getMessage().getMessageId()
> >> >> >
> >> >> > - Aidan
> >> >> > --
> >> >> > Apache Qpid - World Domination through Advanced Message Queueing
> >> >> > http://cwiki.apache.org/qpid
> >> >> > "Nine-tenths of wisdom consists in being wise in time." - Theodore
> >> >> Roosevelt
> >> >>
> >> >> When thinking about the usecase for moving message from queue A to
> >> >> queue B I think the best thing to do might be to implement the
> viewing
> >> >> of Messages first. This will allow the user to identify the messages
> >> >> on the queue and select then provide you with the message ids they
> >> >> wish to move.
> >> >>
> >> >> Having a view command that starts by displaying message ID and header
> >> >> information would be a good start.
> >> >>
> >> >> This will allow the identification of a message which can then be
> used
> >> >> in the move command.
> >> >>
> >> >> Looking at the jmx method you can do
> >> >> view <queue> <num msgs> [<offset>]
> >> >
> >> > Could you please tell me what is the meaning of "index range" with
> >> > viewMessages JMX method. Is it like this,if user wants to delete the
> top
> >> 4
> >> > messages in the queue, then from index = 1, to index = 4 or is it
> >> something
> >> > else.
> >>
> >> yes the viewMessages parameters are an index to the messages based on
> >> their position in the queue. So fromIndex = 1 , toIndex = 4 will give
> >> you the first 4 messages on the queue.
> >>
> >> > And next thing is I want to get some messages in to my broker and test
> my
> >> > implementations. Aidan told me that it can be done by running some
> >> > performance test but I tried by running some scripts but there's no
> >> messages
> >> > in queues.
> >>
> >> Most of the performance tests will consume all the messages what I
> >> would suggest is take a look at the jmsexample.direct Consumer and
> >> Producer. If you start the Consumer then run the Producer you should
> >> see the Consumer receives the messages and exits. If you run the
> >> Producer again then 10 messages should be left on the queue called
> >> 'messageQueue'. If you don't run the Consumer first then you will see
> >> 'javax.jms.JMSException: 312' as the queue has not been created.
> >
> > Thanks Martin,now I can have messages in the Queue message_queue  and
> delete
> > command is works fine for me. I have implemented the view command now I'm
> > getting TabularData object by calling JMX method viewMessages but it's
> bit
> > of difficult to get the actual information from the TabularData object.
> Can
> > somebody help me to figure out how to get information from TabularData
> > object.
> >
> > This code gives me an Exception, when I run view command like this (queue
> > view -n message_queue )
> >
>
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> > TabularData data =
> > (TabularData)this.mbsc.invoke(queue,this.method1,params,signature);
> >                    Object keys[] = data.keySet().toArray();
> >                    CompositeData comdata = data.get(keys);
> >
>
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> > javax.management.openmbean.InvalidKeyException: Argument key's length=11
> is
> > different from the number of item values, which is 1, specified for the
> > indexing rows in this TabularData instance.
> >    at
> >
>
> javax.management.openmbean.TabularDataSupport.checkKeyType(TabularDataSupport.java:805)
> >    at
> >
>
> javax.management.openmbean.TabularDataSupport.get(TabularDataSupport.java:284)
> >    at org.apache.qpid.commands.Commandview.viewmessages(Unknown Source)
> >    at org.apache.qpid.commands.Commandview.execute(Unknown Source)
> >    at org.apache.qpid.CommandExecusionEngine.runcommand(Unknown Source)
> >    at org.apache.qpid.CommandLineInterpreter.main(Unknown Source)
> >
>
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> > When there's one message in the queue I tried to print the TabularData
> > object using toSting method it display something like this.
> >
>
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> >
>
> javax.management.openmbean.TabularDataSupport(tabularType=javax.management.openmbean.TabularType(name=Messages,rowType=javax.management.openmbean.CompositeType(name=Message,items=((itemName=AMQ
> >
>
> MessageId,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=Header,itemType=javax.management.openmbean.ArrayType(name=[Ljava.lang.String;,dimension=1,elementType=javax.management.openmbean.SimpleType(name=java.lang.String),primitiveArray=false)),(itemName=Redelivered,itemType=javax.management.openmbean.SimpleType(name=java.lang.Boolean)),(itemName=Size(bytes),itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)))),indexNames=(AMQ
> >
>
> MessageId)),contents={[22]=javax.management.openmbean.CompositeDataSupport(compositeType=javax.management.openmbean.CompositeType(name=Message,items=((itemName=AMQ
> >
>
> MessageId,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=Header,itemType=javax.management.openmbean.ArrayType(name=[Ljava.lang.String;,dimension=1,elementType=javax.management.openmbean.SimpleType(name=java.lang.String),primitiveArray=false)),(itemName=Redelivered,itemType=javax.management.openmbean.SimpleType(name=java.lang.Boolean)),(itemName=Size(bytes),itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)))),contents={AMQ
> > MessageId=22, Header=[Ljava.lang.String;@1f82982, Redelivered=false,
> > Size(bytes)=18})})
> >
> >
>
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> > Can someone please tell me how to get the actual information and print
> them
> > in to screan.
> >
> > Thanks in advance
> >
> > Lahiru
> >
> >>
> >>
> >> Cheers
> >>
> >> Martin
> >>
> >> > Could you please address my two questions..?
> >> >
> >> > Thanks in advance
> >> > Lahiru
> >> >
> >> >>
> >> >>
> >> >> viewMessages(<offset>, <num msg>)
> >> >> This will return details of all the messages currently on the queue.
> >> >>
> >> >> Which includes the messageID in the reply.
> >> >> ViewUtility.populateCompositeWithCompositeData shows how the current
> >> >> Management interface extracts this information, although it is quite
> >> >> generic code I hope it is reasonable clear to read.
> >> >>
> >> >> from this you can print the msgID list then work up to extracting the
> >> >> header and other values for the message which it would be nice to be
> >> >> able to specify on command line:
> >> >> view <queue> <num msgs> [<offset>] [-show-headers] [-show-content]
> >> >>
> >> >> This should make implementing move much easier as you don't need to
> >> >> progamatically find the ids as the user will provide them
> >> >>
> >> >> hope that helps
> >>
> > Exactly helped a lot :-)
> >
> >>
> >> >>
> >> >> Martin
> >> >>
> >> >>
> >> >> --
> >> >> Martin Ritchie
> >> >>
> >> >
> >>
> >>
> >>
> >> --
> >> Martin Ritchie
> >>
> >
>
> Lahiru,
>
> I've tried to display the output as a hierarchy for as it helps with
> understanding the structure. I also put this info together using the
> ViewUtility and OperationsTabControl classes in the JMX Management tool.
> Whilst that code is very generic so capable of displaying any TabularData
> response we can extract the key parts you need. I usually hate HTML emails
> but I'm hoping that gmail/the-list will not play with the formatting to
> much
> so that the code parts and reformatted output are more readable.
> As I can see it this is what the Management console does the following to
> display message data:
>
>        // data is the results of calling this.mbsc.invoke as in your
> example above
>        Set entrySet = data.entrySet();
>        ArrayList<Map.Entry> list = new ArrayList<Map.Entry>(entrySet);
>        if (list.size() == 0) {// no data}
>        CompositeData compositedata =
> (CompositeData)(list.get(0)).getValue();
>        //you could iterate over 'list' the UI code just displays the first
> value hence the get(0)
>
>        //with the CompositeDataSupport object (compositedata) you can do
>        List<String> itemNames = new
> ArrayList<String>(compositedata.getCompositeType().keySet());
>
>        //Which will give you the list of items you can retrieve:
> AMQMessageID, Header, Relieved, Size
>        //From here you can get the type of the item:
>        OpenType itemType =
> compositedata.getCompositeType().getType(itemName);
>
>        //Handy if you want to check that Header is indeed an array
>        //String Or you can just retrieve the value:
>       String.valueOf(compositedata.get(itemName))
>
>
> Hope that helps,

Of course Martin it helped me a lot, as I said now view and viewcontent
commands are working.
Big Thank You for both of you to help me to get through the data
modification stuff. I think in example producer is sending empty messages
without any encoding .... Am I correct ..?
Now I have to go to sleep(it's 11.30 pm here) since I'm suppose to wakeup
around 3.45am :-)

Thanks in advanced

Cheers
Lahiru

>
>
> Martin
>
>
> javax.management.openmbean.TabularDataSupport
> (tabularType=javax.management.openmbean.TabularType
> (name=Messages,
> rowType=javax.management.openmbean.CompositeType
> (name=Message,
> items=
> (
> (itemName=AMQMessageId,
> itemType=javax.management.openmbean.SimpleType
> (name=java.lang.Long)),
> (itemName=Header,
> itemType=javax.management.openmbean.ArrayType
> (name=[Ljava.lang.String;,
> dimension=1,
> elementType=javax.management.openmbean.SimpleType
> (name=java.lang.String),
> primitiveArray=false)),
> (itemName=Redelivered,
> itemType=javax.management.openmbean.SimpleType
> (name=java.lang.Boolean)),
> (itemName=Size(bytes),
> itemType=javax.management.openmbean.SimpleType
> (name=java.lang.Long)
> )
> )
> ),
> indexNames=(AMQMessageId)
> ),
> contents={[22]=javax.management.openmbean.CompositeDataSupport
> (compositeType=javax.management.openmbean.CompositeType
> (name=Message,
> items=
> (
> (itemName=AMQMessageId,
> itemType=javax.management.openmbean.SimpleType
> (name=java.lang.Long)
> ),
> (itemName=Header,
> itemType=javax.management.openmbean.ArrayType
> (name=[Ljava.lang.String;,
> dimension=1,
> elementType=javax.management.openmbean.SimpleType
> (name=java.lang.String),
> primitiveArray=false)
> ),
> (itemName=Redelivered,
> itemType=javax.management.openmbean.SimpleType
> (name=java.lang.Boolean)
> ),
> (itemName=Size(bytes),
> itemType=javax.management.openmbean.SimpleType
> (name=java.lang.Long)
> )
> )
> ),
> contents={AMQMessageId=22,
>  Header=[Ljava.lang.String;@1f82982,
>  Redelivered=false,
> Size(bytes)=18})})
>
> --
> Martin Ritchie
>

Reply via email to