You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by Julien Lavigne du Cadet <j....@abc-arbitrage.com> on 2009/07/06 19:04:18 UTC

RE: c# multiple producers on seperate threads

You'll find the patch for this issue (and 2 other things) in this JIRA : 
https://issues.apache.org/jira/secure/ManageAttachments.jspa?id=12429626

Regards,

Julien

-----Message d'origine-----
De : Julien Lavigne du Cadet [mailto:j.lavigneducadet@abc-arbitrage.com] 
Envoyé : lundi 6 juillet 2009 17:33
À : users@qpid.apache.org; cctrieloff@redhat.com; mr.b0nj@gmail.com
Objet : RE: c# multiple producers on seperate threads

That's most certainly a threading issue now that the randomUUID is not recreating a ramdom object each time it's called. Could you try applying the attached patch to your trunk? I added a lock in the method. It may not be optimal for performance but it should probably fix your issue (However I was not able to reproduce it yet, so I can't be sure)

By the way, how many messages/producers were you using?

Julien


-----Message d'origine-----
De : Benn [mailto:mr.b0nj@gmail.com] 
Envoyé : lundi 6 juillet 2009 16:35
À : users@qpid.apache.org; cctrieloff@redhat.com
Objet : Re: c# multiple producers on seperate threads

Hey, i got the latest trunk and applied the patch suggested and this error
does indeed go away, however i do seem to get this:

Unhandled Exception: System.IndexOutOfRangeException: Array index is out of
range.
  at System.Random.Sample () [0x00000]
  at System.Random.NextBytes (System.Byte[] buffer) [0x00000]
  at org.apache.qpid.transport.util.UUID.randomUUID () [0x00000]
  at org.apache.qpid.client.ClientSession.messageTransfer (System.String
destination, IMessage message) [0x00000]
  at QTest.Program.Runner () [0x00000]

Many thanks.
Benn

2009/7/6 Carl Trieloff <cc...@redhat.com>

>
> sorry about the delay in sometimes in getting the patches reviewed. If
> there is a patch outstanding for a few days the best is to fire a mail to
> the
> list to bring attention to the Jira.
>
> It looked like Ted had picked up the patch, so I will leave it with him for
> now.
> Carl.
>
>
>
> Julien Lavigne du Cadet wrote:
>
>> I wouldn't be surprised if it was a problem of duplicated UUID. The .Net
>> api is broken in that regards as UUID.randomUUID() is everything but random.
>>
>> I've just uploaded a third patch for this class (UUID) on JIRA (
>> https://issues.apache.org/jira/secure/ManageAttachments.jspa?id=12427578),
>> fixing the "not random UUID" issue.
>> Please note that I would certainly have done it before if any of the 2
>> previous patches had been applied... I'm very grateful for the work of the
>> committers on this project but I also find it quite discouraging for the
>> community when patches are not evaluated.
>>
>>
>> -----Message d'origine-----
>> De : Gordon Sim [mailto:gsim@redhat.com] Envoyé : lundi 6 juillet 2009
>> 11:09
>> À : users@qpid.apache.org
>> Objet : Re: c# multiple producers on seperate threads
>>
>> Benn wrote:
>>
>>
>>> Hi Gordon,
>>> Just looking through the log and seen the following...
>>>
>>>
>>> 2009-jul-06 09:23:45 debug SessionState::SessionState
>>> guest@QPID.1cf3d1fbf-1ac35-14db7-19fa0-113c720be1772: 0x9086108
>>> 2009-jul-06 09:23:45 debug
>>> guest@QPID.1cf3d1fbf-1ac35-14db7-19fa0-113c720be1772: attached on
>>> broker.
>>> 2009-jul-06 09:23:45 debug Attached channel 1 to
>>> guest@QPID.1cf3d1fbf-1ac35-14db7-19fa0-113c720be1772
>>> 2009-jul-06 09:23:45 debug
>>> guest@QPID.1cf3d1fbf-1ac35-14db7-19fa0-113c720be1772: ready to send,
>>> activating output.
>>> 2009-jul-06 09:23:45 trace 209.160.72.159:2144-12(local) activateOutput
>>> -
>>> sending doOutput
>>> 2009-jul-06 09:23:45 trace MCAST 209.160.72.159:2144-12:
>>> {ClusterConnectionDeliverDoOutputBody: bytes=41; }
>>> 2009-jul-06 09:23:45 trace 209.160.72.159:2144-12(local)Send doOutput
>>> request for 41
>>> 2009-jul-06 09:23:45 trace SENT [217.41.62.170:7445]: Frame[BEbe;
>>> channel=1;
>>> {SessionAttachedBody: name=1cf3d1fbf-1ac35-14db7-19fa0-113c720be1772; }]
>>> 2009-jul-06 09:23:45 trace SENT [217.41.62.170:7445]: Frame[BEbe;
>>> channel=1;
>>> {SessionCommandPointBody: command-id=0; command-offset=0; }]
>>> 2009-jul-06 09:23:45 trace 209.160.72.159:2144(READY) DLVR:
>>> Event[209.160.72.159:2144-12 control 22 bytes]
>>> 2009-jul-06 09:23:45 trace 209.160.72.159:2144(READY) DLVR:  Frame[BEbe;
>>> channel=0; {ClusterConnectionDeliverDoOutputBody: bytes=41; }] control
>>> 209.160.72.159:2144-12
>>> 2009-jul-06 09:23:45 trace 209.160.72.159:2144-12(local)
>>> delivereDoOutput:
>>> requested=41 sent=0 more=0
>>> 2009-jul-06 09:23:45 trace MCAST Event[209.160.72.159:2144-15 data 59
>>> bytes]
>>> 2009-jul-06 09:23:45 trace 209.160.72.159:2144(READY) DLVR:
>>> Event[209.160.72.159:2144-15 data 59 bytes]
>>> 2009-jul-06 09:23:45 trace 209.160.72.159:2144(READY) DLVR:  Frame[BEbe;
>>> channel=1; {SessionAttachBody:
>>> name=1cf3d1fbf-1ac35-14db7-19fa0-113c720be1772; }] data
>>> 209.160.72.159:2144-15
>>> read-credit=1
>>> 2009-jul-06 09:23:45 debug Exception constructed: Session already
>>> attached:
>>> guest@QPID.1cf3d1fbf-1ac35-14db7-19fa0-113c720be1772
>>> (qpid/broker/SessionManager.cpp:55)
>>> 2009-jul-06 09:23:45 error Channel exception: session-busy: Session
>>> already
>>> attached: guest@QPID.1cf3d1fbf-1ac35-14db7-19fa0-113c720be1772
>>> (qpid/broker/SessionManager.cpp:55)
>>> 2009-jul-06 09:23:45 trace SENT [217.41.62.170:13894]: Frame[BEbe;
>>> channel=1; {SessionDetachedBody:
>>> name=1cf3d1fbf-1ac35-14db7-19fa0-113c720be1772; code=1; }]
>>> 2009-jul-06 09:23:45 trace MCAST Event[209.160.72.159:2144-13 data 59
>>> bytes]
>>>
>>> Any help much appreciated.
>>>
>>>
>>
>>  From this it looks like either the same uuid is being used for two
>> different sessions, or somehow the attach control is being sent (or received
>> twice). Could you include some of the lines just before this
>> snippet to try and work out which of these it is?
>>
>> Also, do you see the same issue with a standalone broker (i.e.
>> non-clustered)?
>>
>>
>>
>>> 2009/7/6 Gordon Sim <gs...@redhat.com>
>>>
>>>
>>>
>>>> Benn wrote:
>>>>
>>>>
>>>>
>>>>> Hi There,
>>>>> I'm hoping someone has come accross this issue before or can maybe shed
>>>>> some
>>>>> light on why this is happening.
>>>>>
>>>>> I have ported a test application i wrote for RabbitMQ (which worked
>>>>> fine)
>>>>> but it throws a SessionClosedException when multiple producers are
>>>>> started.
>>>>> Perhaps i am going about this all the wrong way for Qpid - but it
>>>>> seemed
>>>>> right to me... any assistance would be appreciated :)
>>>>>
>>>>>
>>>>>
>>>> Do you see any errors logged on the broker?
>>>>
>>>>
>>>>  Here is my (very) simple app:
>>>>
>>>>
>>>>>
>>>>> --------------------------------------------------------------------------------------------
>>>>>
>>>>> using System;
>>>>> using System.Collections;
>>>>> using System.Text;
>>>>> using System.Threading;
>>>>> using org.apache.qpid.client;
>>>>> using org.apache.qpid.transport;
>>>>>
>>>>> namespace QTest
>>>>> {
>>>>> class Program
>>>>> {
>>>>>  static Queue testQueue = Queue.Synchronized(new Queue());
>>>>> static bool run = true;
>>>>>  public static void Main(string[] args)
>>>>> {
>>>>> int messages = int.Parse(args[0]);
>>>>> int producers = int.Parse(args[1]);
>>>>>  PopulateQueue(messages);
>>>>>  DateTime start = DateTime.Now;
>>>>>  for (int x = 0; x < producers ; x++ ) {
>>>>> Thread thd = new Thread(new ThreadStart(Runner));
>>>>> thd.IsBackground = true;
>>>>> thd.Start();
>>>>> }
>>>>>  while (testQueue.Count > 0) {
>>>>> Thread.Sleep(10);
>>>>> }
>>>>>  TimeSpan end = DateTime.Now.Subtract(start);
>>>>>  Console.WriteLine("{0} producers took {1} seconds to enqueue {2}
>>>>> messages",
>>>>> producers, end.TotalSeconds, messages);
>>>>>  run = false;
>>>>>  Console.ReadLine();
>>>>> }
>>>>>  public static void PopulateQueue(int count)
>>>>> {
>>>>> for (int i = 0; i < count ; i++) {
>>>>> testQueue.Enqueue(string.Format("Message: {0}", i));
>>>>> }
>>>>> }
>>>>>  public static void Runner()
>>>>> {
>>>>> Client connection = new Client();
>>>>> connection.connect("redrabbits.co.uk", 5672, string.Empty, "guest",
>>>>> "guest");
>>>>> ClientSession session = connection.createSession(50000);
>>>>>  IMessage message = new Message();
>>>>> message.DeliveryProperties.setRoutingKey("testing");
>>>>> while (run) {
>>>>> if(testQueue.Count > 0) {
>>>>> object thisMsg = testQueue.Dequeue();
>>>>> if(thisMsg != null) {
>>>>>  // put it in message queue
>>>>> message.clearData();
>>>>> message.appendData(Encoding.UTF8.GetBytes(thisMsg.ToString()));
>>>>> session.messageTransfer("amq.direct", message);
>>>>> }
>>>>> }
>>>>> Thread.Sleep(10);
>>>>> }
>>>>>  session.sync();
>>>>> connection.close();
>>>>> }
>>>>> }
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -------------------------------------------------------------------------------------
>>>>>
>>>>> Many thanks in advance :)
>>>>>
>>>>>
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> Apache Qpid - AMQP Messaging Implementation
>>>> Project:      http://qpid.apache.org
>>>> Use/Interact: mailto:users-subscribe@qpid.apache.org
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> Apache Qpid - AMQP Messaging Implementation
>> Project:      http://qpid.apache.org
>> Use/Interact: mailto:users-subscribe@qpid.apache.org
>>
>>
>> P  Please consider your environmental responsibility before printing this
>> email
>>
>>
>> *********************************************************************************
>> Ce message peut contenir des informations confidentielles. Les idees et
>> opinions presentees dans ce message sont celles de son auteur, et ne
>> representent pas necessairement
>> celles du groupe ABC arbitrage.
>> Au cas ou il ne vous serait pas destine,
>> merci d'en aviser l'expediteur immediatement et de le supprimer.
>>
>> This message may contain confidential information. Any views or opinions
>> presented are solely those of its author and do not necessarily represent
>> those of ABC arbitrage. If you are not the intended recipient,
>> please notify the sender immediately and delete it.
>>
>> *********************************************************************************
>>
>>
>>
>> ---------------------------------------------------------------------
>> Apache Qpid - AMQP Messaging Implementation
>> Project:      http://qpid.apache.org
>> Use/Interact: mailto:users-subscribe@qpid.apache.org
>>
>>
>>
>
>


-- 
Cheers,
Benn

P  Please consider your environmental responsibility before printing this email

*********************************************************************************
Ce message peut contenir des informations confidentielles. 
Les idees et opinions presentees dans ce message 
sont celles de son auteur, et ne representent pas necessairement
celles du groupe ABC arbitrage.
Au cas ou il ne vous serait pas destine,
merci d'en aviser l'expediteur immediatement et de le supprimer.

This message may contain confidential information. 
Any views or opinions presented are solely those of its author 
and do not necessarily represent those of ABC arbitrage. 
If you are not the intended recipient,
please notify the sender immediately and delete it.
*********************************************************************************



P  Please consider your environmental responsibility before printing this email

*********************************************************************************
Ce message peut contenir des informations confidentielles. 
Les idees et opinions presentees dans ce message 
sont celles de son auteur, et ne representent pas necessairement
celles du groupe ABC arbitrage.
Au cas ou il ne vous serait pas destine,
merci d'en aviser l'expediteur immediatement et de le supprimer.

This message may contain confidential information. 
Any views or opinions presented are solely those of its author 
and do not necessarily represent those of ABC arbitrage. 
If you are not the intended recipient,
please notify the sender immediately and delete it.
*********************************************************************************



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org